idlehomescreen/xmluirendering/uiengine/src/xnnodeimpl.cpp
changeset 0 f72a12da539e
child 1 5315654608de
equal deleted inserted replaced
-1:000000000000 0:f72a12da539e
       
     1 /*
       
     2 * Copyright (c) 2002-2008 Nokia Corporation and/or its subsidiary(-ies).
       
     3 * All rights reserved.
       
     4 * This component and the accompanying materials are made available
       
     5 * under the terms of "Eclipse Public License v1.0"
       
     6 * which accompanies this distribution, and is available
       
     7 * at the URL "http://www.eclipse.org/legal/epl-v10.html".
       
     8 *
       
     9 * Initial Contributors:
       
    10 * Nokia Corporation - initial contribution.
       
    11 *
       
    12 * Contributors:
       
    13 *
       
    14 * Description:  Implementation part of bridge pattern in CXnNode
       
    15 *
       
    16 */
       
    17 
       
    18 // System includes
       
    19 #include <AknUtils.h>
       
    20 #include <utf.h>
       
    21 #include <mmf/common/mmfcontrollerpluginresolver.h>
       
    22 
       
    23 // User includes
       
    24 #include "xnnodeimpl.h"
       
    25 #include "xnnode.h"
       
    26 #include "xnpropertylist.h"
       
    27 #include "xnproperty.h"
       
    28 #include "xnuiengine.h"
       
    29 #include "xnappuiadapter.h"
       
    30 #include "xncontroladapter.h"
       
    31 #include "xnpopupcontroladapter.h"
       
    32 #include "xnmenuadapter.h"
       
    33 #include "xndomlist.h"
       
    34 #include "xndomdocument.h"
       
    35 #include "xnpointerarray.h"
       
    36 #include "xnodt.h"
       
    37 #include "xntype.h"
       
    38 #include "xndomnode.h"
       
    39 #include "xndomattribute.h"
       
    40 #include "xndompropertyvalue.h"
       
    41 #include "xnpopup.h"
       
    42 #include "c_xnutils.h"
       
    43 #include "xneditmode.h"
       
    44 #include "xneditor.h"
       
    45 #include "xntext.h"
       
    46 #include "xnhittest.h"
       
    47 #include "xnscrollablecontroladapter.h"
       
    48 #include "xnviewdata.h"
       
    49 #include "xnpanic.h"
       
    50 #include "xnlistquerydialogadapter.h"
       
    51 #include "xneffectmanager.h"
       
    52 #include "xnviewadapter.h"
       
    53 
       
    54 // Local constants
       
    55 _LIT8( KRef, "ref" );
       
    56 _LIT8( KId, "id" );
       
    57 _LIT8( KName, "name" );
       
    58 _LIT8( KToolTip, "tooltip" );
       
    59 _LIT8( KMenuBar, "menubar" );
       
    60 
       
    61 _LIT8( KActionsHandler, "actionshandler" );
       
    62 
       
    63 const TReal KS60ScrollbarDefaultWidth = 1.5;
       
    64 const TReal KS60ScrollbarDefaultMargin = 0.25;
       
    65 const TReal KS60ScrollbarDefaultWidthPenEnabled = 3;
       
    66 const TReal KS60ScrollbarDefaultMarginPenEnabled = 0.5;
       
    67 const TInt KUnitMaxLen = 2;
       
    68 const TInt KOneView = 1;
       
    69 
       
    70 _LIT8( KPseudoClassFocus, "focus" );
       
    71 _LIT8( KPseudoClassPressedDown, "presseddown" );
       
    72 _LIT8( KPseudoClassPassiveFocus, "passivefocus" );
       
    73 _LIT8( KPseudoClassHold, "hold" );
       
    74 _LIT8( KPseudoClassHover, "hover" );
       
    75 _LIT8( KPseudoClassLink, "link" );
       
    76 _LIT8( KPseudoClassVisited, "visited" );
       
    77 _LIT8( KPseudoClassActive, "active" );
       
    78 _LIT8( KPseudoClassEdit, "edit" );
       
    79 
       
    80 _LIT8( KCompound, "compound" );
       
    81 _LIT8( KTrue, "true" );
       
    82 _LIT8( KDisplay, "display" );
       
    83 _LIT8( KBlock, "block" );
       
    84 _LIT8( KNone, "none" );
       
    85 _LIT8( KGainEnd, "gainend" );
       
    86 _LIT8( KLoseEnd, "loseend" );
       
    87 
       
    88 // Local classes
       
    89 struct TXnTimedTrigger
       
    90     {
       
    91     CXnNodeImpl* iNodeImpl;
       
    92     CXnUiEngine* iEngine;
       
    93     CXnNode* iNode;
       
    94     CXnNode* iEventData;
       
    95     CXnDomNode* iActionNode;
       
    96     CXnDomNode* iTriggerNode;
       
    97     };
       
    98 
       
    99 struct CGridPropertyCache : public CBase
       
   100     {
       
   101     CXnProperty* iVisibleRows;
       
   102     CXnProperty* iGridColumns;
       
   103     CXnProperty* iGridOrientation;
       
   104     CXnProperty* iGridVerDirection;
       
   105     CXnProperty* iGridHorDirection;
       
   106     CXnProperty* iFocusHorLooping;
       
   107     CXnProperty* iFocusVerLooping;
       
   108     CXnProperty* iGridScrollBarWidth;
       
   109     CXnProperty* iGridScrollBarMargin;
       
   110     };
       
   111 
       
   112 struct CLayoutPropertyCache : public CBase
       
   113     {
       
   114     CLayoutPropertyCache() :
       
   115         iWidths( 1 ),
       
   116         iHeights( 1 ),
       
   117         iMarginLefts( 1 ),
       
   118         iMarginRights( 1 ),
       
   119         iBorderLefts( 1 ),
       
   120         iBorderRights( 1 ),
       
   121         iPaddingLefts( 1 ),
       
   122         iPaddingRights( 1 ),
       
   123         iMarginTops( 1 ),
       
   124         iMarginBottoms( 1 ),
       
   125         iBorderTops( 1 ),
       
   126         iBorderBottoms( 1 ),
       
   127         iPaddingTops( 1 ),
       
   128         iPaddingBottoms( 1 ),
       
   129         iBorderWidths( 1 ),
       
   130         iBlockProgressions( 1 ),
       
   131         iDirections( 1 ),
       
   132         iPositions( 1 ),
       
   133         iMaxHeights( 1 ),
       
   134         iMinHeights( 1 ),
       
   135         iMaxWidths( 1 ),
       
   136         iMinWidths( 1 ),
       
   137         iDisplays( 2 ),
       
   138         iVisibilities( 1 ),
       
   139         iLefts( 1 ),
       
   140         iRights( 1 ),
       
   141         iTops( 1 ),
       
   142         iBottoms( 1 ),
       
   143         iBorderLeftStyles( 1 ),
       
   144         iBorderRightStyles( 1 ),
       
   145         iBorderTopStyles( 1 ),
       
   146         iBorderBottomStyles( 1 ),
       
   147         iBorderStyles( 1 ),
       
   148         iDisplayPriorities( 1 ),
       
   149         iNavIndexes( 1 ),
       
   150         iBackgroundColors( 1 ),
       
   151         iBackgroundImages( 1 ),
       
   152         iFocusBackgrounds( 2 )
       
   153             {
       
   154             }
       
   155 
       
   156     ~CLayoutPropertyCache()
       
   157         {
       
   158         iWidths.Reset();
       
   159         iHeights.Reset();
       
   160         iMarginLefts.Reset();
       
   161         iMarginRights.Reset();
       
   162         iBorderLefts.Reset();
       
   163         iBorderRights.Reset();
       
   164         iPaddingLefts.Reset();
       
   165         iPaddingRights.Reset();
       
   166         iMarginTops.Reset();
       
   167         iMarginBottoms.Reset();
       
   168         iBorderTops.Reset();
       
   169         iBorderBottoms.Reset();
       
   170         iPaddingTops.Reset();
       
   171         iPaddingBottoms.Reset();
       
   172         iBorderWidths.Reset();
       
   173         iBlockProgressions.Reset();
       
   174         iDirections.Reset();
       
   175         iPositions.Reset();
       
   176         iMaxHeights.Reset();
       
   177         iMinHeights.Reset();
       
   178         iMaxWidths.Reset();
       
   179         iMinWidths.Reset();
       
   180         iDisplays.Reset();
       
   181         iVisibilities.Reset();
       
   182         iLefts.Reset();
       
   183         iRights.Reset();
       
   184         iTops.Reset();
       
   185         iBottoms.Reset();
       
   186         iBorderLeftStyles.Reset();
       
   187         iBorderRightStyles.Reset();
       
   188         iBorderTopStyles.Reset();
       
   189         iBorderBottomStyles.Reset();
       
   190         iBorderStyles.Reset();
       
   191         iDisplayPriorities.Reset();
       
   192         iNavIndexes.Reset();
       
   193         iBackgroundColors.Reset();
       
   194         iZIndexes.Reset();
       
   195         iBackgroundImages.Reset();
       
   196         iFocusBackgrounds.Reset();
       
   197         }
       
   198 
       
   199     CXnProperty* iWidth;
       
   200     RPointerArray< CXnProperty > iWidths;
       
   201     CXnProperty* iHeight;
       
   202     RPointerArray< CXnProperty > iHeights;
       
   203     CXnProperty* iMarginLeft;
       
   204     RPointerArray< CXnProperty > iMarginLefts;
       
   205     CXnProperty* iMarginRight;
       
   206     RPointerArray< CXnProperty > iMarginRights;
       
   207     CXnProperty* iBorderLeft;
       
   208     RPointerArray< CXnProperty > iBorderLefts;
       
   209     CXnProperty* iBorderRight;
       
   210     RPointerArray< CXnProperty > iBorderRights;
       
   211     CXnProperty* iPaddingLeft;
       
   212     RPointerArray< CXnProperty > iPaddingLefts;
       
   213     CXnProperty* iPaddingRight;
       
   214     RPointerArray< CXnProperty > iPaddingRights;
       
   215     CXnProperty* iMarginTop;
       
   216     RPointerArray< CXnProperty > iMarginTops;
       
   217     CXnProperty* iMarginBottom;
       
   218     RPointerArray< CXnProperty > iMarginBottoms;
       
   219     CXnProperty* iBorderTop;
       
   220     RPointerArray< CXnProperty > iBorderTops;
       
   221     CXnProperty* iBorderBottom;
       
   222     RPointerArray< CXnProperty > iBorderBottoms;
       
   223     CXnProperty* iPaddingTop;
       
   224     RPointerArray< CXnProperty > iPaddingTops;
       
   225     CXnProperty* iPaddingBottom;
       
   226     RPointerArray< CXnProperty > iPaddingBottoms;
       
   227     CXnProperty* iBorderWidth;
       
   228     RPointerArray< CXnProperty > iBorderWidths;
       
   229     CXnProperty* iBlockProgression;
       
   230     RPointerArray< CXnProperty > iBlockProgressions;
       
   231     CXnProperty* iDirection;
       
   232     RPointerArray< CXnProperty > iDirections;
       
   233     CXnProperty* iPosition;
       
   234     RPointerArray< CXnProperty > iPositions;
       
   235     CXnProperty* iMaxHeight;
       
   236     RPointerArray< CXnProperty > iMaxHeights;
       
   237     CXnProperty* iMinHeight;
       
   238     RPointerArray< CXnProperty > iMinHeights;
       
   239     CXnProperty* iMaxWidth;
       
   240     RPointerArray< CXnProperty > iMaxWidths;
       
   241     CXnProperty* iMinWidth;
       
   242     RPointerArray< CXnProperty > iMinWidths;
       
   243     CXnProperty* iDisplay;
       
   244     RPointerArray< CXnProperty > iDisplays;
       
   245     CXnProperty* iVisibility;
       
   246     RPointerArray< CXnProperty > iVisibilities;
       
   247     CXnProperty* iLeft;
       
   248     RPointerArray< CXnProperty > iLefts;
       
   249     CXnProperty* iRight;
       
   250     RPointerArray< CXnProperty > iRights;
       
   251     CXnProperty* iTop;
       
   252     RPointerArray< CXnProperty > iTops;
       
   253     CXnProperty* iBottom;
       
   254     RPointerArray< CXnProperty > iBottoms;
       
   255     CXnProperty* iBorderLeftStyle;
       
   256     RPointerArray< CXnProperty > iBorderLeftStyles;
       
   257     CXnProperty* iBorderRightStyle;
       
   258     RPointerArray< CXnProperty > iBorderRightStyles;
       
   259     CXnProperty* iBorderTopStyle;
       
   260     RPointerArray< CXnProperty > iBorderTopStyles;
       
   261     CXnProperty* iBorderBottomStyle;
       
   262     RPointerArray< CXnProperty > iBorderBottomStyles;
       
   263     CXnProperty* iBorderStyle;
       
   264     RPointerArray< CXnProperty > iBorderStyles;
       
   265     CXnProperty* iBorderImage;
       
   266     CXnProperty* iDisplayPriority;
       
   267     RPointerArray< CXnProperty > iDisplayPriorities;
       
   268     CXnProperty* iNavIndex;
       
   269     RPointerArray< CXnProperty > iNavIndexes;
       
   270     CXnProperty* iZIndex;
       
   271     RPointerArray< CXnProperty > iZIndexes;
       
   272     CXnProperty* iBackgroundColor;
       
   273     RPointerArray< CXnProperty > iBackgroundColors;
       
   274     CXnProperty* iBackgroundImage;
       
   275     RPointerArray< CXnProperty > iBackgroundImages;
       
   276     CXnProperty* iFocusBackground;
       
   277     RPointerArray< CXnProperty > iFocusBackgrounds;
       
   278     };
       
   279 
       
   280 // Local function prototypes
       
   281 static TBool IsTriggerRunnableL( CXnDomNode& aTriggerNode );
       
   282 static CXnNode* RefNodeL(
       
   283     CXnNodeImpl* aThis, CXnProperty* aRef, CXnUiEngine* aUiEngine );
       
   284 static const TDesC8* CheckRefAttributeL( CXnProperty* aRef );
       
   285 static TBool DoMatchTriggerForKeyEventL(
       
   286     const TKeyEvent& aKeyEvent,
       
   287     TEventCode aType,
       
   288     CXnDomNode& aTriggerNode );
       
   289 static void GetFocusCandidatesL(
       
   290     CXnNodeImpl* aThis, CXnUiEngine& aEngine, CXnDomNode& aEventNode,
       
   291     RPointerArray< CXnNode >& aFocusCandidates );
       
   292 static void RunAppUiNotificationL( CXnUiEngine& aEngine, CXnNode& aNode,
       
   293     CXnDomNode& aEventNode, CXnDomNode& aTriggerNode, CXnNode& aEventData );
       
   294 static void RunAppExit( CXnUiEngine& aEngine );
       
   295 static void RunFullScreenEffectL(
       
   296     CXnUiEngine& aEngine, CXnDomNode& aEventNode );
       
   297 static void RunActivateViewL(
       
   298     CXnNodeImpl* aThis, CXnUiEngine& aEngine, CXnDomNode& aEventNode );
       
   299 static void RunActivateNextViewL( CXnUiEngine& aEngine );
       
   300 static void RunActivatePreviousViewL( CXnUiEngine& aEngine );
       
   301 static void RunAddViewL( CXnUiEngine& aEngine );
       
   302 static void RunRemoveViewL( CXnUiEngine& aEngine );
       
   303 static void RunActivateL(
       
   304     CXnNodeImpl* aThis, CXnUiEngine& aEngine, CXnDomNode& aEventNode );
       
   305 static void RunDeactivateL(
       
   306     CXnNodeImpl* aThis, CXnUiEngine& aEngine, CXnDomNode& aEventNode );
       
   307 static void RunSystemSetPCDataL(
       
   308     CXnNodeImpl* aThis, CXnUiEngine& aEngine, const TDesC8& aId,
       
   309     const TDesC8& aData );
       
   310 static void GetNumberValues( const TDesC8& aData, TReal& aNumber,
       
   311     CXnDomPropertyValue::TPrimitiveValueType& aValueType );
       
   312 static void RunSystemSetNumberL( CXnUiEngine& aEngine, CXnNode* aNode,
       
   313     const TDesC8& aName, const RPointerArray< HBufC8 >& aValues );
       
   314 static void RunSystemSetRGBL( CXnUiEngine& aEngine, CXnNode* aNode,
       
   315     const TDesC8& aName, const RPointerArray< HBufC8 >& aValues );
       
   316 static void RunSystemSetStringL(
       
   317     CXnUiEngine& aEngine, CXnNode* aNode, const TDesC8& aName,
       
   318     const RPointerArray< HBufC8 >& aValues,
       
   319     const CXnDomPropertyValue::TPrimitiveValueType aValueType );
       
   320 static void GetSystemSetDataL( CXnDomNode& aDomNode, HBufC8*& aId,
       
   321     const TDesC8** aPseudoClass = NULL, const TDesC8** aName = NULL,
       
   322     RPointerArray< HBufC8 >* aValues = NULL, const TDesC8** aType = NULL,
       
   323     TBool aSettings = EFalse, const TDesC8& aProvidedId = KNullDesC8,
       
   324     const TDesC8** aClassId = NULL );
       
   325 static void RunSystemSetL(
       
   326     CXnNodeImpl* aThis, CXnUiEngine& aEngine, CXnDomNode& aEventNode,
       
   327     TBool aSettings = EFalse, const TDesC8& aId = KNullDesC8 );
       
   328 static void RunTryDisplayingMenuL(
       
   329     CXnUiEngine& aEngine, CXnDomNode& aEventNode );
       
   330 static void RunTryDisplayingStylusPopupL(
       
   331     CXnNodeImpl* aThis, CXnNode& aNode, CXnUiEngine& aEngine,
       
   332     CXnDomNode& aEventNode );
       
   333 static void RunTryDisplayingListQueryDialogL(
       
   334     CXnNodeImpl* aThis, CXnUiEngine& aEngine, CXnDomNode& aEventNode );
       
   335 static void RunSetInitialFocusL( CXnUiEngine& aEngine );
       
   336 static void ResolveTriggerDelayL(
       
   337     CXnUiEngine& aEngine, CXnDomNode& aNode, TInt& aDelay );
       
   338 static TBool RunEventL(
       
   339     CXnNodeImpl* aThis, CXnUiEngine& aEngine, CXnNode& aNode,
       
   340     CXnDomNode& aEventNode, CXnDomNode& aTriggerNode, CXnNode& aEventData );
       
   341 static void RunEventsL( CXnNodeImpl* aThis, CXnUiEngine& aEngine, CXnNode& aNode,
       
   342     CXnDomNode& aActionNode, CXnDomNode& aTriggerNode, CXnNode& aEventData );
       
   343 static TBool DoMatchTriggerForHighLevelKeyEventL( CXnNode& aNode,
       
   344     const TKeyEvent& aKeyEvent, TEventCode aType, const TDesC8& highLevelKey );
       
   345 static TBool MatchTriggerForKeyEventL(
       
   346     CXnNodeImpl* aThis, CXnUiEngine& aEngine, CXnNode& aNode,
       
   347     const TKeyEvent& aKeyEvent, TEventCode aType,
       
   348     CXnDomNode& aActionNode, CXnDomNode& aTriggerNode );
       
   349 static TBool MatchTriggerForEventL(
       
   350     CXnNodeImpl* aThis, CXnUiEngine& aEngine, CXnNode& aNode,
       
   351     CXnNode& aEventData, CXnDomNode& aActionNode, CXnDomNode& aTriggerNode,
       
   352     TInt aSource );
       
   353 static TBool MatchActionForKeyEventL(
       
   354     CXnNodeImpl* aThis, CXnUiEngine& aEngine, CXnNode& aNode,
       
   355     const TKeyEvent& aKeyEvent, TEventCode aType, CXnDomNode& aActionNode );
       
   356 static TBool IsTriggerActiveL( CXnDomNode& aNode );
       
   357 static TBool MatchActionForEventL(
       
   358     CXnNodeImpl* aThis, CXnUiEngine& aEngine, CXnNode& aNode,
       
   359     CXnNode& aEventData, CXnDomNode& aActionNode, TInt aSource );
       
   360 static CXnNode* FindLoopedFocusableNodeL( CXnNode& aNode, TBool aForward );
       
   361 static CXnNode* FindNextFocusableNodeByNavIndexL( CXnNode& aNode, TBool aForward );
       
   362 static TBool FindNextFocusableNodeL( CXnNode& aNode, TBool aForward );
       
   363 static CXnNode* FindNextNodeFromRightL(
       
   364     RPointerArray< CXnNode >& aArray, CXnNode& aNode, TBool stayInNamespace = EFalse, CXnUiEngine* aEngine = NULL );
       
   365 static CXnNode* FindNextNodeFromLeftL(
       
   366     RPointerArray< CXnNode >& aArray, CXnNode& aNode, TBool stayInNamespace = EFalse, CXnUiEngine* aEngine = NULL );
       
   367 static CXnNode* FindNextNodeFromBelowL(
       
   368     RPointerArray< CXnNode >& aArray, CXnNode& aNode, TBool stayInNamespace = EFalse );
       
   369 static CXnNode* FindNextNodeFromAboveL(
       
   370     RPointerArray< CXnNode >& aArray, CXnNode& aNode, TBool stayInNamespace = EFalse );
       
   371 static CXnNode* FindPluginNode( CXnNode& aNode );
       
   372 static TBool DoInternalFocusChangeL(
       
   373     CXnUiEngine& aEngine, CXnNode& aNode, const TKeyEvent& aKeyEvent,
       
   374     TEventCode aType );
       
   375 static TBool DoTriggerKeyEventL(
       
   376     CXnNodeImpl* aThis, CXnUiEngine& aEngine, CXnNode& aNode,
       
   377     const TKeyEvent& aKeyEvent, TEventCode aType );
       
   378 static void DoTriggerEventL(
       
   379     CXnNodeImpl* aThis, CXnUiEngine& aEngine, CXnNode& aNode,
       
   380     CXnNode& aActionsParent, CXnNode& aEventData, TInt aSource );
       
   381 static TBool DoReceiveFocusL( CXnNode& aNode, CXnUiEngine& aEngine );
       
   382 static CXnNode* BuildActivateTriggerNodeL( CXnUiEngine& aUiEngine );
       
   383 static void DoSetActiveL( CXnNode& aNode, CXnUiEngine& aUiEngine );
       
   384 static void InformPropertyChangeL( CXnNode& aNode, CXnProperty* aProperty = NULL );
       
   385 static CXnNode* BuildEventTypeNodeL( TEventCode aType, CXnUiEngine& aUiEngine );
       
   386 static CXnNode* BuildModifiersNodeL(
       
   387     const TKeyEvent& aKeyEvent, CXnUiEngine& aUiEngine );
       
   388 static CXnNode* BuildKeyCodeNodeL(
       
   389     const TKeyEvent& aKeyEvent, CXnUiEngine& aUiEngine );
       
   390 static CXnNode* BuildScanCodeNodeL(
       
   391     const TKeyEvent& aKeyEvent, CXnUiEngine& aUiEngine );
       
   392 static CXnNode* BuildRepeatsNodeL(
       
   393     const TKeyEvent& aKeyEvent, CXnUiEngine& aUiEngine );
       
   394 static void BuildPropertyNodesL( CXnNode& aNode, const TKeyEvent& aKeyEvent,
       
   395     TEventCode aType, CXnUiEngine& aUiEngine );
       
   396 static CXnNode* BuildKeyTriggerNodeL( const TKeyEvent& aKeyEvent, TEventCode aType,
       
   397     CXnUiEngine& aUiEngine );
       
   398 static CXnDomPropertyValue* GetNavIndexL( CXnNode& aNode );
       
   399 static CXnNode* BackwardL( CXnNode& aNode );
       
   400 static CXnNode* ForwardL( CXnNode& aNode );
       
   401 static CXnNode* BackwardLoopL( CXnNode& aNode );
       
   402 static CXnNode* ForwardLoopL( CXnNode& aNode );
       
   403 static TInt CompareNavIndexesL(
       
   404     CXnDomPropertyValue* aCurrentPropertyValue,
       
   405     CXnDomPropertyValue* aNextPropertyValue );
       
   406 static void ReplaceOrAppend(
       
   407     CXnProperty* aProperty, RPointerArray< CXnProperty >& aArray,
       
   408     TBool aAppendOnly );
       
   409 static TBool DisplayValueMatchL( CXnNode& aNode, const TDesC8& aDisplayValue );
       
   410 static void SetStringPropertyToNodeL(
       
   411     CXnDomStringPool& aStringPool, CXnNode& aNode,
       
   412     const TDesC8& aPropertyName, const TDesC8& aPropertyValue );
       
   413 static void SetFloatPropertyToNodeL(
       
   414     CXnDomStringPool& aStringPool, CXnNode& aNode,
       
   415     const TDesC8& aPropertyName, TReal aPropertyValue,
       
   416     CXnDomPropertyValue::TPrimitiveValueType aValueType );
       
   417 static CXnNode* FindYoungestSiblingWithDisplayL(
       
   418     RPointerArray< CXnNode >& aSiblingArray,
       
   419     const TDesC8& aDisplayValue,
       
   420     TInt& aIndex );
       
   421 static CXnNode* FindOldestSiblingWithDisplayL(
       
   422     RPointerArray< CXnNode >& aSiblingArray,
       
   423     const TDesC8& aDisplayValue,
       
   424     TInt& aIndex );
       
   425 static TBool IsCompoundNodeL( CXnNode* aNode );
       
   426 static void NotifyScrollNodeL( CXnNode* aNode, TBool aBegin, TBool aGainEnd );
       
   427 static void DoCompoundNodeBeginKeyL(
       
   428     RPointerArray< CXnNode >& aChildren, CXnNode* aFocusedNode );
       
   429 static void DoCompoundNodeEndKeyL(
       
   430     RPointerArray< CXnNode >& aChildren, CXnNode* aFocusedNode );
       
   431 static void DoCompoundNodeScrollingL(
       
   432     CXnNode& aFocusedNode,
       
   433     const TKeyEvent& aKeyEvent,
       
   434     TEventCode aType );
       
   435 static CXnNode* BuildTriggerNodeL(
       
   436     CXnUiEngine& aUiEngine, const TDesC8& aTriggerName );
       
   437 static CXnNode* IsNodeNavigableL( CXnNode* aParent );
       
   438 static TBool IsNodeNavigableL( CXnNode& aNode, TBool aIgnoreDropped = EFalse );
       
   439 static TInt DirtyLevelFromPropertyL( CXnNode& aNode, const TDesC8& aPropName );
       
   440 static TBool IsNodeDisplayedL(
       
   441     CXnNode& aNode, TBool aCheckVisiblity = EFalse, TBool aCheckParent = ETrue );
       
   442 static void EnableStatePropertyL(
       
   443     CXnNode& aNode,
       
   444     CXnDomProperty::TPseudoClass aPseudoClass,
       
   445     CXnProperty* ( CXnNode::* aGetCachedPropertyL )(),
       
   446     CXnProperty*& aProperty,
       
   447     RPointerArray< CXnProperty >& aArray, TInt& aLevel,
       
   448     TBool aInformChange = EFalse );
       
   449 static void DisableStatePropertyL(
       
   450     CXnNode& aNode,
       
   451     CXnDomProperty::TPseudoClass aPseudoClass,
       
   452     CXnProperty* ( CXnNode::* aGetCachedPropertyL )(),
       
   453     CXnProperty*& aProperty,
       
   454     RPointerArray< CXnProperty >& aArray,
       
   455     RArray< CXnDomProperty::TPseudoClass >& aStates, TInt& aLevel,
       
   456     TBool aInformChange = EFalse );
       
   457 static TBool MatchTitleScrollTriggerL(
       
   458     CXnNode& aEventData, CXnDomNode& aTriggerNode );
       
   459 
       
   460 // ============================= LOCAL FUNCTIONS ===============================
       
   461 
       
   462 // -----------------------------------------------------------------------------
       
   463 // Checks whether trigger is runnable
       
   464 // -----------------------------------------------------------------------------
       
   465 //
       
   466 TBool IsTriggerRunnableL( CXnDomNode& aTriggerNode )
       
   467     {
       
   468     TBool ret( ETrue );
       
   469     CXnNode* layoutNode = aTriggerNode.LayoutNode();
       
   470     if ( layoutNode )
       
   471         {
       
   472         CXnProperty* display =
       
   473             layoutNode->GetPropertyL( XnPropertyNames::style::common::KDisplay );
       
   474 
       
   475         if ( display && display->StringValue() ==
       
   476              XnPropertyNames::style::common::display::KNone )
       
   477             {
       
   478             ret = EFalse;
       
   479             }
       
   480         }
       
   481     return ret;
       
   482     }
       
   483 
       
   484 // -----------------------------------------------------------------------------
       
   485 // DirtyLevelFromPropertyL
       
   486 // -----------------------------------------------------------------------------
       
   487 //
       
   488 static TInt DirtyLevelFromPropertyL( CXnNode& aNode, const TDesC8& aPropName )
       
   489     {
       
   490     if ( aPropName == XnPropertyNames::style::common::KDisplay ||
       
   491         aPropName == XnPropertyNames::style::common::KBlockProgression ||
       
   492         aPropName == XnPropertyNames::style::common::KDirection ||
       
   493         aPropName == XnPropertyNames::style::common::KPosition ||
       
   494         aPropName == XnPropertyNames::style::common::KTop ||
       
   495         aPropName == XnPropertyNames::style::common::KLeft ||
       
   496         aPropName == XnPropertyNames::style::common::KBottom ||
       
   497         aPropName == XnPropertyNames::style::common::KRight ||
       
   498         aPropName == XnPropertyNames::style::common::KWidth ||
       
   499         aPropName == XnPropertyNames::style::common::KHeight ||
       
   500         aPropName == XnPropertyNames::style::common::KMinWidth ||
       
   501         aPropName == XnPropertyNames::style::common::KMaxWidth ||
       
   502         aPropName == XnPropertyNames::style::common::KMinHeight ||
       
   503         aPropName == XnPropertyNames::style::common::KMaxHeight ||
       
   504         aPropName == XnPropertyNames::style::common::KS60DisplayPriority ||
       
   505         aPropName == XnPropertyNames::style::common::KMarginTop ||
       
   506         aPropName == XnPropertyNames::style::common::KMarginRight ||
       
   507         aPropName == XnPropertyNames::style::common::KMarginBottom ||
       
   508         aPropName == XnPropertyNames::style::common::KMarginLeft ||
       
   509         aPropName == XnPropertyNames::style::common::KBorderWidth ||
       
   510         aPropName == XnPropertyNames::style::common::KBorderTopWidth ||
       
   511         aPropName == XnPropertyNames::style::common::KBorderRightWidth ||
       
   512         aPropName == XnPropertyNames::style::common::KBorderBottomWidth ||
       
   513         aPropName == XnPropertyNames::style::common::KBorderLeftWidth ||
       
   514         aPropName == XnPropertyNames::style::common::KBorderLeftWidth ||
       
   515         aPropName == XnPropertyNames::style::common::KPaddingRight ||
       
   516         aPropName == XnPropertyNames::style::common::KPaddingBottom ||
       
   517         aPropName == XnPropertyNames::style::common::KPaddingLeft )
       
   518         {
       
   519         TInt retval( XnDirtyLevel::ELayoutAndRenderSiblings );
       
   520 
       
   521         CXnProperty* prop( aNode.PositionL() );
       
   522 
       
   523         if ( prop )
       
   524             {
       
   525             const TDesC8& value( prop->StringValue() );
       
   526 
       
   527             if ( value == XnPropertyNames::style::common::position::KAbsolute ||
       
   528                  value == XnPropertyNames::style::common::position::KFloating )
       
   529                 {
       
   530                 retval = XnDirtyLevel::ELayoutAndRender;
       
   531                 }
       
   532             }
       
   533 
       
   534         if ( aNode.Type()->Type() == KToolTip )
       
   535             {
       
   536             retval = XnDirtyLevel::ELayoutAndRender;
       
   537             }
       
   538 
       
   539         return retval;
       
   540         }
       
   541     else
       
   542         {
       
   543         return XnDirtyLevel::ERender;
       
   544         }
       
   545     }
       
   546 
       
   547 // -----------------------------------------------------------------------------
       
   548 // IsNodeDisplayedL
       
   549 // Check whether a node is displayed or not
       
   550 // -----------------------------------------------------------------------------
       
   551 //
       
   552 static TBool IsNodeDisplayedL(
       
   553     CXnNode& aNode,
       
   554     TBool aCheckVisiblity,
       
   555     TBool aCheckParent )
       
   556     {
       
   557     if ( !aNode.IsLayoutCapable() )
       
   558         {
       
   559         return EFalse;
       
   560         }
       
   561 
       
   562     if ( aCheckVisiblity )
       
   563         {
       
   564         CXnProperty* visibilityProp( aNode.VisibilityL() );
       
   565 
       
   566         // Am I visible?
       
   567         if ( visibilityProp )
       
   568             {
       
   569             const TDesC8& visibility( visibilityProp->StringValue() );
       
   570 
       
   571             if ( visibility != XnPropertyNames::style::common::visibility::KVisible )
       
   572                 {
       
   573                 return EFalse;
       
   574                 }
       
   575             }
       
   576         }
       
   577 
       
   578     // Am I displayed?
       
   579     CXnProperty* displayProp( aNode.DisplayL() );
       
   580 
       
   581     if ( displayProp )
       
   582         {
       
   583         const TDesC8& display( displayProp->StringValue() );
       
   584 
       
   585         if ( display != XnPropertyNames::style::common::display::KBlock )
       
   586             {
       
   587             return EFalse;
       
   588             }
       
   589         }
       
   590 
       
   591     if ( aCheckParent )
       
   592         {
       
   593         CXnNode* parent( aNode.Parent() );
       
   594 
       
   595         // Is my parent displayed?
       
   596         for ( ; parent; parent = parent->Parent() )
       
   597             {
       
   598             CXnProperty* displayProp( parent->DisplayL() );
       
   599 
       
   600             if ( displayProp )
       
   601                 {
       
   602                 const TDesC8& display( displayProp->StringValue() );
       
   603 
       
   604                 if ( display != XnPropertyNames::style::common::display::KBlock )
       
   605                     {
       
   606                     return EFalse;
       
   607                     }
       
   608                 }
       
   609             }
       
   610         }
       
   611 
       
   612     return ETrue;
       
   613     }
       
   614 
       
   615 // -----------------------------------------------------------------------------
       
   616 // IsNodeNavigableL
       
   617 // Check whether a node or its child is navigable, ignores dropped state
       
   618 // -----------------------------------------------------------------------------
       
   619 //
       
   620 static CXnNode* IsNodeNavigableL( CXnNode* aParent )
       
   621     {
       
   622     if ( IsNodeNavigableL( *aParent, ETrue ) )
       
   623         {
       
   624         return aParent;
       
   625         }
       
   626 
       
   627     RPointerArray< CXnNode >& children( aParent->Children() );
       
   628 
       
   629     TInt count( children.Count() );
       
   630 
       
   631     CXnNode* retval = NULL;
       
   632     for ( TInt i = 0; i < count; i++ )
       
   633         {
       
   634         retval = IsNodeNavigableL( children[i] );
       
   635         if ( retval )
       
   636             {
       
   637             return retval;
       
   638             }
       
   639         }
       
   640 
       
   641     return NULL;
       
   642     }
       
   643 
       
   644 // -----------------------------------------------------------------------------
       
   645 // IsNodeNavigableL()
       
   646 // Check if node can be navigated
       
   647 // -----------------------------------------------------------------------------
       
   648 //
       
   649 static TBool IsNodeNavigableL( CXnNode& aNode, TBool aIgnoreDropped )
       
   650     {
       
   651     if ( !aNode.IsLayoutCapable() || ( !aIgnoreDropped && aNode.IsDropped() ) )
       
   652         {
       
   653         return EFalse;
       
   654         }
       
   655 
       
   656     CXnProperty* displayProp( aNode.DisplayL() );
       
   657 
       
   658     if ( displayProp )
       
   659         {
       
   660         const TDesC8& display( displayProp->StringValue() );
       
   661 
       
   662         if ( display != XnPropertyNames::style::common::display::KBlock )
       
   663             {
       
   664             return EFalse;
       
   665             }
       
   666         }
       
   667 
       
   668     CXnProperty* visibilityProp( aNode.VisibilityL() );
       
   669 
       
   670     if ( visibilityProp )
       
   671         {
       
   672         const TDesC8& visibility( visibilityProp->StringValue() );
       
   673 
       
   674         if ( visibility != XnPropertyNames::style::common::visibility::KVisible )
       
   675             {
       
   676             return EFalse;
       
   677             }
       
   678         }
       
   679 
       
   680     CXnProperty* focusableProp(
       
   681         aNode.GetPropertyL( XnPropertyNames::common::KFocusable ) );
       
   682 
       
   683     if ( focusableProp )
       
   684         {
       
   685         const TDesC8& focus( focusableProp->StringValue() );
       
   686 
       
   687         if ( focus != XnPropertyNames::KTrue )
       
   688             {
       
   689             return EFalse;
       
   690             }
       
   691         }
       
   692     else
       
   693         {
       
   694         return EFalse;
       
   695         }
       
   696     CXnProperty* disabledProp(
       
   697         aNode.GetPropertyL( XnPropertyNames::common::KDisabled ) );
       
   698 
       
   699     if ( disabledProp )
       
   700         {
       
   701         const TDesC8& disabled( disabledProp->StringValue() );
       
   702 
       
   703         if ( disabled == XnPropertyNames::KTrue )
       
   704             {
       
   705             return EFalse;
       
   706             }
       
   707         }
       
   708 
       
   709     // The node can be navigated. Then check parents display and visibilty properties
       
   710     CXnNode* parent( aNode.Parent() );
       
   711 
       
   712     for ( ; parent; parent = parent->Parent() )
       
   713         {
       
   714         CXnProperty* displayProp( parent->DisplayL() );
       
   715 
       
   716         if ( displayProp )
       
   717             {
       
   718             const TDesC8& display( displayProp->StringValue() );
       
   719 
       
   720             if ( display != XnPropertyNames::style::common::display::KBlock )
       
   721                 {
       
   722                 return EFalse;
       
   723                 }
       
   724             }
       
   725 
       
   726         CXnProperty* visibilityProp( parent->VisibilityL() );
       
   727 
       
   728         if ( visibilityProp )
       
   729             {
       
   730             const TDesC8& visibility( visibilityProp->StringValue() );
       
   731 
       
   732             if ( visibility != XnPropertyNames::style::common::visibility::KVisible )
       
   733                 {
       
   734                 return EFalse;
       
   735                 }
       
   736             }
       
   737         }
       
   738 
       
   739     return ETrue;
       
   740     }
       
   741 
       
   742 // -----------------------------------------------------------------------------
       
   743 // EnableStatePropertyL()
       
   744 // -----------------------------------------------------------------------------
       
   745 //
       
   746 static void EnableStatePropertyL(
       
   747     CXnNode& aNode,
       
   748     CXnDomProperty::TPseudoClass aPseudoClass,
       
   749     CXnProperty* ( CXnNode::* aGetCachedPropertyL )(),
       
   750     CXnProperty*& aProperty,
       
   751     RPointerArray< CXnProperty >& aArray, TInt& aLevel,
       
   752     TBool aInformChange )
       
   753     {
       
   754     TBool doInform( EFalse );
       
   755 
       
   756     for ( TInt i = aArray.Count() - 1; i >= 0; --i )
       
   757         {
       
   758         if ( aArray[i]->Property()->PseudoClass() == aPseudoClass )
       
   759             {
       
   760             CXnProperty* temp( aArray[i] );
       
   761 
       
   762             if ( aLevel < XnDirtyLevel::ELayoutAndRenderSiblings ||
       
   763                  aInformChange )
       
   764                 {
       
   765                 TInt level( XnDirtyLevel::ENone );
       
   766 
       
   767                 // Get current cached prop
       
   768                 CXnProperty* prop( ( aNode.*aGetCachedPropertyL )() );
       
   769 
       
   770                 if ( !temp && prop )
       
   771                     {
       
   772                     level = DirtyLevelFromPropertyL(
       
   773                         aNode, prop->Property()->Name() );
       
   774                     }
       
   775                 else if ( ( temp && !prop ) ||
       
   776                           ( temp && prop && !prop->EqualsL( *temp ) ) )
       
   777                     {
       
   778                     level = DirtyLevelFromPropertyL(
       
   779                         aNode, temp->Property()->Name() );
       
   780                     }
       
   781 
       
   782                 if ( aInformChange && ( level != XnDirtyLevel::ENone ) )
       
   783                     {
       
   784                     doInform = ETrue;
       
   785                     }
       
   786 
       
   787                 if ( level > aLevel && aNode.IsLayoutCapable())
       
   788                     {
       
   789                     aLevel = level;
       
   790                     }
       
   791                 }
       
   792 
       
   793             aProperty = temp;
       
   794 
       
   795             if ( doInform )
       
   796                 {
       
   797                 // Property is changed
       
   798                 InformPropertyChangeL( aNode, temp );
       
   799                 }
       
   800 
       
   801             break;
       
   802             }
       
   803         }
       
   804     }
       
   805 
       
   806 // -----------------------------------------------------------------------------
       
   807 // DisableStatePropertyL()
       
   808 // -----------------------------------------------------------------------------
       
   809 //
       
   810 static void DisableStatePropertyL(
       
   811     CXnNode& aNode,
       
   812     CXnDomProperty::TPseudoClass aPseudoClass,
       
   813     CXnProperty* ( CXnNode::* aGetCachedPropertyL )(),
       
   814     CXnProperty*& aProperty,
       
   815     RPointerArray< CXnProperty >& aArray,
       
   816     RArray< CXnDomProperty::TPseudoClass >& aStates, TInt& aLevel,
       
   817     TBool aInformChange )
       
   818     {
       
   819     CXnProperty* currentStateProperty( NULL );
       
   820 
       
   821     TBool doInform( EFalse );
       
   822 
       
   823     if ( aProperty && aProperty->Property()->PseudoClass() == aPseudoClass )
       
   824         {
       
   825         // Is there an other pseudo state where to return?
       
   826         for ( TInt i = aArray.Count() - 1; !currentStateProperty && i >= 0; --i )
       
   827             {
       
   828             for ( TInt j = aStates.Count() - 1; j >= 0; --j )
       
   829                 {
       
   830                 if ( aArray[i]->Property()->PseudoClass() == aStates[j] &&
       
   831                      aArray[i]->Property()->PseudoClass() != aPseudoClass )
       
   832                     {
       
   833                     currentStateProperty = aArray[i];
       
   834                     break;
       
   835                     }
       
   836                 }
       
   837             }
       
   838 
       
   839         // No, use the property from state "none"
       
   840         for ( TInt i = aArray.Count() - 1; !currentStateProperty && i >= 0; --i )
       
   841             {
       
   842             for ( TInt j = aStates.Count() - 1; j >= 0; --j )
       
   843                 {
       
   844                 if ( aArray[i]->Property()->PseudoClass() == CXnDomProperty::ENone &&
       
   845                      aArray[i]->Property()->PseudoClass() != aPseudoClass )
       
   846                     {
       
   847                     currentStateProperty = aArray[i];
       
   848                     break;
       
   849                     }
       
   850                 }
       
   851             }
       
   852 
       
   853         CXnProperty* temp( currentStateProperty );
       
   854 
       
   855         if ( aLevel < XnDirtyLevel::ELayoutAndRenderSiblings || aInformChange )
       
   856             {
       
   857             TInt level( XnDirtyLevel::ENone );
       
   858 
       
   859             // Get current cached prop
       
   860             CXnProperty* prop( ( aNode.*aGetCachedPropertyL )() );
       
   861 
       
   862             if ( !temp && prop )
       
   863                 {
       
   864                 level = DirtyLevelFromPropertyL( aNode, prop->Property()->Name() );
       
   865                 }
       
   866             else if ( ( temp && !prop ) || ( temp && prop && !prop->EqualsL( *temp ) ) )
       
   867                 {
       
   868                 level = DirtyLevelFromPropertyL( aNode, temp->Property()->Name() );
       
   869                 }
       
   870 
       
   871             if ( aInformChange && ( level != XnDirtyLevel::ENone ) )
       
   872                 {
       
   873                 doInform = ETrue;
       
   874                 }
       
   875 
       
   876             if ( level > aLevel && aNode.IsLayoutCapable())
       
   877                 {
       
   878                 aLevel = level;
       
   879                 }
       
   880             }
       
   881 
       
   882         aProperty = temp;
       
   883 
       
   884         if ( doInform )
       
   885             {
       
   886             // Property is changed
       
   887             InformPropertyChangeL( aNode, temp );
       
   888             }
       
   889         }
       
   890     }
       
   891 
       
   892 // -----------------------------------------------------------------------------
       
   893 // EnableStatePropertiesL()
       
   894 // -----------------------------------------------------------------------------
       
   895 //
       
   896 static void EnableStatePropertiesL(
       
   897     CXnNode& aNode,
       
   898     CXnDomProperty::TPseudoClass aPseudoClass,
       
   899     CLayoutPropertyCache*& aLayoutPropertyCache )
       
   900     {
       
   901     if ( !aLayoutPropertyCache )
       
   902         {
       
   903         aLayoutPropertyCache = new ( ELeave ) CLayoutPropertyCache;
       
   904         }
       
   905 
       
   906     TInt level( XnDirtyLevel::ENone );
       
   907 
       
   908     EnableStatePropertyL(
       
   909         aNode, aPseudoClass, CXnNode::WidthL,
       
   910         aLayoutPropertyCache->iWidth,
       
   911         aLayoutPropertyCache->iWidths, level );
       
   912 
       
   913     EnableStatePropertyL(
       
   914         aNode, aPseudoClass, CXnNode::HeightL,
       
   915         aLayoutPropertyCache->iHeight,
       
   916         aLayoutPropertyCache->iHeights, level );
       
   917 
       
   918     EnableStatePropertyL(
       
   919         aNode, aPseudoClass, CXnNode::MarginLeftL,
       
   920         aLayoutPropertyCache->iMarginLeft,
       
   921         aLayoutPropertyCache->iMarginLefts, level );
       
   922 
       
   923     EnableStatePropertyL(
       
   924         aNode, aPseudoClass, CXnNode::MarginRightL,
       
   925         aLayoutPropertyCache->iMarginRight,
       
   926         aLayoutPropertyCache->iMarginRights, level );
       
   927 
       
   928     EnableStatePropertyL(
       
   929         aNode, aPseudoClass, CXnNode::BorderLeftL,
       
   930         aLayoutPropertyCache->iBorderLeft,
       
   931         aLayoutPropertyCache->iBorderLefts, level );
       
   932 
       
   933     EnableStatePropertyL(
       
   934         aNode, aPseudoClass, CXnNode::BorderRightL,
       
   935         aLayoutPropertyCache->iBorderRight,
       
   936         aLayoutPropertyCache->iBorderRights, level );
       
   937 
       
   938     EnableStatePropertyL(
       
   939         aNode, aPseudoClass, CXnNode::PaddingLeftL,
       
   940         aLayoutPropertyCache->iPaddingLeft,
       
   941         aLayoutPropertyCache->iPaddingLefts, level );
       
   942 
       
   943     EnableStatePropertyL(
       
   944         aNode, aPseudoClass, CXnNode::PaddingRightL,
       
   945         aLayoutPropertyCache->iPaddingRight,
       
   946         aLayoutPropertyCache->iPaddingRights, level );
       
   947 
       
   948     EnableStatePropertyL(
       
   949         aNode, aPseudoClass, CXnNode::MarginTopL,
       
   950         aLayoutPropertyCache->iMarginTop,
       
   951         aLayoutPropertyCache->iMarginTops, level );
       
   952 
       
   953     EnableStatePropertyL(
       
   954         aNode, aPseudoClass, CXnNode::MarginBottomL,
       
   955         aLayoutPropertyCache->iMarginBottom,
       
   956         aLayoutPropertyCache->iMarginBottoms, level );
       
   957 
       
   958     EnableStatePropertyL(
       
   959         aNode, aPseudoClass, CXnNode::BorderTopL,
       
   960         aLayoutPropertyCache->iBorderTop,
       
   961         aLayoutPropertyCache->iBorderTops, level );
       
   962 
       
   963     EnableStatePropertyL(
       
   964         aNode, aPseudoClass, CXnNode::BorderBottomL,
       
   965         aLayoutPropertyCache->iBorderBottom,
       
   966         aLayoutPropertyCache->iBorderBottoms, level );
       
   967 
       
   968     EnableStatePropertyL(
       
   969         aNode, aPseudoClass, CXnNode::PaddingTopL,
       
   970         aLayoutPropertyCache->iPaddingTop,
       
   971         aLayoutPropertyCache->iPaddingTops, level );
       
   972 
       
   973     EnableStatePropertyL(
       
   974         aNode, aPseudoClass, CXnNode::PaddingBottomL,
       
   975         aLayoutPropertyCache->iPaddingBottom,
       
   976         aLayoutPropertyCache->iPaddingBottoms, level );
       
   977 
       
   978     EnableStatePropertyL(
       
   979         aNode, aPseudoClass, CXnNode::BorderWidthL,
       
   980         aLayoutPropertyCache->iBorderWidth,
       
   981         aLayoutPropertyCache->iBorderWidths, level );
       
   982 
       
   983     EnableStatePropertyL(
       
   984         aNode, aPseudoClass, CXnNode::BlockProgressionL,
       
   985         aLayoutPropertyCache->iBlockProgression,
       
   986         aLayoutPropertyCache->iBlockProgressions, level );
       
   987 
       
   988     EnableStatePropertyL(
       
   989         aNode, aPseudoClass, CXnNode::DirectionL,
       
   990         aLayoutPropertyCache->iDirection,
       
   991         aLayoutPropertyCache->iDirections, level );
       
   992 
       
   993     EnableStatePropertyL(
       
   994         aNode, aPseudoClass, CXnNode::PositionL,
       
   995         aLayoutPropertyCache->iPosition,
       
   996         aLayoutPropertyCache->iPositions, level );
       
   997 
       
   998     EnableStatePropertyL(
       
   999         aNode, aPseudoClass, CXnNode::MaxHeightL,
       
  1000         aLayoutPropertyCache->iMaxHeight,
       
  1001         aLayoutPropertyCache->iMaxHeights, level );
       
  1002 
       
  1003     EnableStatePropertyL(
       
  1004         aNode, aPseudoClass, CXnNode::MinHeightL,
       
  1005         aLayoutPropertyCache->iMinHeight,
       
  1006         aLayoutPropertyCache->iMinHeights, level );
       
  1007 
       
  1008     EnableStatePropertyL(
       
  1009         aNode, aPseudoClass, CXnNode::MaxWidthL,
       
  1010         aLayoutPropertyCache->iMaxWidth,
       
  1011         aLayoutPropertyCache->iMaxWidths, level );
       
  1012 
       
  1013     EnableStatePropertyL(
       
  1014         aNode, aPseudoClass, CXnNode::MinWidthL,
       
  1015         aLayoutPropertyCache->iMinWidth,
       
  1016         aLayoutPropertyCache->iMinWidths, level );
       
  1017 
       
  1018     EnableStatePropertyL(
       
  1019         aNode, aPseudoClass, CXnNode::DisplayL,
       
  1020         aLayoutPropertyCache->iDisplay,
       
  1021         aLayoutPropertyCache->iDisplays, level, ETrue );
       
  1022 
       
  1023     EnableStatePropertyL(
       
  1024         aNode, aPseudoClass, CXnNode::VisibilityL,
       
  1025         aLayoutPropertyCache->iVisibility,
       
  1026         aLayoutPropertyCache->iVisibilities, level );
       
  1027 
       
  1028     EnableStatePropertyL(
       
  1029         aNode, aPseudoClass, CXnNode::LeftL,
       
  1030         aLayoutPropertyCache->iLeft,
       
  1031         aLayoutPropertyCache->iLefts, level );
       
  1032 
       
  1033     EnableStatePropertyL(
       
  1034         aNode, aPseudoClass, CXnNode::RightL,
       
  1035         aLayoutPropertyCache->iRight,
       
  1036         aLayoutPropertyCache->iRights, level );
       
  1037 
       
  1038     EnableStatePropertyL(
       
  1039         aNode, aPseudoClass, CXnNode::TopL,
       
  1040         aLayoutPropertyCache->iTop,
       
  1041         aLayoutPropertyCache->iTops, level );
       
  1042 
       
  1043     EnableStatePropertyL(
       
  1044         aNode, aPseudoClass, CXnNode::BottomL,
       
  1045         aLayoutPropertyCache->iBottom,
       
  1046         aLayoutPropertyCache->iBottoms, level );
       
  1047 
       
  1048     EnableStatePropertyL(
       
  1049         aNode, aPseudoClass, CXnNode::BorderLeftStyleL,
       
  1050         aLayoutPropertyCache->iBorderLeftStyle,
       
  1051         aLayoutPropertyCache->iBorderLeftStyles, level );
       
  1052 
       
  1053     EnableStatePropertyL(
       
  1054         aNode, aPseudoClass, CXnNode::BorderRightStyleL,
       
  1055         aLayoutPropertyCache->iBorderRightStyle,
       
  1056         aLayoutPropertyCache->iBorderRightStyles, level );
       
  1057 
       
  1058     EnableStatePropertyL(
       
  1059         aNode, aPseudoClass, CXnNode::BorderTopStyleL,
       
  1060         aLayoutPropertyCache->iBorderTopStyle,
       
  1061         aLayoutPropertyCache->iBorderTopStyles, level );
       
  1062 
       
  1063     EnableStatePropertyL(
       
  1064         aNode, aPseudoClass, CXnNode::BorderBottomStyleL,
       
  1065         aLayoutPropertyCache->iBorderBottomStyle,
       
  1066         aLayoutPropertyCache->iBorderBottomStyles, level );
       
  1067 
       
  1068     EnableStatePropertyL(
       
  1069         aNode, aPseudoClass, CXnNode::BorderStyleL,
       
  1070         aLayoutPropertyCache->iBorderStyle,
       
  1071         aLayoutPropertyCache->iBorderStyles, level );
       
  1072 
       
  1073     EnableStatePropertyL(
       
  1074         aNode, aPseudoClass, CXnNode::DisplayPriorityL,
       
  1075         aLayoutPropertyCache->iDisplayPriority,
       
  1076         aLayoutPropertyCache->iDisplayPriorities, level );
       
  1077 
       
  1078     EnableStatePropertyL(
       
  1079         aNode, aPseudoClass, CXnNode::NavIndexL,
       
  1080         aLayoutPropertyCache->iNavIndex,
       
  1081         aLayoutPropertyCache->iNavIndexes, level );
       
  1082 
       
  1083     EnableStatePropertyL(
       
  1084         aNode, aPseudoClass, CXnNode::ZIndexL,
       
  1085         aLayoutPropertyCache->iZIndex,
       
  1086         aLayoutPropertyCache->iZIndexes, level );
       
  1087 
       
  1088     EnableStatePropertyL(
       
  1089         aNode, aPseudoClass, CXnNode::BackgroundColorL,
       
  1090         aLayoutPropertyCache->iBackgroundColor,
       
  1091         aLayoutPropertyCache->iBackgroundColors, level );
       
  1092 
       
  1093     EnableStatePropertyL(
       
  1094         aNode, aPseudoClass, CXnNode::BackgroundImageL,
       
  1095         aLayoutPropertyCache->iBackgroundImage,
       
  1096         aLayoutPropertyCache->iBackgroundImages, level, ETrue );
       
  1097 
       
  1098     EnableStatePropertyL(
       
  1099         aNode, aPseudoClass, CXnNode::FocusBackgroundL,
       
  1100         aLayoutPropertyCache->iFocusBackground,
       
  1101         aLayoutPropertyCache->iFocusBackgrounds, level );
       
  1102 
       
  1103     aNode.SetDirtyL( level );
       
  1104     }
       
  1105 
       
  1106 // -----------------------------------------------------------------------------
       
  1107 // DisableStatePropertiesL()
       
  1108 // -----------------------------------------------------------------------------
       
  1109 //
       
  1110 static void DisableStatePropertiesL(
       
  1111     CXnNode& aNode,
       
  1112     CXnDomProperty::TPseudoClass aPseudoClass,
       
  1113     RArray< CXnDomProperty::TPseudoClass >& aStates,
       
  1114     CLayoutPropertyCache*& aLayoutPropertyCache )
       
  1115     {
       
  1116     if ( !aLayoutPropertyCache )
       
  1117         {
       
  1118         aLayoutPropertyCache = new ( ELeave ) CLayoutPropertyCache;
       
  1119         }
       
  1120 
       
  1121     TInt level( XnDirtyLevel::ENone );
       
  1122 
       
  1123     DisableStatePropertyL(
       
  1124         aNode, aPseudoClass, CXnNode::WidthL,
       
  1125         aLayoutPropertyCache->iWidth,
       
  1126         aLayoutPropertyCache->iWidths, aStates, level );
       
  1127 
       
  1128     DisableStatePropertyL(
       
  1129         aNode, aPseudoClass, CXnNode::HeightL,
       
  1130         aLayoutPropertyCache->iHeight,
       
  1131         aLayoutPropertyCache->iHeights, aStates, level );
       
  1132 
       
  1133     DisableStatePropertyL(
       
  1134         aNode, aPseudoClass, CXnNode::MarginLeftL,
       
  1135         aLayoutPropertyCache->iMarginLeft,
       
  1136         aLayoutPropertyCache->iMarginLefts, aStates, level );
       
  1137 
       
  1138     DisableStatePropertyL(
       
  1139         aNode, aPseudoClass, CXnNode::MarginRightL,
       
  1140         aLayoutPropertyCache->iMarginRight,
       
  1141         aLayoutPropertyCache->iMarginRights, aStates, level );
       
  1142 
       
  1143     DisableStatePropertyL(
       
  1144         aNode, aPseudoClass, CXnNode::BorderLeftL,
       
  1145         aLayoutPropertyCache->iBorderLeft,
       
  1146         aLayoutPropertyCache->iBorderLefts, aStates, level );
       
  1147 
       
  1148     DisableStatePropertyL(
       
  1149         aNode, aPseudoClass, CXnNode::BorderRightL,
       
  1150         aLayoutPropertyCache->iBorderRight,
       
  1151         aLayoutPropertyCache->iBorderRights, aStates, level );
       
  1152 
       
  1153     DisableStatePropertyL(
       
  1154         aNode, aPseudoClass, CXnNode::PaddingLeftL,
       
  1155         aLayoutPropertyCache->iPaddingLeft,
       
  1156         aLayoutPropertyCache->iPaddingLefts, aStates, level );
       
  1157 
       
  1158     DisableStatePropertyL(
       
  1159         aNode, aPseudoClass, CXnNode::PaddingRightL,
       
  1160         aLayoutPropertyCache->iPaddingRight,
       
  1161         aLayoutPropertyCache->iPaddingRights, aStates, level );
       
  1162 
       
  1163     DisableStatePropertyL(
       
  1164         aNode, aPseudoClass, CXnNode::MarginTopL,
       
  1165         aLayoutPropertyCache->iMarginTop,
       
  1166         aLayoutPropertyCache->iMarginTops, aStates, level );
       
  1167 
       
  1168     DisableStatePropertyL(
       
  1169         aNode, aPseudoClass, CXnNode::MarginBottomL,
       
  1170         aLayoutPropertyCache->iMarginBottom,
       
  1171         aLayoutPropertyCache->iMarginBottoms, aStates, level );
       
  1172 
       
  1173     DisableStatePropertyL(
       
  1174         aNode, aPseudoClass, CXnNode::BorderTopL,
       
  1175         aLayoutPropertyCache->iBorderTop,
       
  1176         aLayoutPropertyCache->iBorderTops, aStates, level );
       
  1177 
       
  1178     DisableStatePropertyL(
       
  1179         aNode, aPseudoClass, CXnNode::BorderBottomL,
       
  1180         aLayoutPropertyCache->iBorderBottom,
       
  1181         aLayoutPropertyCache->iBorderBottoms, aStates, level );
       
  1182 
       
  1183     DisableStatePropertyL(
       
  1184         aNode, aPseudoClass, CXnNode::PaddingTopL,
       
  1185         aLayoutPropertyCache->iPaddingTop,
       
  1186         aLayoutPropertyCache->iPaddingTops, aStates, level );
       
  1187 
       
  1188     DisableStatePropertyL(
       
  1189         aNode, aPseudoClass, CXnNode::PaddingBottomL,
       
  1190         aLayoutPropertyCache->iPaddingBottom,
       
  1191         aLayoutPropertyCache->iPaddingBottoms, aStates, level );
       
  1192 
       
  1193     DisableStatePropertyL(
       
  1194         aNode, aPseudoClass, CXnNode::BorderWidthL,
       
  1195         aLayoutPropertyCache->iBorderWidth,
       
  1196         aLayoutPropertyCache->iBorderWidths, aStates, level );
       
  1197 
       
  1198     DisableStatePropertyL(
       
  1199         aNode, aPseudoClass, CXnNode::BlockProgressionL,
       
  1200         aLayoutPropertyCache->iBlockProgression,
       
  1201         aLayoutPropertyCache->iBlockProgressions, aStates, level );
       
  1202 
       
  1203     DisableStatePropertyL(
       
  1204         aNode, aPseudoClass, CXnNode::DirectionL,
       
  1205         aLayoutPropertyCache->iDirection,
       
  1206         aLayoutPropertyCache->iDirections, aStates, level );
       
  1207 
       
  1208     DisableStatePropertyL(
       
  1209         aNode, aPseudoClass, CXnNode::PositionL,
       
  1210         aLayoutPropertyCache->iPosition,
       
  1211         aLayoutPropertyCache->iPositions, aStates, level );
       
  1212 
       
  1213     DisableStatePropertyL(
       
  1214         aNode, aPseudoClass, CXnNode::MaxHeightL,
       
  1215         aLayoutPropertyCache->iMaxHeight,
       
  1216         aLayoutPropertyCache->iMaxHeights, aStates, level );
       
  1217 
       
  1218     DisableStatePropertyL(
       
  1219         aNode, aPseudoClass, CXnNode::MinHeightL,
       
  1220         aLayoutPropertyCache->iMinHeight,
       
  1221         aLayoutPropertyCache->iMinHeights, aStates, level );
       
  1222 
       
  1223     DisableStatePropertyL(
       
  1224         aNode, aPseudoClass, CXnNode::MaxWidthL,
       
  1225         aLayoutPropertyCache->iMaxWidth,
       
  1226         aLayoutPropertyCache->iMaxWidths, aStates, level );
       
  1227 
       
  1228     DisableStatePropertyL(
       
  1229         aNode, aPseudoClass, CXnNode::MinWidthL,
       
  1230         aLayoutPropertyCache->iMinWidth,
       
  1231         aLayoutPropertyCache->iMinWidths, aStates, level );
       
  1232 
       
  1233     DisableStatePropertyL(
       
  1234         aNode, aPseudoClass, CXnNode::DisplayL,
       
  1235         aLayoutPropertyCache->iDisplay,
       
  1236         aLayoutPropertyCache->iDisplays, aStates, level, ETrue );
       
  1237 
       
  1238     DisableStatePropertyL(
       
  1239         aNode, aPseudoClass, CXnNode::VisibilityL,
       
  1240         aLayoutPropertyCache->iVisibility,
       
  1241         aLayoutPropertyCache->iVisibilities, aStates, level );
       
  1242 
       
  1243     DisableStatePropertyL(
       
  1244         aNode, aPseudoClass, CXnNode::LeftL,
       
  1245         aLayoutPropertyCache->iLeft,
       
  1246         aLayoutPropertyCache->iLefts, aStates, level );
       
  1247 
       
  1248     DisableStatePropertyL(
       
  1249         aNode, aPseudoClass, CXnNode::RightL,
       
  1250         aLayoutPropertyCache->iRight,
       
  1251         aLayoutPropertyCache->iRights, aStates, level );
       
  1252 
       
  1253     DisableStatePropertyL(
       
  1254         aNode, aPseudoClass, CXnNode::TopL,
       
  1255         aLayoutPropertyCache->iTop,
       
  1256         aLayoutPropertyCache->iTops, aStates, level );
       
  1257 
       
  1258     DisableStatePropertyL(
       
  1259         aNode, aPseudoClass, CXnNode::BottomL,
       
  1260         aLayoutPropertyCache->iBottom,
       
  1261         aLayoutPropertyCache->iBottoms, aStates, level );
       
  1262 
       
  1263     DisableStatePropertyL(
       
  1264         aNode, aPseudoClass, CXnNode::BorderLeftStyleL,
       
  1265         aLayoutPropertyCache->iBorderLeftStyle,
       
  1266         aLayoutPropertyCache->iBorderLeftStyles, aStates, level );
       
  1267 
       
  1268     DisableStatePropertyL(
       
  1269         aNode, aPseudoClass, CXnNode::BorderRightStyleL,
       
  1270         aLayoutPropertyCache->iBorderRightStyle,
       
  1271         aLayoutPropertyCache->iBorderRightStyles, aStates, level );
       
  1272 
       
  1273     DisableStatePropertyL(
       
  1274         aNode, aPseudoClass, CXnNode::BorderTopStyleL,
       
  1275         aLayoutPropertyCache->iBorderTopStyle,
       
  1276         aLayoutPropertyCache->iBorderTopStyles, aStates, level );
       
  1277 
       
  1278     DisableStatePropertyL(
       
  1279         aNode, aPseudoClass, CXnNode::BorderBottomStyleL,
       
  1280         aLayoutPropertyCache->iBorderBottomStyle,
       
  1281         aLayoutPropertyCache->iBorderBottomStyles, aStates, level );
       
  1282 
       
  1283     DisableStatePropertyL(
       
  1284         aNode, aPseudoClass, CXnNode::BorderStyleL,
       
  1285         aLayoutPropertyCache->iBorderStyle,
       
  1286         aLayoutPropertyCache->iBorderStyles, aStates, level );
       
  1287 
       
  1288     DisableStatePropertyL(
       
  1289         aNode, aPseudoClass, CXnNode::DisplayPriorityL,
       
  1290         aLayoutPropertyCache->iDisplayPriority,
       
  1291         aLayoutPropertyCache->iDisplayPriorities, aStates, level );
       
  1292 
       
  1293     DisableStatePropertyL(
       
  1294         aNode, aPseudoClass, CXnNode::NavIndexL,
       
  1295         aLayoutPropertyCache->iNavIndex,
       
  1296         aLayoutPropertyCache->iNavIndexes, aStates, level );
       
  1297 
       
  1298     DisableStatePropertyL(
       
  1299         aNode, aPseudoClass, CXnNode::ZIndexL,
       
  1300         aLayoutPropertyCache->iZIndex,
       
  1301         aLayoutPropertyCache->iZIndexes, aStates, level );
       
  1302 
       
  1303     DisableStatePropertyL(
       
  1304         aNode, aPseudoClass, CXnNode::BackgroundColorL,
       
  1305         aLayoutPropertyCache->iBackgroundColor,
       
  1306         aLayoutPropertyCache->iBackgroundColors, aStates, level );
       
  1307 
       
  1308     DisableStatePropertyL(
       
  1309         aNode, aPseudoClass, CXnNode::BackgroundImageL,
       
  1310         aLayoutPropertyCache->iBackgroundImage,
       
  1311         aLayoutPropertyCache->iBackgroundImages, aStates, level, ETrue );
       
  1312 
       
  1313     DisableStatePropertyL(
       
  1314         aNode, aPseudoClass, CXnNode::FocusBackgroundL,
       
  1315         aLayoutPropertyCache->iFocusBackground,
       
  1316         aLayoutPropertyCache->iFocusBackgrounds, aStates, level );
       
  1317 
       
  1318     aNode.SetDirtyL( level );
       
  1319     }
       
  1320 
       
  1321 // -----------------------------------------------------------------------------
       
  1322 // AllocateLayoutCache()
       
  1323 // -----------------------------------------------------------------------------
       
  1324 //
       
  1325 static TBool AllocateLayoutCache( CLayoutPropertyCache*& aLayoutPropertyCache )
       
  1326     {
       
  1327     if ( !aLayoutPropertyCache )
       
  1328         {
       
  1329         aLayoutPropertyCache = new CLayoutPropertyCache;
       
  1330         }
       
  1331 
       
  1332     return aLayoutPropertyCache ? ETrue : EFalse;
       
  1333     }
       
  1334 
       
  1335 // -----------------------------------------------------------------------------
       
  1336 // DoSetCachedProperty()
       
  1337 // -----------------------------------------------------------------------------
       
  1338 //
       
  1339 static void DoSetCachedProperty(
       
  1340     CXnProperty* aProperty,\
       
  1341     CXnProperty*& aCachedPropertyToSet,
       
  1342     RPointerArray< CXnProperty >& aArray,
       
  1343     TBool aInitializing,
       
  1344     TBool aArrayOnly )
       
  1345     {
       
  1346     ReplaceOrAppend( aProperty, aArray, aInitializing );
       
  1347 
       
  1348     if ( !aArrayOnly )
       
  1349         {
       
  1350         aCachedPropertyToSet = aProperty;
       
  1351         }
       
  1352     }
       
  1353 
       
  1354 // -----------------------------------------------------------------------------
       
  1355 // SetCachedProperty()
       
  1356 // -----------------------------------------------------------------------------
       
  1357 //
       
  1358 static void SetCachedProperty(
       
  1359     CXnProperty* aProperty,
       
  1360     CLayoutPropertyCache*& aLayoutPropertyCache,
       
  1361     CXnProperty*& aRef,
       
  1362     CXnProperty*& aName,
       
  1363     CXnProperty*& aValue,
       
  1364     CXnProperty*& aLabel,
       
  1365     CXnProperty*& aInitialFocus,
       
  1366     CXnProperty*& aClass,
       
  1367     CXnProperty*& aId,
       
  1368     CXnProperty*& aPath,
       
  1369     CXnProperty*& aMaskPath,
       
  1370     CGridPropertyCache*& aGridPropertyCache,
       
  1371     TBool aInitializing,
       
  1372     TBool aArrayOnly)
       
  1373     {
       
  1374     const TDesC8& name = aProperty->Property()->Name();
       
  1375     if ( !AllocateLayoutCache( aLayoutPropertyCache ) )
       
  1376         {
       
  1377         return;
       
  1378         }
       
  1379     if ( name == XnPropertyNames::common::KId )
       
  1380         {
       
  1381         aId = aProperty;
       
  1382         }
       
  1383     else if ( name == XnPropertyNames::common::KClass )
       
  1384         {
       
  1385         aClass = aProperty;
       
  1386         }
       
  1387     else if ( name == XnPropertyNames::style::common::KWidth )
       
  1388         {
       
  1389         DoSetCachedProperty(
       
  1390             aProperty,
       
  1391             aLayoutPropertyCache->iWidth,
       
  1392             aLayoutPropertyCache->iWidths,
       
  1393             aInitializing, aArrayOnly );
       
  1394         }
       
  1395     else if ( name == XnPropertyNames::style::common::KHeight )
       
  1396         {
       
  1397         DoSetCachedProperty(
       
  1398             aProperty,
       
  1399             aLayoutPropertyCache->iHeight,
       
  1400             aLayoutPropertyCache->iHeights,
       
  1401             aInitializing, aArrayOnly );
       
  1402         }
       
  1403     else if ( name == XnPropertyNames::style::common::KBlockProgression )
       
  1404         {
       
  1405         DoSetCachedProperty(
       
  1406             aProperty,
       
  1407             aLayoutPropertyCache->iBlockProgression,
       
  1408             aLayoutPropertyCache->iBlockProgressions,
       
  1409             aInitializing, aArrayOnly );
       
  1410         }
       
  1411     else if ( name == XnPropertyNames::style::common::KDirection )
       
  1412         {
       
  1413         DoSetCachedProperty(
       
  1414             aProperty,
       
  1415             aLayoutPropertyCache->iDirection,
       
  1416             aLayoutPropertyCache->iDirections,
       
  1417             aInitializing, aArrayOnly );
       
  1418         }
       
  1419     else if ( name == XnPropertyNames::style::common::KPosition )
       
  1420         {
       
  1421         DoSetCachedProperty(
       
  1422             aProperty,
       
  1423             aLayoutPropertyCache->iPosition,
       
  1424             aLayoutPropertyCache->iPositions,
       
  1425             aInitializing, aArrayOnly );
       
  1426         }
       
  1427     else if ( name == XnPropertyNames::style::common::KDisplay )
       
  1428         {
       
  1429         DoSetCachedProperty(
       
  1430             aProperty,
       
  1431             aLayoutPropertyCache->iDisplay,
       
  1432             aLayoutPropertyCache->iDisplays,
       
  1433             aInitializing, aArrayOnly );
       
  1434         }
       
  1435     else if ( name == XnPropertyNames::style::common::KVisibility )
       
  1436         {
       
  1437         DoSetCachedProperty(
       
  1438             aProperty,
       
  1439             aLayoutPropertyCache->iVisibility,
       
  1440             aLayoutPropertyCache->iVisibilities,
       
  1441             aInitializing, aArrayOnly );
       
  1442         }
       
  1443     else if ( name == XnPropertyNames::action::KName )
       
  1444         {
       
  1445         aName = aProperty;
       
  1446         }
       
  1447     else if ( name == XnPropertyNames::action::KValue )
       
  1448         {
       
  1449         aValue = aProperty;
       
  1450         }
       
  1451     else if ( name == XnPropertyNames::menu::KLabel )
       
  1452         {
       
  1453         aLabel = aProperty;
       
  1454         }
       
  1455     else if ( name == XnPropertyNames::image::KPath )
       
  1456         {
       
  1457         aPath = aProperty;
       
  1458         }
       
  1459     else if ( name == XnPropertyNames::image::KMaskPath )
       
  1460         {
       
  1461         aMaskPath = aProperty;
       
  1462         }
       
  1463     else if ( name == KRef )
       
  1464         {
       
  1465         aRef = aProperty;
       
  1466         }
       
  1467     else if ( name == XnPropertyNames::style::common::KMarginLeft )
       
  1468         {
       
  1469         DoSetCachedProperty(
       
  1470             aProperty,
       
  1471             aLayoutPropertyCache->iMarginLeft,
       
  1472             aLayoutPropertyCache->iMarginLefts,
       
  1473             aInitializing, aArrayOnly );
       
  1474         }
       
  1475     else if ( name == XnPropertyNames::style::common::KMarginRight )
       
  1476         {
       
  1477         DoSetCachedProperty(
       
  1478             aProperty,
       
  1479             aLayoutPropertyCache->iMarginRight,
       
  1480             aLayoutPropertyCache->iMarginRights,
       
  1481             aInitializing, aArrayOnly );
       
  1482         }
       
  1483     else if ( name == XnPropertyNames::style::common::KBorderLeftWidth )
       
  1484         {
       
  1485         DoSetCachedProperty(
       
  1486             aProperty,
       
  1487             aLayoutPropertyCache->iBorderLeft,
       
  1488             aLayoutPropertyCache->iBorderLefts,
       
  1489             aInitializing, aArrayOnly );
       
  1490         }
       
  1491     else if ( name == XnPropertyNames::style::common::KBorderRightWidth )
       
  1492         {
       
  1493         DoSetCachedProperty(
       
  1494             aProperty,
       
  1495             aLayoutPropertyCache->iBorderRight,
       
  1496             aLayoutPropertyCache->iBorderRights,
       
  1497             aInitializing, aArrayOnly );
       
  1498         }
       
  1499     else if ( name == XnPropertyNames::style::common::KPaddingLeft )
       
  1500         {
       
  1501         DoSetCachedProperty(
       
  1502             aProperty,
       
  1503             aLayoutPropertyCache->iPaddingLeft,
       
  1504             aLayoutPropertyCache->iPaddingLefts,
       
  1505             aInitializing, aArrayOnly );
       
  1506         }
       
  1507     else if ( name == XnPropertyNames::style::common::KPaddingRight )
       
  1508         {
       
  1509         DoSetCachedProperty(
       
  1510             aProperty,
       
  1511             aLayoutPropertyCache->iPaddingRight,
       
  1512             aLayoutPropertyCache->iPaddingRights,
       
  1513             aInitializing, aArrayOnly );
       
  1514         }
       
  1515     else if ( name == XnPropertyNames::style::common::KMarginTop )
       
  1516         {
       
  1517         DoSetCachedProperty(
       
  1518             aProperty,
       
  1519             aLayoutPropertyCache->iMarginTop,
       
  1520             aLayoutPropertyCache->iMarginTops,
       
  1521             aInitializing, aArrayOnly );
       
  1522         }
       
  1523     else if ( name == XnPropertyNames::style::common::KMarginBottom )
       
  1524         {
       
  1525         DoSetCachedProperty(
       
  1526             aProperty,
       
  1527             aLayoutPropertyCache->iMarginBottom,
       
  1528             aLayoutPropertyCache->iMarginBottoms,
       
  1529             aInitializing, aArrayOnly );
       
  1530         }
       
  1531     else if ( name == XnPropertyNames::style::common::KBorderTopWidth )
       
  1532         {
       
  1533         DoSetCachedProperty(
       
  1534             aProperty,
       
  1535             aLayoutPropertyCache->iBorderTop,
       
  1536             aLayoutPropertyCache->iBorderTops,
       
  1537             aInitializing, aArrayOnly );
       
  1538         }
       
  1539     else if ( name == XnPropertyNames::style::common::KBorderBottomWidth )
       
  1540         {
       
  1541         DoSetCachedProperty(
       
  1542             aProperty,
       
  1543             aLayoutPropertyCache->iBorderBottom,
       
  1544             aLayoutPropertyCache->iBorderBottoms,
       
  1545             aInitializing, aArrayOnly );
       
  1546         }
       
  1547     else if ( name == XnPropertyNames::style::common::KPaddingTop )
       
  1548         {
       
  1549         DoSetCachedProperty(
       
  1550             aProperty,
       
  1551             aLayoutPropertyCache->iPaddingTop,
       
  1552             aLayoutPropertyCache->iPaddingTops,
       
  1553             aInitializing, aArrayOnly );
       
  1554         }
       
  1555     else if ( name == XnPropertyNames::style::common::KPaddingBottom )
       
  1556         {
       
  1557         DoSetCachedProperty(
       
  1558             aProperty,
       
  1559             aLayoutPropertyCache->iPaddingBottom,
       
  1560             aLayoutPropertyCache->iPaddingBottoms,
       
  1561             aInitializing, aArrayOnly );
       
  1562         }
       
  1563     else if ( name == XnPropertyNames::style::common::KBorderWidth )
       
  1564         {
       
  1565         DoSetCachedProperty(
       
  1566             aProperty,
       
  1567             aLayoutPropertyCache->iBorderWidth,
       
  1568             aLayoutPropertyCache->iBorderWidths,
       
  1569             aInitializing, aArrayOnly );
       
  1570         }
       
  1571     else if ( name == XnPropertyNames::style::common::KMaxHeight )
       
  1572         {
       
  1573         DoSetCachedProperty(
       
  1574             aProperty,
       
  1575             aLayoutPropertyCache->iMaxHeight,
       
  1576             aLayoutPropertyCache->iMaxHeights,
       
  1577             aInitializing, aArrayOnly );
       
  1578         }
       
  1579     else if ( name == XnPropertyNames::style::common::KMinHeight )
       
  1580         {
       
  1581         DoSetCachedProperty(
       
  1582             aProperty,
       
  1583             aLayoutPropertyCache->iMinHeight,
       
  1584             aLayoutPropertyCache->iMinHeights,
       
  1585             aInitializing, aArrayOnly );
       
  1586         }
       
  1587     else if ( name == XnPropertyNames::style::common::KMaxWidth )
       
  1588         {
       
  1589         DoSetCachedProperty(
       
  1590             aProperty,
       
  1591             aLayoutPropertyCache->iMaxWidth,
       
  1592             aLayoutPropertyCache->iMaxWidths,
       
  1593             aInitializing, aArrayOnly );
       
  1594         }
       
  1595     else if ( name == XnPropertyNames::style::common::KMinWidth )
       
  1596         {
       
  1597         DoSetCachedProperty(
       
  1598             aProperty,
       
  1599             aLayoutPropertyCache->iMinWidth,
       
  1600             aLayoutPropertyCache->iMinWidths,
       
  1601             aInitializing, aArrayOnly );
       
  1602         }
       
  1603     else if ( name == XnPropertyNames::style::common::KLeft )
       
  1604         {
       
  1605         DoSetCachedProperty(
       
  1606             aProperty,
       
  1607             aLayoutPropertyCache->iLeft,
       
  1608             aLayoutPropertyCache->iLefts,
       
  1609             aInitializing, aArrayOnly );
       
  1610         }
       
  1611     else if ( name == XnPropertyNames::style::common::KRight )
       
  1612         {
       
  1613         DoSetCachedProperty(
       
  1614             aProperty,
       
  1615             aLayoutPropertyCache->iRight,
       
  1616             aLayoutPropertyCache->iRights,
       
  1617             aInitializing, aArrayOnly );
       
  1618         }
       
  1619     else if ( name == XnPropertyNames::style::common::KTop )
       
  1620         {
       
  1621         DoSetCachedProperty(
       
  1622             aProperty,
       
  1623             aLayoutPropertyCache->iTop,
       
  1624             aLayoutPropertyCache->iTops,
       
  1625             aInitializing, aArrayOnly );
       
  1626         }
       
  1627     else if ( name == XnPropertyNames::style::common::KBottom )
       
  1628         {
       
  1629         DoSetCachedProperty(
       
  1630             aProperty,
       
  1631             aLayoutPropertyCache->iBottom,
       
  1632             aLayoutPropertyCache->iBottoms,
       
  1633             aInitializing, aArrayOnly );
       
  1634         }
       
  1635     else if ( name == XnPropertyNames::appearance::common::KBorderLeftStyle )
       
  1636         {
       
  1637         DoSetCachedProperty(
       
  1638             aProperty,
       
  1639             aLayoutPropertyCache->iBorderLeftStyle,
       
  1640             aLayoutPropertyCache->iBorderLeftStyles,
       
  1641             aInitializing, aArrayOnly );
       
  1642         }
       
  1643     else if ( name == XnPropertyNames::appearance::common::KBorderRightStyle )
       
  1644         {
       
  1645         DoSetCachedProperty(
       
  1646             aProperty,
       
  1647             aLayoutPropertyCache->iBorderRightStyle,
       
  1648             aLayoutPropertyCache->iBorderRightStyles,
       
  1649             aInitializing, aArrayOnly );
       
  1650         }
       
  1651     else if ( name == XnPropertyNames::appearance::common::KBorderTopStyle )
       
  1652         {
       
  1653         DoSetCachedProperty(
       
  1654             aProperty,
       
  1655             aLayoutPropertyCache->iBorderTopStyle,
       
  1656             aLayoutPropertyCache->iBorderTopStyles,
       
  1657             aInitializing, aArrayOnly );
       
  1658         }
       
  1659     else if ( name == XnPropertyNames::appearance::common::KBorderBottomStyle )
       
  1660         {
       
  1661         DoSetCachedProperty(
       
  1662             aProperty,
       
  1663             aLayoutPropertyCache->iBorderBottomStyle,
       
  1664             aLayoutPropertyCache->iBorderBottomStyles,
       
  1665             aInitializing, aArrayOnly );
       
  1666         }
       
  1667     else if ( name == XnPropertyNames::appearance::common::KBorderStyle )
       
  1668         {
       
  1669         DoSetCachedProperty(
       
  1670             aProperty,
       
  1671             aLayoutPropertyCache->iBorderStyle,
       
  1672             aLayoutPropertyCache->iBorderStyles,
       
  1673             aInitializing, aArrayOnly );
       
  1674         }
       
  1675     else if ( name == XnPropertyNames::appearance::common::KBorderImage )
       
  1676         {
       
  1677         aLayoutPropertyCache->iBorderImage = aProperty;
       
  1678         }
       
  1679     else if ( name == XnPropertyNames::style::common::KZIndex )
       
  1680         {
       
  1681         DoSetCachedProperty(
       
  1682             aProperty,
       
  1683             aLayoutPropertyCache->iZIndex,
       
  1684             aLayoutPropertyCache->iZIndexes,
       
  1685             aInitializing, aArrayOnly );
       
  1686         }
       
  1687     else if ( name == XnPropertyNames::appearance::common::KBackGroundColor )
       
  1688         {
       
  1689         DoSetCachedProperty(
       
  1690             aProperty,
       
  1691             aLayoutPropertyCache->iBackgroundColor,
       
  1692             aLayoutPropertyCache->iBackgroundColors,
       
  1693             aInitializing, aArrayOnly );
       
  1694         }
       
  1695     else if ( name == XnPropertyNames::appearance::common::KBackGroundImage )
       
  1696         {
       
  1697         DoSetCachedProperty(
       
  1698             aProperty,
       
  1699             aLayoutPropertyCache->iBackgroundImage,
       
  1700             aLayoutPropertyCache->iBackgroundImages,
       
  1701             aInitializing, aArrayOnly );
       
  1702         }
       
  1703     else if ( name == XnPropertyNames::appearance::common::KFocusBackground )
       
  1704         {
       
  1705         DoSetCachedProperty(
       
  1706             aProperty,
       
  1707             aLayoutPropertyCache->iFocusBackground,
       
  1708             aLayoutPropertyCache->iFocusBackgrounds,
       
  1709             aInitializing, aArrayOnly );
       
  1710         }
       
  1711     else if ( name == XnPropertyNames::style::common::KS60DisplayPriority )
       
  1712         {
       
  1713         DoSetCachedProperty(
       
  1714             aProperty,
       
  1715             aLayoutPropertyCache->iDisplayPriority,
       
  1716             aLayoutPropertyCache->iDisplayPriorities,
       
  1717             aInitializing, aArrayOnly );
       
  1718         }
       
  1719     else if ( name == XnPropertyNames::common::KInitialFocus )
       
  1720         {
       
  1721         aInitialFocus = aProperty;
       
  1722         }
       
  1723     else if ( name == XnPropertyNames::style::common::KNavIndex )
       
  1724         {
       
  1725         DoSetCachedProperty(
       
  1726             aProperty,
       
  1727             aLayoutPropertyCache->iNavIndex,
       
  1728             aLayoutPropertyCache->iNavIndexes,
       
  1729             aInitializing, aArrayOnly );
       
  1730         }
       
  1731     else if ( name == XnPropertyNames::grid::KS60VisibleRows )
       
  1732         {
       
  1733         if ( !aGridPropertyCache )
       
  1734             {
       
  1735             aGridPropertyCache = new CGridPropertyCache;
       
  1736             }
       
  1737         if ( aGridPropertyCache )
       
  1738             {
       
  1739             aGridPropertyCache->iVisibleRows = aProperty;
       
  1740             }
       
  1741         }
       
  1742     else if ( name == XnPropertyNames::grid::KS60GridColumns )
       
  1743         {
       
  1744         if ( !aGridPropertyCache )
       
  1745             {
       
  1746             aGridPropertyCache = new CGridPropertyCache;
       
  1747             }
       
  1748         if ( aGridPropertyCache )
       
  1749             {
       
  1750             aGridPropertyCache->iGridColumns = aProperty;
       
  1751             }
       
  1752         }
       
  1753     else if ( name == XnPropertyNames::grid::KS60GridOrientation )
       
  1754         {
       
  1755         if ( !aGridPropertyCache )
       
  1756             {
       
  1757             aGridPropertyCache = new CGridPropertyCache;
       
  1758             }
       
  1759         if ( aGridPropertyCache )
       
  1760             {
       
  1761             aGridPropertyCache->iGridOrientation = aProperty;
       
  1762             }
       
  1763         }
       
  1764     else if ( name == XnPropertyNames::grid::KS60GridVerDirection )
       
  1765         {
       
  1766         if ( !aGridPropertyCache )
       
  1767             {
       
  1768             aGridPropertyCache = new CGridPropertyCache;
       
  1769             }
       
  1770         if ( aGridPropertyCache )
       
  1771             {
       
  1772             aGridPropertyCache->iGridVerDirection = aProperty;
       
  1773             }
       
  1774         }
       
  1775     else if ( name == XnPropertyNames::grid::KS60GridHorDirection )
       
  1776         {
       
  1777         if ( !aGridPropertyCache )
       
  1778             {
       
  1779             aGridPropertyCache = new CGridPropertyCache;
       
  1780             }
       
  1781         if ( aGridPropertyCache )
       
  1782             {
       
  1783             aGridPropertyCache->iGridHorDirection = aProperty;
       
  1784             }
       
  1785         }
       
  1786     else if ( name == XnPropertyNames::grid::KS60FocusHorLooping )
       
  1787         {
       
  1788         if ( !aGridPropertyCache )
       
  1789             {
       
  1790             aGridPropertyCache = new CGridPropertyCache;
       
  1791             }
       
  1792         if ( aGridPropertyCache )
       
  1793             {
       
  1794             aGridPropertyCache->iFocusHorLooping = aProperty;
       
  1795             }
       
  1796         }
       
  1797     else if ( name == XnPropertyNames::grid::KS60FocusVerLooping )
       
  1798         {
       
  1799         if ( !aGridPropertyCache )
       
  1800             {
       
  1801             aGridPropertyCache = new CGridPropertyCache;
       
  1802             }
       
  1803         if ( aGridPropertyCache )
       
  1804             {
       
  1805             aGridPropertyCache->iFocusVerLooping = aProperty;
       
  1806             }
       
  1807         }
       
  1808     else if ( name == XnPropertyNames::grid::KS60GridScrollbarWidth )
       
  1809         {
       
  1810         if ( !aGridPropertyCache )
       
  1811             {
       
  1812             aGridPropertyCache = new CGridPropertyCache;
       
  1813             }
       
  1814         if ( aGridPropertyCache )
       
  1815             {
       
  1816             aGridPropertyCache->iGridScrollBarWidth = aProperty;
       
  1817             }
       
  1818         }
       
  1819     else if ( name == XnPropertyNames::grid::KS60GridScrollbarMargin )
       
  1820         {
       
  1821         if ( !aGridPropertyCache )
       
  1822             {
       
  1823             aGridPropertyCache = new CGridPropertyCache;
       
  1824             }
       
  1825         if ( aGridPropertyCache )
       
  1826             {
       
  1827             aGridPropertyCache->iGridScrollBarMargin = aProperty;
       
  1828             }
       
  1829         }
       
  1830     }
       
  1831 
       
  1832 // -----------------------------------------------------------------------------
       
  1833 // ReplaceOrAppend()
       
  1834 // -----------------------------------------------------------------------------
       
  1835 //
       
  1836 static void ReplaceOrAppend(
       
  1837     CXnProperty* aProperty,
       
  1838     RPointerArray< CXnProperty >& aArray,
       
  1839     TBool aAppendOnly )
       
  1840     {
       
  1841     if ( !aAppendOnly )
       
  1842         {
       
  1843         for ( TInt i = aArray.Count() - 1; i >= 0; --i )
       
  1844             {
       
  1845             if ( aArray[i] == aProperty )
       
  1846                 {
       
  1847                 aArray.Remove( i );
       
  1848                 }
       
  1849             else if ( aArray[i]->Property()->PseudoClass() ==
       
  1850                       aProperty->Property()->PseudoClass() &&
       
  1851                       aArray[i]->Property()->Name() ==
       
  1852                       aProperty->Property()->Name() )
       
  1853                 {
       
  1854                 aArray.Remove( i );
       
  1855                 }
       
  1856             }
       
  1857         }
       
  1858     aArray.Append( aProperty );
       
  1859     }
       
  1860 
       
  1861 // -----------------------------------------------------------------------------
       
  1862 // IsPropertyPseudoClass()
       
  1863 // -----------------------------------------------------------------------------
       
  1864 //
       
  1865 static TBool IsPropertyPseudoClass(
       
  1866     CXnDomProperty::TPseudoClass aPseudoClass,
       
  1867     RArray< CXnDomProperty::TPseudoClass >& aArray )
       
  1868     {
       
  1869     for ( TInt i = aArray.Count() - 1; i >= 0; --i )
       
  1870         {
       
  1871         if ( aArray[i] == aPseudoClass )
       
  1872             {
       
  1873             return ETrue;
       
  1874             }
       
  1875         }
       
  1876     return EFalse;
       
  1877     }
       
  1878 
       
  1879 // -----------------------------------------------------------------------------
       
  1880 // InsertPropertyPseudoClassL()
       
  1881 // -----------------------------------------------------------------------------
       
  1882 //
       
  1883 static void InsertPropertyPseudoClassL(
       
  1884     CXnDomProperty::TPseudoClass aPseudoClass,
       
  1885     RArray< CXnDomProperty::TPseudoClass >& aArray )
       
  1886     {
       
  1887     if ( !IsPropertyPseudoClass( aPseudoClass, aArray ) )
       
  1888         {
       
  1889         User::LeaveIfError( aArray.Append( aPseudoClass ) );
       
  1890         }
       
  1891     }
       
  1892 
       
  1893 // -----------------------------------------------------------------------------
       
  1894 // BuildEventTypeNodeL
       
  1895 // -----------------------------------------------------------------------------
       
  1896 //
       
  1897 static CXnNode* BuildEventTypeNodeL( TEventCode aType, CXnUiEngine& aUiEngine )
       
  1898     {
       
  1899     CXnNode* node = CXnNode::NewL();
       
  1900     CleanupStack::PushL( node );
       
  1901     CXnType* type = CXnType::NewL( XnPropertyNames::action::KProperty );
       
  1902     CleanupStack::PushL( type );
       
  1903     CXnNodeImpl* impl = CXnNodeImpl::NewL( type );
       
  1904     CleanupStack::Pop( type );
       
  1905     node->SetImpl( impl );
       
  1906     node->SetUiEngine( aUiEngine );
       
  1907     CXnDomPropertyValue* nameValue = CXnDomPropertyValue::NewL(
       
  1908         aUiEngine.ODT()->DomDocument().StringPool() );
       
  1909     CleanupStack::PushL( nameValue );
       
  1910     nameValue->SetStringValueL(
       
  1911         CXnDomPropertyValue::EString,
       
  1912         XnPropertyNames::action::trigger::name::keyevent::KEventType );
       
  1913     CXnProperty* name = CXnProperty::NewL(
       
  1914         XnPropertyNames::action::KName,
       
  1915         nameValue, aUiEngine.ODT()->DomDocument().StringPool() );
       
  1916     CleanupStack::Pop( nameValue );
       
  1917     CleanupStack::PushL( name );
       
  1918     node->SetPropertyL( name );
       
  1919     CleanupStack::Pop( name );
       
  1920     CXnDomPropertyValue* valueValue = CXnDomPropertyValue::NewL(
       
  1921         aUiEngine.ODT()->DomDocument().StringPool() );
       
  1922     CleanupStack::PushL( valueValue );
       
  1923     valueValue->SetFloatValueL( CXnDomPropertyValue::ENumber, aType );
       
  1924     CXnProperty* value = CXnProperty::NewL(
       
  1925         XnPropertyNames::action::KValue, valueValue,
       
  1926         aUiEngine.ODT()->DomDocument().StringPool() );
       
  1927     CleanupStack::Pop( valueValue );
       
  1928     CleanupStack::PushL( value );
       
  1929     node->SetPropertyL( value );
       
  1930     CleanupStack::Pop( value );
       
  1931     CleanupStack::Pop( node );
       
  1932     return node;
       
  1933     }
       
  1934 
       
  1935 // -----------------------------------------------------------------------------
       
  1936 // BuildModifiersNodeL
       
  1937 // -----------------------------------------------------------------------------
       
  1938 //
       
  1939 static CXnNode* BuildModifiersNodeL(
       
  1940     const TKeyEvent& aKeyEvent,
       
  1941     CXnUiEngine& aUiEngine )
       
  1942     {
       
  1943     CXnNode* node = CXnNode::NewL();
       
  1944     CleanupStack::PushL( node );
       
  1945     CXnType* type = CXnType::NewL( XnPropertyNames::action::KProperty );
       
  1946     CleanupStack::PushL( type );
       
  1947     CXnNodeImpl* impl = CXnNodeImpl::NewL( type );
       
  1948     CleanupStack::Pop( type );
       
  1949     node->SetImpl( impl );
       
  1950     node->SetUiEngine( aUiEngine );
       
  1951     CXnDomPropertyValue* nameValue = CXnDomPropertyValue::NewL(
       
  1952         aUiEngine.ODT()->DomDocument().StringPool() );
       
  1953     CleanupStack::PushL( nameValue );
       
  1954     nameValue->SetStringValueL(
       
  1955         CXnDomPropertyValue::EString,
       
  1956         XnPropertyNames::action::trigger::name::keyevent::KModifiers );
       
  1957     CXnProperty* name = CXnProperty::NewL(
       
  1958         XnPropertyNames::action::KName,
       
  1959         nameValue,
       
  1960         aUiEngine.ODT()->DomDocument().StringPool() );
       
  1961     CleanupStack::Pop( nameValue );
       
  1962     CleanupStack::PushL( name );
       
  1963     node->SetPropertyL( name );
       
  1964     CleanupStack::Pop( name );
       
  1965     CXnDomPropertyValue* valueValue = CXnDomPropertyValue::NewL(
       
  1966         aUiEngine.ODT()->DomDocument().StringPool() );
       
  1967     CleanupStack::PushL( valueValue );
       
  1968     valueValue->SetFloatValueL(
       
  1969         CXnDomPropertyValue::ENumber, aKeyEvent.iModifiers );
       
  1970     CXnProperty* value = CXnProperty::NewL(
       
  1971         XnPropertyNames::action::KValue,
       
  1972         valueValue,
       
  1973         aUiEngine.ODT()->DomDocument().StringPool() );
       
  1974     CleanupStack::Pop( valueValue );
       
  1975     CleanupStack::PushL( value );
       
  1976     node->SetPropertyL( value );
       
  1977     CleanupStack::Pop( value );
       
  1978     CleanupStack::Pop( node );
       
  1979     return node;
       
  1980     }
       
  1981 
       
  1982 // -----------------------------------------------------------------------------
       
  1983 // BuildKeyCodeNodeL
       
  1984 // -----------------------------------------------------------------------------
       
  1985 //
       
  1986 static CXnNode* BuildKeyCodeNodeL(
       
  1987     const TKeyEvent& aKeyEvent,
       
  1988     CXnUiEngine& aUiEngine )
       
  1989     {
       
  1990     CXnNode* node = CXnNode::NewL();
       
  1991     CleanupStack::PushL( node );
       
  1992     CXnType* type = CXnType::NewL( XnPropertyNames::action::KProperty );
       
  1993     CleanupStack::PushL( type );
       
  1994     CXnNodeImpl* impl = CXnNodeImpl::NewL( type );
       
  1995     CleanupStack::Pop( type );
       
  1996     node->SetImpl( impl );
       
  1997     node->SetUiEngine( aUiEngine );
       
  1998     CXnDomPropertyValue* nameValue = CXnDomPropertyValue::NewL(
       
  1999         aUiEngine.ODT()->DomDocument().StringPool() );
       
  2000     CleanupStack::PushL( nameValue );
       
  2001     nameValue->SetStringValueL(
       
  2002         CXnDomPropertyValue::EString,
       
  2003         XnPropertyNames::action::trigger::name::keyevent::KKeyCode );
       
  2004     CXnProperty* name = CXnProperty::NewL(
       
  2005         XnPropertyNames::action::KName,
       
  2006         nameValue,
       
  2007         aUiEngine.ODT()->DomDocument().StringPool() );
       
  2008     CleanupStack::Pop( nameValue );
       
  2009     CleanupStack::PushL( name );
       
  2010     node->SetPropertyL( name );
       
  2011     CleanupStack::Pop( name );
       
  2012     CXnDomPropertyValue* valueValue = CXnDomPropertyValue::NewL(
       
  2013         aUiEngine.ODT()->DomDocument().StringPool() );
       
  2014     CleanupStack::PushL( valueValue );
       
  2015     valueValue->SetFloatValueL( CXnDomPropertyValue::ENumber, aKeyEvent.iCode );
       
  2016     CXnProperty* value = CXnProperty::NewL(
       
  2017         XnPropertyNames::action::KValue,
       
  2018         valueValue,
       
  2019         aUiEngine.ODT()->DomDocument().StringPool() );
       
  2020     CleanupStack::Pop( valueValue );
       
  2021     CleanupStack::PushL( value );
       
  2022     node->SetPropertyL( value );
       
  2023     CleanupStack::Pop( value );
       
  2024     CleanupStack::Pop( node );
       
  2025     return node;
       
  2026     }
       
  2027 
       
  2028 // -----------------------------------------------------------------------------
       
  2029 // BuildScanCodeNodeL
       
  2030 // -----------------------------------------------------------------------------
       
  2031 //
       
  2032 static CXnNode* BuildScanCodeNodeL(
       
  2033     const TKeyEvent& aKeyEvent,
       
  2034     CXnUiEngine& aUiEngine )
       
  2035     {
       
  2036     CXnNode* node = CXnNode::NewL();
       
  2037     CleanupStack::PushL( node );
       
  2038     CXnType* type = CXnType::NewL( XnPropertyNames::action::KProperty );
       
  2039     CleanupStack::PushL( type );
       
  2040     CXnNodeImpl* impl = CXnNodeImpl::NewL( type );
       
  2041     CleanupStack::Pop( type );
       
  2042     node->SetImpl( impl );
       
  2043     node->SetUiEngine( aUiEngine );
       
  2044     CXnDomPropertyValue* nameValue = CXnDomPropertyValue::NewL(
       
  2045         aUiEngine.ODT()->DomDocument().StringPool() );
       
  2046     CleanupStack::PushL( nameValue );
       
  2047     nameValue->SetStringValueL(
       
  2048         CXnDomPropertyValue::EString,
       
  2049         XnPropertyNames::action::trigger::name::keyevent::KScanCode );
       
  2050     CXnProperty* name = CXnProperty::NewL(
       
  2051         XnPropertyNames::action::KName,
       
  2052         nameValue,
       
  2053         aUiEngine.ODT()->DomDocument().StringPool() );
       
  2054     CleanupStack::Pop( nameValue );
       
  2055     CleanupStack::PushL( name );
       
  2056     node->SetPropertyL( name );
       
  2057     CleanupStack::Pop( name );
       
  2058     CXnDomPropertyValue* valueValue = CXnDomPropertyValue::NewL(
       
  2059         aUiEngine.ODT()->DomDocument().StringPool() );
       
  2060     CleanupStack::PushL( valueValue );
       
  2061     valueValue->SetFloatValueL(
       
  2062         CXnDomPropertyValue::ENumber, aKeyEvent.iScanCode );
       
  2063     CXnProperty* value = CXnProperty::NewL(
       
  2064         XnPropertyNames::action::KValue,
       
  2065         valueValue,
       
  2066         aUiEngine.ODT()->DomDocument().StringPool() );
       
  2067     CleanupStack::Pop( valueValue );
       
  2068     CleanupStack::PushL( value );
       
  2069     node->SetPropertyL( value );
       
  2070     CleanupStack::Pop( value );
       
  2071     CleanupStack::Pop( node );
       
  2072     return node;
       
  2073     }
       
  2074 
       
  2075 // -----------------------------------------------------------------------------
       
  2076 // BuildRepeatsNodeL
       
  2077 // -----------------------------------------------------------------------------
       
  2078 //
       
  2079 static CXnNode* BuildRepeatsNodeL(
       
  2080     const TKeyEvent& aKeyEvent,
       
  2081     CXnUiEngine& aUiEngine )
       
  2082     {
       
  2083     CXnNode* node = CXnNode::NewL();
       
  2084     CleanupStack::PushL( node );
       
  2085     CXnType* type = CXnType::NewL( XnPropertyNames::action::KProperty );
       
  2086     CleanupStack::PushL( type );
       
  2087     CXnNodeImpl* impl = CXnNodeImpl::NewL( type );
       
  2088     CleanupStack::Pop( type );
       
  2089     node->SetImpl( impl );
       
  2090     node->SetUiEngine( aUiEngine );
       
  2091     CXnDomPropertyValue* nameValue = CXnDomPropertyValue::NewL(
       
  2092         aUiEngine.ODT()->DomDocument().StringPool() );
       
  2093     CleanupStack::PushL( nameValue );
       
  2094     nameValue->SetStringValueL(
       
  2095         CXnDomPropertyValue::EString,
       
  2096         XnPropertyNames::action::trigger::name::keyevent::KRepeats );
       
  2097     CXnProperty* name = CXnProperty::NewL(
       
  2098         XnPropertyNames::action::KName,
       
  2099         nameValue,
       
  2100         aUiEngine.ODT()->DomDocument().StringPool() );
       
  2101     CleanupStack::Pop( nameValue );
       
  2102     CleanupStack::PushL( name );
       
  2103     node->SetPropertyL( name );
       
  2104     CleanupStack::Pop( name );
       
  2105     CXnDomPropertyValue* valueValue = CXnDomPropertyValue::NewL(
       
  2106         aUiEngine.ODT()->DomDocument().StringPool() );
       
  2107     CleanupStack::PushL( valueValue );
       
  2108     valueValue->SetFloatValueL(
       
  2109         CXnDomPropertyValue::ENumber, aKeyEvent.iRepeats );
       
  2110     CXnProperty* value = CXnProperty::NewL(
       
  2111         XnPropertyNames::action::KValue,
       
  2112         valueValue,
       
  2113         aUiEngine.ODT()->DomDocument().StringPool()) ;
       
  2114     CleanupStack::Pop( valueValue );
       
  2115     CleanupStack::PushL( value );
       
  2116     node->SetPropertyL( value );
       
  2117     CleanupStack::Pop( value );
       
  2118     CleanupStack::Pop( node );
       
  2119     return node;
       
  2120     }
       
  2121 
       
  2122 // -----------------------------------------------------------------------------
       
  2123 // BuildActivateTriggerNodeL
       
  2124 // -----------------------------------------------------------------------------
       
  2125 //
       
  2126 static CXnNode* BuildActivateTriggerNodeL( CXnUiEngine& aUiEngine )
       
  2127     {
       
  2128     CXnNode* node = CXnNode::NewL();
       
  2129     CleanupStack::PushL( node );
       
  2130     CXnType* type = CXnType::NewL( XnPropertyNames::action::KTrigger );
       
  2131     CleanupStack::PushL( type );
       
  2132     CXnNodeImpl* impl = CXnNodeImpl::NewL( type );
       
  2133     CleanupStack::Pop( type );
       
  2134     node->SetImpl( impl );
       
  2135     node->SetUiEngine( aUiEngine );
       
  2136     CXnDomPropertyValue* nameValue = CXnDomPropertyValue::NewL(
       
  2137         aUiEngine.ODT()->DomDocument().StringPool() );
       
  2138     CleanupStack::PushL( nameValue );
       
  2139     nameValue->SetStringValueL( CXnDomPropertyValue::EString,
       
  2140         XnPropertyNames::action::trigger::name::KActivate );
       
  2141     CXnProperty* name = CXnProperty::NewL(
       
  2142         XnPropertyNames::action::trigger::KName,
       
  2143         nameValue,
       
  2144         aUiEngine.ODT()->DomDocument().StringPool() );
       
  2145     CleanupStack::Pop( nameValue );
       
  2146     CleanupStack::PushL( name );
       
  2147     node->SetPropertyL( name );
       
  2148     CleanupStack::Pop( name );
       
  2149     CleanupStack::Pop( node );
       
  2150     return node;
       
  2151     }
       
  2152 
       
  2153 // -----------------------------------------------------------------------------
       
  2154 // BuildPropertyNodesL
       
  2155 // -----------------------------------------------------------------------------
       
  2156 //
       
  2157 static void BuildPropertyNodesL(
       
  2158     CXnNode& aNode,
       
  2159     const TKeyEvent& aKeyEvent,
       
  2160     TEventCode aType,
       
  2161     CXnUiEngine& aUiEngine )
       
  2162     {
       
  2163     CXnNode* eventType = BuildEventTypeNodeL( aType, aUiEngine );
       
  2164     CleanupStack::PushL( eventType );
       
  2165     aNode.AddChildL( eventType );
       
  2166     CleanupStack::Pop( eventType );
       
  2167     CXnNode* modifiers = BuildModifiersNodeL( aKeyEvent, aUiEngine );
       
  2168     CleanupStack::PushL( modifiers );
       
  2169     aNode.AddChildL( modifiers );
       
  2170     CleanupStack::Pop( modifiers );
       
  2171     CXnNode* keyCode = BuildKeyCodeNodeL( aKeyEvent, aUiEngine );
       
  2172     CleanupStack::PushL( keyCode );
       
  2173     aNode.AddChildL( keyCode );
       
  2174     CleanupStack::Pop( keyCode );
       
  2175     CXnNode* scanCode = BuildScanCodeNodeL( aKeyEvent, aUiEngine );
       
  2176     CleanupStack::PushL( scanCode );
       
  2177     aNode.AddChildL( scanCode );
       
  2178     CleanupStack::Pop( scanCode );
       
  2179     CXnNode* repeats = BuildRepeatsNodeL( aKeyEvent, aUiEngine );
       
  2180     CleanupStack::PushL( repeats );
       
  2181     aNode.AddChildL( repeats );
       
  2182     CleanupStack::Pop( repeats );
       
  2183     }
       
  2184 
       
  2185 // -----------------------------------------------------------------------------
       
  2186 // BuildKeyTriggerNodeL
       
  2187 // -----------------------------------------------------------------------------
       
  2188 //
       
  2189 static CXnNode* BuildKeyTriggerNodeL(
       
  2190     const TKeyEvent& aKeyEvent,
       
  2191     TEventCode aType,
       
  2192     CXnUiEngine& aUiEngine )
       
  2193     {
       
  2194     CXnNode* node = CXnNode::NewL();
       
  2195     CleanupStack::PushL( node );
       
  2196     CXnType* type = CXnType::NewL( XnPropertyNames::action::KTrigger );
       
  2197     CleanupStack::PushL( type );
       
  2198     CXnNodeImpl* impl = CXnNodeImpl::NewL( type );
       
  2199     CleanupStack::Pop( type );
       
  2200     node->SetImpl( impl );
       
  2201     node->SetUiEngine( aUiEngine );
       
  2202     CXnDomPropertyValue* nameValue = CXnDomPropertyValue::NewL(
       
  2203         aUiEngine.ODT()->DomDocument().StringPool() );
       
  2204     CleanupStack::PushL( nameValue );
       
  2205     nameValue->SetStringValueL(
       
  2206         CXnDomPropertyValue::EString,
       
  2207         XnPropertyNames::action::trigger::name::KKeyEvent );
       
  2208     CXnProperty* name = CXnProperty::NewL(
       
  2209         XnPropertyNames::action::trigger::KName,
       
  2210         nameValue,
       
  2211         aUiEngine.ODT()->DomDocument().StringPool() );
       
  2212     CleanupStack::Pop( nameValue );
       
  2213     CleanupStack::PushL( name );
       
  2214     node->SetPropertyL( name );
       
  2215     CleanupStack::Pop( name );
       
  2216     BuildPropertyNodesL( *node, aKeyEvent, aType, aUiEngine );
       
  2217     CleanupStack::Pop( node );
       
  2218     return node;
       
  2219     }
       
  2220 
       
  2221 // -----------------------------------------------------------------------------
       
  2222 // PseudoClassFromName
       
  2223 // -----------------------------------------------------------------------------
       
  2224 //
       
  2225 static CXnDomProperty::TPseudoClass PseudoClassFromName( const TDesC8& aName )
       
  2226     {
       
  2227     if ( aName == KPseudoClassFocus )
       
  2228         {
       
  2229         return CXnDomProperty::EFocus;
       
  2230         }
       
  2231     else if ( aName == KPseudoClassPassiveFocus )
       
  2232         {
       
  2233         return CXnDomProperty::EPassiveFocus;
       
  2234         }
       
  2235     else if ( aName == KPseudoClassHold )
       
  2236         {
       
  2237         return CXnDomProperty::EHold;
       
  2238         }
       
  2239     else if ( aName == KPseudoClassHover )
       
  2240         {
       
  2241         return CXnDomProperty::EHover;
       
  2242         }
       
  2243     else if ( aName == KPseudoClassLink )
       
  2244         {
       
  2245         return CXnDomProperty::ELink;
       
  2246         }
       
  2247     else if ( aName == KPseudoClassVisited )
       
  2248         {
       
  2249         return CXnDomProperty::EVisited;
       
  2250         }
       
  2251     else if ( aName == KPseudoClassActive )
       
  2252         {
       
  2253         return CXnDomProperty::EActive;
       
  2254         }
       
  2255     else if ( aName == KPseudoClassEdit )
       
  2256         {
       
  2257         return CXnDomProperty::EEdit;
       
  2258         }
       
  2259     else if ( aName == KPseudoClassPressedDown )
       
  2260         {
       
  2261         return CXnDomProperty::EPressedDown;
       
  2262         }
       
  2263     return CXnDomProperty::ENone;
       
  2264     }
       
  2265 
       
  2266 // -----------------------------------------------------------------------------
       
  2267 // PseudoClassName
       
  2268 // -----------------------------------------------------------------------------
       
  2269 //
       
  2270 static const TDesC8& PseudoClassName( CXnDomProperty::TPseudoClass aPseudoClass )
       
  2271     {
       
  2272     switch ( aPseudoClass )
       
  2273         {
       
  2274         case CXnDomProperty::EFocus:
       
  2275             return KPseudoClassFocus;
       
  2276         case CXnDomProperty::EPassiveFocus:
       
  2277             return KPseudoClassPassiveFocus;
       
  2278         case CXnDomProperty::EHold:
       
  2279             return KPseudoClassHold;
       
  2280         case CXnDomProperty::EHover:
       
  2281             return KPseudoClassHover;
       
  2282         case CXnDomProperty::ELink:
       
  2283             return KPseudoClassLink;
       
  2284         case CXnDomProperty::EVisited:
       
  2285             return KPseudoClassVisited;
       
  2286         case CXnDomProperty::EActive:
       
  2287             return KPseudoClassActive;
       
  2288         case CXnDomProperty::EEdit:
       
  2289             return KPseudoClassEdit;
       
  2290         default:
       
  2291             return KNullDesC8;
       
  2292         }
       
  2293     }
       
  2294 
       
  2295 // -----------------------------------------------------------------------------
       
  2296 // CheckRefAttributeL
       
  2297 // -----------------------------------------------------------------------------
       
  2298 //
       
  2299 static const TDesC8* CheckRefAttributeL( CXnProperty* aRef )
       
  2300     {
       
  2301     if ( !aRef )
       
  2302         {
       
  2303         return NULL;
       
  2304         }
       
  2305 
       
  2306     return &aRef->StringValue();
       
  2307     }
       
  2308 
       
  2309 // -----------------------------------------------------------------------------
       
  2310 // DoMatchTriggerForKeyEventL
       
  2311 // -----------------------------------------------------------------------------
       
  2312 //
       
  2313 static TBool DoMatchTriggerForKeyEventL(
       
  2314     const TKeyEvent& aKeyEvent, TEventCode aType,
       
  2315     CXnDomNode& aTriggerNode )
       
  2316     {
       
  2317     TInt triggerEventType = EEventKeyDown;
       
  2318     TInt triggerKeyCode = 0;
       
  2319     TInt triggerScanCode = 0;
       
  2320     TInt triggerModifiers = 0;
       
  2321     CXnDomList& triggerChildren = aTriggerNode.ChildNodes();
       
  2322     TInt triggerCount = triggerChildren.Length();
       
  2323     TBool triggerScanCodeSet = EFalse;
       
  2324     TBool triggerKeyCodeSet = EFalse;
       
  2325     for ( TInt i = 0; i < triggerCount; ++i )
       
  2326         {
       
  2327         CXnDomNode* node = static_cast< CXnDomNode* >(
       
  2328             triggerChildren.Item( i ) );
       
  2329         CXnDomList& attrs = node->AttributeList();
       
  2330         CXnDomAttribute* nameAttribute = static_cast< CXnDomAttribute* >(
       
  2331             attrs.FindByName( XnPropertyNames::action::KName ) );
       
  2332         CXnDomAttribute* valueAttribute = static_cast< CXnDomAttribute* >(
       
  2333             attrs.FindByName( XnPropertyNames::action::KValue ) );
       
  2334         if ( nameAttribute->Value() ==
       
  2335              XnPropertyNames::action::trigger::name::keyevent::KEventType )
       
  2336             {
       
  2337             TLex8 lex( valueAttribute->Value() );
       
  2338             lex.Val( triggerEventType );
       
  2339             }
       
  2340         else if ( nameAttribute->Value() ==
       
  2341                   XnPropertyNames::action::trigger::name::keyevent::KModifiers )
       
  2342             {
       
  2343             TLex8 lex( valueAttribute->Value() );
       
  2344             lex.Val( triggerModifiers );
       
  2345             }
       
  2346         else if ( nameAttribute->Value() ==
       
  2347                   XnPropertyNames::action::trigger::name::keyevent::KKeyCode )
       
  2348             {
       
  2349             TLex8 lex( valueAttribute->Value() );
       
  2350             lex.Val( triggerKeyCode );
       
  2351             triggerKeyCodeSet = ETrue;
       
  2352             }
       
  2353         else if ( nameAttribute->Value() ==
       
  2354                   XnPropertyNames::action::trigger::name::keyevent::KScanCode )
       
  2355             {
       
  2356             TLex8 lex( valueAttribute->Value() );
       
  2357             lex.Val( triggerScanCode );
       
  2358             triggerScanCodeSet = ETrue;
       
  2359             }
       
  2360         }
       
  2361     return
       
  2362         aType == triggerEventType &&
       
  2363         ( triggerKeyCodeSet  ? ( aKeyEvent.iCode == triggerKeyCode ) : ETrue ) &&
       
  2364         ( triggerScanCodeSet ? ( aKeyEvent.iScanCode == triggerScanCode ) : ETrue ) &&
       
  2365         ( ( aKeyEvent.iModifiers & 0xFFFFFFFE ) == ( triggerModifiers & 0xFFFFFFFE ) );
       
  2366     }
       
  2367 
       
  2368 // -----------------------------------------------------------------------------
       
  2369 // MatchTriggerForKeyEventL
       
  2370 // -----------------------------------------------------------------------------
       
  2371 //
       
  2372 static TBool MatchTriggerForKeyEventL(
       
  2373     CXnNodeImpl* aThis,
       
  2374     CXnUiEngine& aEngine,
       
  2375     CXnNode& aNode,
       
  2376     const TKeyEvent& aKeyEvent,
       
  2377     TEventCode aType,
       
  2378     CXnDomNode& aActionNode,
       
  2379     CXnDomNode& aTriggerNode )
       
  2380     {
       
  2381     CXnDomList& attrs = aTriggerNode.AttributeList();
       
  2382     CXnDomAttribute* attribute = static_cast< CXnDomAttribute* >(
       
  2383         attrs.FindByName(XnPropertyNames::action::trigger::KName ) );
       
  2384     if ( !attribute )
       
  2385         {
       
  2386         return EFalse;
       
  2387         }
       
  2388 
       
  2389     const TDesC8& nameString = attribute->Value();
       
  2390     if ( nameString == KNullDesC8 )
       
  2391         {
       
  2392         return EFalse;
       
  2393         }
       
  2394     if ( nameString == XnPropertyNames::action::trigger::name::KKeyEvent )
       
  2395         {
       
  2396         TBool match = DoMatchTriggerForKeyEventL( aKeyEvent, aType, aTriggerNode );
       
  2397         if ( match )
       
  2398             {
       
  2399             CXnNode* eventNode = BuildKeyTriggerNodeL( aKeyEvent, aType, aEngine );
       
  2400             CleanupStack::PushL( eventNode );
       
  2401             RunEventsL( aThis, aEngine, aNode, aActionNode, aTriggerNode, *eventNode );
       
  2402             CleanupStack::PopAndDestroy( eventNode );
       
  2403             }
       
  2404         return match;
       
  2405         }
       
  2406     else if ( aType == EEventKey &&
       
  2407               ( nameString == XnPropertyNames::action::trigger::name::KUp ||
       
  2408                 nameString == XnPropertyNames::action::trigger::name::KDown ||
       
  2409                 nameString == XnPropertyNames::action::trigger::name::KLeft ||
       
  2410                 nameString == XnPropertyNames::action::trigger::name::KRight ) )
       
  2411         {
       
  2412         TBool match = DoMatchTriggerForHighLevelKeyEventL(
       
  2413             aNode, aKeyEvent, aType, nameString );
       
  2414         if ( match )
       
  2415             {
       
  2416             CXnNode* eventNode = BuildKeyTriggerNodeL( aKeyEvent, aType, aEngine );
       
  2417             CleanupStack::PushL( eventNode );
       
  2418             RunEventsL( aThis, aEngine, aNode, aActionNode, aTriggerNode, *eventNode );
       
  2419             CleanupStack::PopAndDestroy( eventNode );
       
  2420             }
       
  2421         return match;
       
  2422         }
       
  2423     else if ( aKeyEvent.iScanCode == EStdKeyDevice3 &&
       
  2424               aKeyEvent.iRepeats > 0 &&
       
  2425               nameString == XnPropertyNames::action::trigger::name::KHold )
       
  2426         {
       
  2427         CXnNode* eventNode = BuildKeyTriggerNodeL( aKeyEvent, aType, aEngine );
       
  2428         CleanupStack::PushL( eventNode );
       
  2429         RunEventsL( aThis, aEngine, aNode, aActionNode, aTriggerNode, *eventNode );
       
  2430         CleanupStack::PopAndDestroy( eventNode );
       
  2431         return ETrue;
       
  2432         }
       
  2433    else if ( ( ( aKeyEvent.iScanCode == EStdKeyDevice0 ) ||
       
  2434                ( aKeyEvent.iScanCode == EStdKeyDevice1 ) ) &&
       
  2435              aKeyEvent.iRepeats > 0 &&
       
  2436              nameString == XnPropertyNames::action::trigger::name::KHold )
       
  2437         {
       
  2438         CXnNode* eventNode = BuildKeyTriggerNodeL( aKeyEvent, aType, aEngine );
       
  2439         CleanupStack::PushL( eventNode );
       
  2440         RunEventsL( aThis, aEngine, aNode, aActionNode, aTriggerNode, *eventNode );
       
  2441         CleanupStack::PopAndDestroy( eventNode );
       
  2442         return ETrue;
       
  2443         }
       
  2444     return EFalse;
       
  2445     }
       
  2446 
       
  2447 // -----------------------------------------------------------------------------
       
  2448 // MatchTimedTriggerPropertiesL
       
  2449 // -----------------------------------------------------------------------------
       
  2450 //
       
  2451 static TBool MatchTimedTriggerPropertiesL( CXnDomNode& aTriggerNode )
       
  2452     {
       
  2453     CXnDomList& children = aTriggerNode.ChildNodes();
       
  2454     TInt count = children.Length();
       
  2455     if ( count > 0 )
       
  2456         {
       
  2457         for ( TInt i = 0; i < count; ++i )
       
  2458             {
       
  2459             CXnDomNode* child = static_cast< CXnDomNode* >( children.Item( i ) );
       
  2460             const TDesC8& name = child->AttributeValue( XnPropertyNames::action::KName );
       
  2461             if ( name == XnPropertyNames::action::trigger::KDelay )
       
  2462                 {
       
  2463                 return ETrue;
       
  2464                 }
       
  2465             }
       
  2466         }
       
  2467     return EFalse;
       
  2468     }
       
  2469 
       
  2470 // -----------------------------------------------------------------------------
       
  2471 // MatchStylusTriggerL
       
  2472 // -----------------------------------------------------------------------------
       
  2473 //
       
  2474 static TBool MatchStylusTriggerL(
       
  2475     CXnNode& aMatchingTriggerNode,
       
  2476     CXnDomNode& aTreeTriggerNode )
       
  2477     {
       
  2478     TInt ret( EFalse );
       
  2479 
       
  2480     CXnDomList& treeChildren = aTreeTriggerNode.ChildNodes();
       
  2481     TInt treeCount = treeChildren.Length();
       
  2482 
       
  2483     RPointerArray< CXnNode >& matchingChildren = aMatchingTriggerNode.Children();
       
  2484     TInt matchCount = matchingChildren.Count();
       
  2485 
       
  2486     if ( treeCount == 0 )
       
  2487         {
       
  2488         // If stylus-trigger does not have properties, trigger is run with stylus up.
       
  2489         for ( TInt i = 0; i < matchCount; ++i )
       
  2490             {
       
  2491             CXnNode* node = matchingChildren[i];
       
  2492             CXnProperty* nameProperty = node->NameL();
       
  2493             if ( nameProperty )
       
  2494                 {
       
  2495                 const TDesC8& name = nameProperty->StringValue();
       
  2496                 if ( name ==
       
  2497                      XnPropertyNames::action::trigger::name::stylus::KStylusEventType )
       
  2498                     {
       
  2499                     CXnProperty* valueProperty = node->ValueL();
       
  2500                     if ( valueProperty )
       
  2501                         {
       
  2502                         const TDesC8& name = valueProperty->StringValue();
       
  2503                         if ( name == XnPropertyNames::action::trigger::name::KDownAndUp )
       
  2504                             {
       
  2505                             return ETrue;
       
  2506                             }
       
  2507                         }
       
  2508                     }
       
  2509                 }
       
  2510             }
       
  2511         return EFalse;
       
  2512         }
       
  2513 
       
  2514     // Fetch trigger data defined in the theme
       
  2515     TInt treeTriggerState( 1 );
       
  2516     HBufC8* treeTriggerType( NULL );
       
  2517     for ( TInt i = 0; i < treeCount; ++i )
       
  2518         {
       
  2519         CXnDomNode* domNode = static_cast< CXnDomNode* >( treeChildren.Item( i ) );
       
  2520         CXnDomList& attrs = domNode->AttributeList();
       
  2521         CXnDomAttribute* nameAttribute = static_cast< CXnDomAttribute* >(
       
  2522             attrs.FindByName( XnPropertyNames::action::KName ) );
       
  2523         CXnDomAttribute* valueAttribute = static_cast< CXnDomAttribute* >(
       
  2524             attrs.FindByName( XnPropertyNames::action::KValue ) );
       
  2525         if ( nameAttribute->Value() ==
       
  2526              XnPropertyNames::action::trigger::name::stylus::KStylusState )
       
  2527             {
       
  2528             TLex8 lex( valueAttribute->Value() );
       
  2529             lex.Val( treeTriggerState );
       
  2530             }
       
  2531         else if ( nameAttribute->Value() ==
       
  2532                   XnPropertyNames::action::trigger::name::stylus::KStylusEventType )
       
  2533             {
       
  2534             // just in case
       
  2535             if ( treeTriggerType )
       
  2536                 {
       
  2537                 CleanupStack::PopAndDestroy( treeTriggerType );
       
  2538                 treeTriggerType = NULL;
       
  2539                 }
       
  2540             const TDesC8& value = valueAttribute->Value();
       
  2541             treeTriggerType = HBufC8::NewL( value.Length() );
       
  2542             TPtr8 ptr = treeTriggerType->Des();
       
  2543             ptr = value;
       
  2544             CleanupStack::PushL( treeTriggerType );
       
  2545             }
       
  2546         }
       
  2547 
       
  2548     // If not defined, use the default value 'up'
       
  2549     if ( !treeTriggerType )
       
  2550         {
       
  2551         treeTriggerType = HBufC8::NewL( 10 );
       
  2552         TPtr8 ptr = treeTriggerType->Des();
       
  2553         ptr.Append( XnPropertyNames::action::trigger::name::KDownAndUp );
       
  2554         CleanupStack::PushL( treeTriggerType );
       
  2555         }
       
  2556 
       
  2557     // Fetch matching trigger data.
       
  2558     TInt matchTriggerState( 1 );
       
  2559     HBufC8* matchTriggerType( NULL );
       
  2560     for ( TInt i = 0; i < matchCount; ++i )
       
  2561         {
       
  2562         CXnNode* matchNode = matchingChildren[i];
       
  2563         CXnProperty* nameProperty = matchNode->NameL();
       
  2564         CXnProperty* valueProperty = matchNode->ValueL();
       
  2565         if ( nameProperty && valueProperty )
       
  2566             {
       
  2567             if ( nameProperty->StringValue() ==
       
  2568                  XnPropertyNames::action::trigger::name::stylus::KStylusState )
       
  2569                 {
       
  2570                 TLex8 lex( valueProperty->StringValue() );
       
  2571                 lex.Val( matchTriggerState );
       
  2572                 }
       
  2573             else if ( nameProperty->StringValue() ==
       
  2574                       XnPropertyNames::action::trigger::name::stylus::KStylusEventType )
       
  2575                 {
       
  2576                 // just in case
       
  2577                 if ( matchTriggerType )
       
  2578                     {
       
  2579                     CleanupStack::PopAndDestroy( matchTriggerType );
       
  2580                     matchTriggerType = NULL;
       
  2581                     }
       
  2582                 const TDesC8& value = valueProperty->StringValue();
       
  2583                 matchTriggerType = HBufC8::NewL( value.Length() );
       
  2584                 TPtr8 ptr = matchTriggerType->Des();
       
  2585                 ptr = value;
       
  2586                 CleanupStack::PushL( matchTriggerType );
       
  2587                 }
       
  2588             }
       
  2589         }
       
  2590 
       
  2591     if ( treeTriggerState == matchTriggerState )
       
  2592         {
       
  2593         // just in case
       
  2594         if ( !matchTriggerType )
       
  2595             {
       
  2596             ret = EFalse;
       
  2597             }
       
  2598         else if ( treeTriggerType->Des() == matchTriggerType->Des() )
       
  2599             {
       
  2600             ret = ETrue;
       
  2601             }
       
  2602         // still, if trigger type is 'KUp' it should match to 'KDownAndUp' event
       
  2603         else if ( treeTriggerType->Des() ==
       
  2604                   XnPropertyNames::action::trigger::name::KUp )
       
  2605             {
       
  2606             if ( matchTriggerType->Des() ==
       
  2607                  XnPropertyNames::action::trigger::name::KDownAndUp )
       
  2608                 {
       
  2609                 ret = ETrue;
       
  2610                 }
       
  2611             }
       
  2612         }
       
  2613     if ( matchTriggerType )
       
  2614         {
       
  2615         CleanupStack::PopAndDestroy( matchTriggerType );
       
  2616         }
       
  2617     if ( treeTriggerType )
       
  2618         {
       
  2619         CleanupStack::PopAndDestroy( treeTriggerType );
       
  2620         }
       
  2621     return ret;
       
  2622     }
       
  2623 
       
  2624 // -----------------------------------------------------------------------------
       
  2625 // MatchActivateTriggerPropertiesL
       
  2626 // Checks if triggered node properties match
       
  2627 // ones defined in theme
       
  2628 // -----------------------------------------------------------------------------
       
  2629 //
       
  2630 static TBool MatchActivateTriggerPropertiesL(
       
  2631     CXnNode& aEventData,
       
  2632     CXnDomNode& aTriggerNode )
       
  2633     {
       
  2634     RPointerArray< CXnNode >& eventChildren = aEventData.Children();
       
  2635     TInt eventCount = eventChildren.Count();
       
  2636 
       
  2637     if ( eventCount )
       
  2638         {
       
  2639         CXnNode* node = eventChildren[0];
       
  2640         CXnProperty* nameProperty = node->NameL();
       
  2641         CXnProperty* valueProperty = node->ValueL();
       
  2642 
       
  2643         if ( !nameProperty || !valueProperty )
       
  2644             {
       
  2645             return EFalse;
       
  2646             }
       
  2647 
       
  2648         const TDesC8& name = nameProperty->StringValue();
       
  2649 
       
  2650         if ( name == XnPropertyNames::action::trigger::name::keyevent::KEventType )
       
  2651             {
       
  2652             const TDesC8& valueName = valueProperty->StringValue();
       
  2653 
       
  2654             CXnDomList& children = aTriggerNode.ChildNodes();
       
  2655             TInt count = children.Length();
       
  2656 
       
  2657             if ( ( valueName == _L8( "3" ) ) ) //keydown
       
  2658                 {
       
  2659                 // check that no eventype has been defined
       
  2660                 if ( !count )
       
  2661                     {
       
  2662                     return EFalse;
       
  2663                     }
       
  2664                 }
       
  2665             else if ( ( valueName ==  _L8( "2" ) ) ) //keyup
       
  2666                 {
       
  2667                 ///check that some eventtype has been defined
       
  2668                 if ( !count )
       
  2669                     {
       
  2670                     return EFalse;
       
  2671                     }
       
  2672 
       
  2673                 CXnDomNode* node = static_cast< CXnDomNode* >( children.Item( 0 ) );
       
  2674                 CXnDomList& attrs = node->AttributeList();
       
  2675                 CXnDomAttribute* nameAttribute = static_cast< CXnDomAttribute* >(
       
  2676                     attrs.FindByName( XnPropertyNames::action::KName ) );
       
  2677                 CXnDomAttribute* valueAttribute = static_cast< CXnDomAttribute* >(
       
  2678                     attrs.FindByName( XnPropertyNames::action::KValue ) );
       
  2679 
       
  2680                 const TDesC8& name = nameAttribute->Value();
       
  2681 
       
  2682                 // check that eventype name matches
       
  2683                 if ( name !=
       
  2684                      XnPropertyNames::action::trigger::name::keyevent::KEventType )
       
  2685                     {
       
  2686                     return EFalse;
       
  2687                     }
       
  2688                 else
       
  2689                     {
       
  2690                     //check that eventype value matches
       
  2691                     const TDesC8& valueName = valueAttribute->Value();
       
  2692                     if ( valueName != _L8( "2" ) )
       
  2693                         {
       
  2694                         return EFalse;
       
  2695                         }
       
  2696                     }
       
  2697                 }
       
  2698             }
       
  2699         }
       
  2700 
       
  2701     return ETrue;
       
  2702     }
       
  2703 
       
  2704 // -----------------------------------------------------------------------------
       
  2705 // MatchScreenDeviceChangePropertiesL
       
  2706 // Checks if triggered node properties match
       
  2707 // ones defined in theme
       
  2708 // -----------------------------------------------------------------------------
       
  2709 //
       
  2710 static TBool MatchScreenDeviceChangePropertiesL(
       
  2711     CXnNode& aEventData,
       
  2712     CXnDomNode& aTriggerNode )
       
  2713     {
       
  2714     CXnDomList& attributeList( aTriggerNode.AttributeList() );
       
  2715 
       
  2716     const TDesC8& reason(
       
  2717         XnPropertyNames::action::trigger::name::uidefinitionmodification::KReason );
       
  2718 
       
  2719     CXnDomAttribute* attribute( static_cast< CXnDomAttribute* >
       
  2720         ( attributeList.FindByName( reason ) ) );
       
  2721 
       
  2722     if ( !attribute )
       
  2723         {
       
  2724         // Reason not defined, run events for plain screendevicechange trigger
       
  2725         return ETrue;
       
  2726         }
       
  2727 
       
  2728     const TDesC8& value( attribute->Value() );
       
  2729 
       
  2730     if ( value ==
       
  2731          XnPropertyNames::action::trigger::name::uidefinitionmodification::reason::KLandscape ||
       
  2732          value ==
       
  2733          XnPropertyNames::action::trigger::name::uidefinitionmodification::reason::KPortrait )
       
  2734         {
       
  2735         CXnProperty* reasonProp( aEventData.GetPropertyL( reason ) );
       
  2736 
       
  2737         if ( reasonProp )
       
  2738             {
       
  2739             const TDesC8& reasonValue( reasonProp->StringValue() );
       
  2740 
       
  2741             if ( reasonValue == value )
       
  2742                 {
       
  2743                 return ETrue;
       
  2744                 }
       
  2745             }
       
  2746         }
       
  2747 
       
  2748     return EFalse;
       
  2749     }
       
  2750 
       
  2751 // -----------------------------------------------------------------------------
       
  2752 // MatchSwipeTriggerL
       
  2753 // Check if trigger matches the one defined in theme
       
  2754 // -----------------------------------------------------------------------------
       
  2755 //
       
  2756 static TBool MatchSwipeTriggerL(
       
  2757     CXnNode& aEventData,
       
  2758     CXnDomNode& aTriggerNode )
       
  2759     {
       
  2760     CXnDomList& attributeList( aTriggerNode.AttributeList() );
       
  2761 
       
  2762      const TDesC8& reason( XnPropertyNames::action::trigger::name::swipe::KDirection);
       
  2763 
       
  2764      CXnDomAttribute* attribute( static_cast< CXnDomAttribute* >
       
  2765          ( attributeList.FindByName( reason ) ) );
       
  2766 
       
  2767      if ( !attribute )
       
  2768          {
       
  2769          // Reason not defined
       
  2770          return EFalse;
       
  2771          }
       
  2772 
       
  2773      const TDesC8& value( attribute->Value() );
       
  2774 
       
  2775      if ( value == XnPropertyNames::action::trigger::name::swipe::direction::KLeft ||
       
  2776           value == XnPropertyNames::action::trigger::name::swipe::direction::KRight )
       
  2777          {
       
  2778          CXnProperty* reasonProp( aEventData.GetPropertyL( reason ) );
       
  2779 
       
  2780          if ( reasonProp )
       
  2781              {
       
  2782              const TDesC8& reasonValue( reasonProp->StringValue() );
       
  2783 
       
  2784              if ( reasonValue == value )
       
  2785                  {
       
  2786                  return ETrue;
       
  2787                  }
       
  2788              }
       
  2789          }
       
  2790 
       
  2791      return EFalse;
       
  2792     }
       
  2793 
       
  2794 // -----------------------------------------------------------------------------
       
  2795 // MatchValueAttributeTriggerL
       
  2796 // Check if trigger matches the one defined in theme
       
  2797 // -----------------------------------------------------------------------------
       
  2798 //
       
  2799 static TBool MatchValueAttributeTriggerL( CXnNode& aEventData,
       
  2800     CXnDomNode& aTriggerNode )
       
  2801     {
       
  2802     CXnDomList& attributeList( aTriggerNode.AttributeList() );
       
  2803 
       
  2804      const TDesC8& reason( XnPropertyNames::action::KValue );
       
  2805 
       
  2806      CXnDomAttribute* attribute( static_cast< CXnDomAttribute* >
       
  2807          ( attributeList.FindByName( reason ) ) );
       
  2808 
       
  2809      if ( !attribute )
       
  2810          {
       
  2811          // Reason not defined
       
  2812          return EFalse;
       
  2813          }
       
  2814 
       
  2815      const TDesC8& value( attribute->Value() );
       
  2816 
       
  2817      CXnProperty* reasonProp( aEventData.GetPropertyL( reason ) );
       
  2818 
       
  2819      if ( reasonProp )
       
  2820          {
       
  2821          const TDesC8& reasonValue( reasonProp->StringValue() );
       
  2822 
       
  2823          if ( reasonValue == value )
       
  2824              {
       
  2825              return ETrue;
       
  2826              }
       
  2827          }
       
  2828 
       
  2829      return EFalse;
       
  2830     }
       
  2831 
       
  2832 // -----------------------------------------------------------------------------
       
  2833 // MatchTitleScrollTriggerL
       
  2834 // -----------------------------------------------------------------------------
       
  2835 //
       
  2836 static TBool MatchTitleScrollTriggerL(CXnNode& aEventData,
       
  2837         CXnDomNode& aTriggerNode )
       
  2838     {
       
  2839     CXnDomList& attributeList( aTriggerNode.AttributeList() );
       
  2840 
       
  2841      const TDesC8& reason( XnPropertyNames::action::trigger::name::KTitleIndex );
       
  2842 
       
  2843      CXnDomAttribute* attribute( static_cast< CXnDomAttribute* >
       
  2844          ( attributeList.FindByName( reason ) ) );
       
  2845 
       
  2846      if ( !attribute )
       
  2847          {
       
  2848          // Reason not defined
       
  2849          return ETrue;
       
  2850          }
       
  2851      else
       
  2852          {
       
  2853          const TDesC8& value( attribute->Value() );
       
  2854 
       
  2855          CXnProperty* reasonProp( aEventData.GetPropertyL( reason ) );
       
  2856 
       
  2857          if ( reasonProp )
       
  2858              {
       
  2859              const TDesC8& reasonValue( reasonProp->StringValue() );
       
  2860 
       
  2861              if ( reasonValue == value )
       
  2862                  {
       
  2863                  return ETrue;
       
  2864                  }
       
  2865              }
       
  2866          }
       
  2867 
       
  2868      return EFalse;
       
  2869     }
       
  2870 
       
  2871 // -----------------------------------------------------------------------------
       
  2872 // MatchTriggerForEventL
       
  2873 // -----------------------------------------------------------------------------
       
  2874 //
       
  2875 static TBool MatchTriggerForEventL(
       
  2876     CXnNodeImpl* aThis,
       
  2877     CXnUiEngine& aEngine,
       
  2878     CXnNode& aNode,
       
  2879     CXnNode& aEventData,
       
  2880     CXnDomNode& aActionNode,
       
  2881     CXnDomNode& aTriggerNode,
       
  2882     TInt aSource )
       
  2883     {
       
  2884     const TDesC8& nameString( aTriggerNode.AttributeValue( KName ) );
       
  2885 
       
  2886     if ( nameString == KNullDesC8 )
       
  2887         {
       
  2888         return EFalse;
       
  2889         }
       
  2890 
       
  2891     CXnProperty* eventName( aEventData.NameL() );
       
  2892     const TDesC8& eventNameString( eventName->StringValue() );
       
  2893 
       
  2894     if ( nameString == eventNameString )
       
  2895         {
       
  2896         if ( nameString == XnPropertyNames::action::trigger::name::KStylus )
       
  2897             {
       
  2898             if ( !MatchStylusTriggerL( aEventData, aTriggerNode ) )
       
  2899                 {
       
  2900                 return EFalse;
       
  2901                 }
       
  2902             }
       
  2903         // Check if triggernode properties match the ones defined in theme
       
  2904         // This is for identifying keyup in activate-trigger
       
  2905         else if ( nameString == XnPropertyNames::action::trigger::name::KActivate )
       
  2906             {
       
  2907             if ( !MatchActivateTriggerPropertiesL( aEventData, aTriggerNode ) )
       
  2908                 {
       
  2909                 return EFalse;
       
  2910                 }
       
  2911             }
       
  2912         // Check if the trigger is timed trigger
       
  2913         else if ( MatchTimedTriggerPropertiesL( aTriggerNode ) )
       
  2914             {
       
  2915             if ( !aThis->PeriodicTimer() )
       
  2916                 {
       
  2917                 aThis->CreatePeriodicL();
       
  2918                 }
       
  2919 
       
  2920             if ( !aThis->PeriodicTimer()->IsActive() )
       
  2921                 {
       
  2922                 TXnTimedTrigger* params = new ( ELeave ) TXnTimedTrigger;
       
  2923                 CleanupStack::PushL( params );
       
  2924 
       
  2925                 params->iNodeImpl = aThis;
       
  2926                 params->iEngine = &aEngine;
       
  2927                 params->iNode = &aNode;
       
  2928                 params->iEventData = &aEventData;
       
  2929                 params->iActionNode = &aActionNode;
       
  2930                 params->iTriggerNode = &aTriggerNode;
       
  2931 
       
  2932                 TInt delay( 0 );
       
  2933 
       
  2934                 ResolveTriggerDelayL( aEngine, aTriggerNode, delay );
       
  2935                 aNode.SetTriggerDelay( delay );
       
  2936 
       
  2937                 CleanupStack::Pop( params );
       
  2938 
       
  2939                 aThis->PeriodicTimer()->Start(
       
  2940                     TTimeIntervalMicroSeconds32( delay ),
       
  2941                     TTimeIntervalMicroSeconds32( delay ),
       
  2942                     TCallBack( CXnNodeImpl::PeriodicEventL, params ) );
       
  2943 
       
  2944                 return ETrue;
       
  2945                 }
       
  2946             else
       
  2947                 {
       
  2948                 return EFalse;
       
  2949                 }
       
  2950             }
       
  2951         else if ( nameString == XnPropertyNames::action::trigger::name::KTitleToScroll ||
       
  2952                   nameString == XnPropertyNames::action::trigger::name::KTitleScrolled )
       
  2953             {
       
  2954             if ( !MatchTitleScrollTriggerL( aEventData, aTriggerNode ) )
       
  2955                 {
       
  2956                 return EFalse;
       
  2957                 }
       
  2958             }
       
  2959         else if ( nameString ==
       
  2960                   XnPropertyNames::action::trigger::name::KScreenDeviceChange )
       
  2961             {
       
  2962             if ( !MatchScreenDeviceChangePropertiesL( aEventData, aTriggerNode ) )
       
  2963                 {
       
  2964                 return EFalse;
       
  2965                 }
       
  2966             }
       
  2967         else if ( nameString == XnPropertyNames::action::trigger::name::KSwipe )
       
  2968             {
       
  2969             if ( !MatchSwipeTriggerL( aEventData, aTriggerNode ) )
       
  2970                 {
       
  2971                 return EFalse;
       
  2972                 }
       
  2973             }
       
  2974         else if ( nameString == XnPropertyNames::action::trigger::name::KWidgetAmount ||
       
  2975                   nameString == XnPropertyNames::action::trigger::name::KCallState ||
       
  2976                   nameString == XnPropertyNames::action::trigger::name::KEditMode )
       
  2977             {
       
  2978             if ( !MatchValueAttributeTriggerL( aEventData, aTriggerNode ) )
       
  2979                 {
       
  2980                 return EFalse;
       
  2981                 }
       
  2982             }
       
  2983         else if ( aSource != XnEventSource::EUnknown )
       
  2984             {
       
  2985             CXnDomAttribute* attr = static_cast< CXnDomAttribute* >
       
  2986                 ( aTriggerNode.AttributeList().FindByName(
       
  2987                     XnPropertyNames::common::KEventFilter ) );
       
  2988             if ( attr )
       
  2989                 {
       
  2990                 if ( attr->Value().Find(XnPropertyNames::action::trigger::name::KStylus)
       
  2991                      != KErrNotFound &&
       
  2992                      aSource == XnEventSource::EStylus )
       
  2993                     {
       
  2994                     return EFalse;
       
  2995                     }
       
  2996                 else if ( attr->Value().Find(XnPropertyNames::action::trigger::name::KKeyEvent)
       
  2997                           != KErrNotFound &&
       
  2998                           aSource == XnEventSource::EKey )
       
  2999                     {
       
  3000                     return EFalse;
       
  3001                     }
       
  3002                 }
       
  3003             }
       
  3004 
       
  3005         RunEventsL( aThis, aEngine, aNode, aActionNode, aTriggerNode, aEventData );
       
  3006 
       
  3007         return ETrue;
       
  3008         }
       
  3009 
       
  3010     return EFalse;
       
  3011     }
       
  3012 
       
  3013 // -----------------------------------------------------------------------------
       
  3014 // GetFocusCandidatesL
       
  3015 // -----------------------------------------------------------------------------
       
  3016 //
       
  3017 static void GetFocusCandidatesL(
       
  3018     CXnNodeImpl* aThis,
       
  3019     CXnUiEngine& aEngine,
       
  3020     CXnDomNode& aEventNode,
       
  3021     RPointerArray< CXnNode >& aFocusCandidates )
       
  3022     {
       
  3023     CXnDomList& children( aEventNode.ChildNodes() );
       
  3024 
       
  3025     TInt count( children.Length() );
       
  3026 
       
  3027     for ( TInt i = 0; i < count; ++i )
       
  3028         {
       
  3029         CXnDomNode* dnode( static_cast< CXnDomNode* >( children.Item( i ) ) );
       
  3030 
       
  3031         const TDesC8& type( dnode->Name() );
       
  3032 
       
  3033         // Is the event's node child a property?
       
  3034         if ( type == XnPropertyNames::action::KProperty )
       
  3035             {
       
  3036             CXnDomList& attributeList( dnode->AttributeList() );
       
  3037 
       
  3038             CXnDomAttribute* attribute( static_cast< CXnDomAttribute* >
       
  3039                 ( attributeList.FindByName( XnPropertyNames::action::KValue ) ) );
       
  3040 
       
  3041             if ( attribute )
       
  3042                 {
       
  3043                 CXnNode* node( aEngine.FindNodeByIdL(
       
  3044                     attribute->Value(), aThis->Namespace() ) );
       
  3045 
       
  3046                 if ( node )
       
  3047                     {
       
  3048                     aFocusCandidates.AppendL( node );
       
  3049                     }
       
  3050                 }
       
  3051             }
       
  3052         }
       
  3053     }
       
  3054 
       
  3055 // -----------------------------------------------------------------------------
       
  3056 // RunPassiveFocusChangeL
       
  3057 // -----------------------------------------------------------------------------
       
  3058 //
       
  3059 static void RunPassiveFocusChangeL(
       
  3060     CXnNodeImpl* aThis,
       
  3061     CXnUiEngine& aEngine,
       
  3062     CXnDomNode& aEventNode,
       
  3063     const TDesC8& aString )
       
  3064     {
       
  3065     CXnDomList& children = aEventNode.ChildNodes();
       
  3066     TInt count = children.Length();
       
  3067     for ( TInt i = 0; i < count; ++i )
       
  3068         {
       
  3069         CXnDomNode* dnode = static_cast< CXnDomNode* >( children.Item( i ) );
       
  3070         const TDesC8& type = dnode->Name();
       
  3071         if ( type == XnPropertyNames::action::KProperty )
       
  3072             {
       
  3073             CXnDomList& attrs = dnode->AttributeList();
       
  3074             CXnDomAttribute* attribute = static_cast< CXnDomAttribute* >(
       
  3075                 attrs.FindByName(XnPropertyNames::action::KValue ) );
       
  3076             if ( attribute )
       
  3077                 {
       
  3078                 CXnNode* node = aEngine.FindNodeByIdL(
       
  3079                     attribute->Value(), aThis->Namespace() );
       
  3080                 if ( node )
       
  3081                     {
       
  3082                     if ( aString == XnPropertyNames::action::event::KSetPassiveFocus )
       
  3083                         {
       
  3084                         aEngine.AddPassiveFocusedNodeL( node );
       
  3085                         }
       
  3086                     else if ( aString == XnPropertyNames::action::event::KResetPassiveFocus )
       
  3087                         {
       
  3088                         aEngine.RemovePassiveFocusedNodeL( node );
       
  3089                         }
       
  3090                     else if ( aString == XnPropertyNames::action::event::KSetActiveFocus )
       
  3091                         {
       
  3092                         CXnNode* previousNode = aEngine.FocusedNode();
       
  3093                         if ( previousNode != node )
       
  3094                             {
       
  3095                             if ( IsNodeNavigableL( *node ) )
       
  3096                                 {
       
  3097                                 node->SetStateL( XnPropertyNames::style::common::KFocus );
       
  3098                                 aEngine.AddPassiveFocusedNodeL( previousNode );
       
  3099                                 break;
       
  3100                                 }
       
  3101                             }
       
  3102                         }
       
  3103                     }
       
  3104                 }
       
  3105             }
       
  3106         }
       
  3107     }
       
  3108 
       
  3109 // -----------------------------------------------------------------------------
       
  3110 // RunAppUiNotificationL
       
  3111 // -----------------------------------------------------------------------------
       
  3112 //
       
  3113 static void RunAppUiNotificationL(
       
  3114     CXnUiEngine& aEngine,
       
  3115     CXnNode& aNode,
       
  3116     CXnDomNode& aEventNode,
       
  3117     CXnDomNode& aTriggerNode,
       
  3118     CXnNode& aEventData )
       
  3119     {       
       
  3120     CXnAppUiAdapter& adapter( aEngine.AppUiAdapter() );
       
  3121     
       
  3122     adapter.HandleXuikonEventL(
       
  3123         aNode.AppIfL(), aEventData.AppIfL(), aTriggerNode, aEventNode );
       
  3124     }
       
  3125 
       
  3126 // -----------------------------------------------------------------------------
       
  3127 // RunAppExit
       
  3128 // -----------------------------------------------------------------------------
       
  3129 //
       
  3130 static void RunAppExit( CXnUiEngine& aEngine )
       
  3131     {
       
  3132     CXnAppUiAdapter& adapter( aEngine.AppUiAdapter() );
       
  3133     
       
  3134     adapter.Exit();
       
  3135     }
       
  3136 
       
  3137 // -----------------------------------------------------------------------------
       
  3138 // RunFullScreenEffectL
       
  3139 // -----------------------------------------------------------------------------
       
  3140 //
       
  3141 static void RunFullScreenEffectL( CXnUiEngine& aEngine, CXnDomNode& aEventNode )
       
  3142     {
       
  3143     CXnDomList& list( aEventNode.AttributeList() );
       
  3144     const TDesC8& effectid( XnPropertyNames::common::KEffectId );
       
  3145     CXnDomAttribute* attribute( static_cast< CXnDomAttribute* >
       
  3146         ( list.FindByName( effectid ) ) );
       
  3147 
       
  3148     if ( attribute )
       
  3149         {
       
  3150         const TDesC8& value( attribute->Value() );
       
  3151         TLex8 lex( value );
       
  3152         TInt effect;
       
  3153         lex.Val( effect );
       
  3154         aEngine.AppUiAdapter().EffectManager()->BeginFullscreenEffectL(
       
  3155                 effect, aEngine.ViewManager()->ActiveViewData() );
       
  3156         }
       
  3157     }
       
  3158 
       
  3159 // -----------------------------------------------------------------------------
       
  3160 // RunActivateViewL
       
  3161 // -----------------------------------------------------------------------------
       
  3162 //
       
  3163 static void RunActivateViewL(
       
  3164     CXnNodeImpl* aThis,
       
  3165     CXnUiEngine& aEngine,
       
  3166     CXnDomNode& aEventNode )
       
  3167     {
       
  3168     CXnDomList& children( aEventNode.ChildNodes() );
       
  3169 
       
  3170     TInt count( children.Length() );
       
  3171 
       
  3172     for ( TInt i = 0; i < count; ++i )
       
  3173         {
       
  3174         CXnDomNode* node = static_cast< CXnDomNode* >( children.Item( i ) );
       
  3175 
       
  3176         const TDesC8& type( node->Name() );
       
  3177 
       
  3178         if ( type == XnPropertyNames::action::KProperty )
       
  3179             {
       
  3180             const TDesC8& id( node->AttributeValue( XnPropertyNames::action::KValue ) );
       
  3181 
       
  3182             CXnNode* viewNode( aEngine.FindNodeByIdL( id, aThis->Namespace() ) );
       
  3183 
       
  3184             if ( viewNode )
       
  3185                 {
       
  3186                 aEngine.ActivateViewL( *viewNode );
       
  3187                 }
       
  3188             }
       
  3189         }
       
  3190     }
       
  3191 
       
  3192 // -----------------------------------------------------------------------------
       
  3193 // RunActivateNextViewL
       
  3194 // -----------------------------------------------------------------------------
       
  3195 //
       
  3196 static void RunActivateNextViewL( CXnUiEngine& aEngine )
       
  3197     {
       
  3198     aEngine.ViewManager()->ActivateNextViewL();
       
  3199     }
       
  3200 
       
  3201 // -----------------------------------------------------------------------------
       
  3202 // RunActivatePreviousViewL
       
  3203 // -----------------------------------------------------------------------------
       
  3204 //
       
  3205 static void RunActivatePreviousViewL( CXnUiEngine& aEngine )
       
  3206     {
       
  3207     aEngine.ViewManager()->ActivatePreviousViewL();
       
  3208     }
       
  3209 
       
  3210 // -----------------------------------------------------------------------------
       
  3211 // RunAddViewL
       
  3212 // -----------------------------------------------------------------------------
       
  3213 //
       
  3214 static void RunAddViewL( CXnUiEngine& aEngine )
       
  3215     {
       
  3216     aEngine.ViewManager()->AddViewL();
       
  3217     }
       
  3218 
       
  3219 // -----------------------------------------------------------------------------
       
  3220 // RunRemoveViewL
       
  3221 // -----------------------------------------------------------------------------
       
  3222 //
       
  3223 static void RunRemoveViewL( CXnUiEngine& aEngine )
       
  3224     {
       
  3225     aEngine.ViewManager()->RemoveViewL();
       
  3226     }
       
  3227 
       
  3228 // -----------------------------------------------------------------------------
       
  3229 // RunActivateL
       
  3230 // -----------------------------------------------------------------------------
       
  3231 //
       
  3232 static void RunActivateL(
       
  3233     CXnNodeImpl* aThis,
       
  3234     CXnUiEngine& aEngine,
       
  3235     CXnDomNode& aEventNode )
       
  3236     {
       
  3237     CXnDomList& children = aEventNode.ChildNodes();
       
  3238     TInt count = children.Length();
       
  3239     for ( TInt i = 0; i < count; ++i )
       
  3240         {
       
  3241         CXnDomNode* dnode = static_cast< CXnDomNode* >( children.Item( i ) );
       
  3242         const TDesC8& type = dnode->Name();
       
  3243         if ( type == XnPropertyNames::action::KProperty )
       
  3244             {
       
  3245             const TDesC8& id = dnode->AttributeValue( KId );
       
  3246             CXnNode* node = aEngine.FindNodeByIdL( id, aThis->Namespace() );
       
  3247             if ( node )
       
  3248                 {
       
  3249                 node->SetStateL( XnPropertyNames::style::common::KActive );
       
  3250                 return;
       
  3251                 }
       
  3252             }
       
  3253         }
       
  3254 
       
  3255     CXnNode* focused( aEngine.FocusedNode() );
       
  3256 
       
  3257     if ( focused )
       
  3258         {
       
  3259         focused->SetStateL( XnPropertyNames::style::common::KActive );
       
  3260         }
       
  3261     }
       
  3262 
       
  3263 // -----------------------------------------------------------------------------
       
  3264 // RunEditL
       
  3265 // -----------------------------------------------------------------------------
       
  3266 //
       
  3267 static void RunEditL(
       
  3268     CXnNodeImpl* aThis,
       
  3269     CXnUiEngine& aEngine,
       
  3270     CXnDomNode& aEventNode )
       
  3271     {    
       
  3272     TBool keyEditMode(EFalse);
       
  3273     
       
  3274     aEngine.DisableRenderUiLC();
       
  3275    
       
  3276     // Set plugins to edit state
       
  3277     RPointerArray< CXnPluginData>& plugins( 
       
  3278             aEngine.ViewManager()->ActiveViewData().PluginData() );
       
  3279 
       
  3280     CXnDomStringPool& sp( aEventNode.StringPool() );
       
  3281     
       
  3282     CXnDomList& children( aEventNode.ChildNodes() );
       
  3283 
       
  3284     TInt count( children.Length() );
       
  3285 
       
  3286     for ( TInt i = 0; i < count; ++i )
       
  3287         {
       
  3288         CXnDomNode* dnode = static_cast< CXnDomNode* >( children.Item( i ) );
       
  3289         const TDesC8& type = dnode->Name();
       
  3290 
       
  3291         if ( type == XnPropertyNames::action::KProperty )
       
  3292             {
       
  3293             const TDesC8& name = dnode->AttributeValue(
       
  3294                 XnPropertyNames::action::event::systemset::KName );
       
  3295             const TDesC8& value = dnode->AttributeValue(
       
  3296                 XnPropertyNames::action::event::systemset::KValue );
       
  3297 
       
  3298             if ( name != KNullDesC8 && value != KNullDesC8 )
       
  3299                 {
       
  3300                 // Find node by id
       
  3301                 if ( name == XnPropertyNames::common::KId )
       
  3302                     {
       
  3303                     CXnNode* node( aEngine.FindNodeByIdL( value, aThis->Namespace() ) );
       
  3304 
       
  3305                     if ( node )
       
  3306                         {
       
  3307                         node->SetStateL( XnPropertyNames::style::common::KEdit );                        
       
  3308                         }
       
  3309                     }
       
  3310                 // Find nodes by class
       
  3311                 else if ( name == XnPropertyNames::common::KClass )
       
  3312                     {
       
  3313                     CXnPointerArray* array = aEngine.FindNodeByClassL( value );
       
  3314                     CleanupStack::PushL( array );
       
  3315 
       
  3316                     if ( array )
       
  3317                         {
       
  3318                         const TInt count( array->Container().Count() );
       
  3319 
       
  3320                         for ( TInt i = 0; i < count; ++i )
       
  3321                             {
       
  3322                             CXnNode* node( static_cast< CXnNode* >(
       
  3323                                 array->Container()[i] ) );
       
  3324                                                                                                              
       
  3325                             CXnProperty* editable( node->GetPropertyL(
       
  3326                                 XnPropertyNames::style::common::edit::KEditable ) );
       
  3327 
       
  3328                             if ( !editable ||
       
  3329                                  editable->StringValue() != XnPropertyNames::KFalse )
       
  3330                                 {
       
  3331                                 node->SetStateL( XnPropertyNames::style::common::KEdit );                               
       
  3332                                 }
       
  3333                             }
       
  3334                         }
       
  3335 
       
  3336                     CleanupStack::PopAndDestroy( array );
       
  3337                     }
       
  3338                 else if ( name == XnPropertyNames::common::KKeyMoveMode )
       
  3339                     {
       
  3340                     if ( value == XnPropertyNames::KTrue )
       
  3341                         {
       
  3342                         keyEditMode = ETrue;
       
  3343                         }
       
  3344                     }
       
  3345                 }
       
  3346             }
       
  3347         }
       
  3348     if ( keyEditMode )
       
  3349         {
       
  3350         for ( TInt i = 0; i < plugins.Count(); i++ )
       
  3351             {
       
  3352             if ( plugins[i]->Occupied() )
       
  3353                 {
       
  3354                 CXnNode* node( plugins[i]->Owner()->LayoutNode() );
       
  3355                                              
       
  3356                 node->SetStateL( XnPropertyNames::style::common::KEdit );                                       
       
  3357                 }
       
  3358             }
       
  3359         
       
  3360         aEngine.EditMode()->SetEditModeL( CXnEditMode::EKeyMove );
       
  3361 
       
  3362         // Put focus to parent plugin if focused node is not a plugin already
       
  3363         CXnNode* focusedNode = aEngine.FocusedNode();
       
  3364         
       
  3365         if ( focusedNode && focusedNode->DomNode()->Name() != _L8( "plugin" ) )
       
  3366             {
       
  3367             for ( CXnNode* candidate =
       
  3368                   focusedNode; candidate; candidate = candidate->Parent() )
       
  3369                 {
       
  3370                 if ( candidate->DomNode()->Name() == _L8( "plugin" ) )
       
  3371                     {
       
  3372                     candidate->SetStateL( XnPropertyNames::style::common::KFocus );
       
  3373                     break;
       
  3374                     }
       
  3375                 }
       
  3376             }
       
  3377         }
       
  3378     else 
       
  3379         {        
       
  3380         TBool useEmpty( aEngine.ViewManager()->ActiveViewData().UseEmptyWidget() );
       
  3381         
       
  3382         for ( TInt i = 0; i < plugins.Count(); i++ )
       
  3383             {
       
  3384             CXnNode* node( plugins[i]->Owner()->LayoutNode() );
       
  3385             
       
  3386             node->SetStateL( XnPropertyNames::style::common::KEdit );
       
  3387                                    
       
  3388             if ( !plugins[i]->Occupied() && useEmpty )
       
  3389                 {                               
       
  3390                 // Make empty space visible
       
  3391                 SetStringPropertyToNodeL( sp, *node,
       
  3392                     XnPropertyNames::style::common::KVisibility,
       
  3393                     XnPropertyNames::style::common::visibility::KVisible );                    
       
  3394                 }                                              
       
  3395             }
       
  3396         
       
  3397         aEngine.EditMode()->SetEditModeL( CXnEditMode::EDragAndDrop );        
       
  3398         }
       
  3399 
       
  3400     CleanupStack::PopAndDestroy();
       
  3401     
       
  3402     aEngine.AppUiAdapter().ViewAdapter().UpdateRskByModeL();
       
  3403     }
       
  3404 
       
  3405 // -----------------------------------------------------------------------------
       
  3406 // RunResetEditL
       
  3407 // -----------------------------------------------------------------------------
       
  3408 //
       
  3409 static void RunResetEditL(
       
  3410     CXnNodeImpl* aThis,
       
  3411     CXnUiEngine& aEngine,
       
  3412     CXnDomNode& aEventNode )
       
  3413     {    
       
  3414     TBool keyEditMode( 
       
  3415             aEngine.EditMode()->EditState() == CXnEditMode::EKeyMove );
       
  3416     
       
  3417     CXnDomList& children( aEventNode.ChildNodes() );
       
  3418 
       
  3419     TInt count( children.Length() );
       
  3420 
       
  3421     for ( TInt i = 0; i < count; ++i )
       
  3422         {
       
  3423         CXnDomNode* dnode = static_cast< CXnDomNode* >( children.Item( i ) );
       
  3424         const TDesC8& type = dnode->Name();
       
  3425 
       
  3426         if ( type == XnPropertyNames::action::KProperty )
       
  3427             {
       
  3428             const TDesC8& name = dnode->AttributeValue(
       
  3429                 XnPropertyNames::action::event::systemset::KName );
       
  3430             const TDesC8& value = dnode->AttributeValue(
       
  3431                 XnPropertyNames::action::event::systemset::KValue );
       
  3432 
       
  3433             if ( name != KNullDesC8 && value != KNullDesC8 )
       
  3434                 {
       
  3435                 if ( name == XnPropertyNames::common::KId )
       
  3436                     {
       
  3437                     CXnNode* node( aEngine.FindNodeByIdL( value, aThis->Namespace() ) );
       
  3438 
       
  3439                     if ( node )
       
  3440                         {
       
  3441                         node->UnsetStateL(
       
  3442                             XnPropertyNames::style::common::KEdit );                        
       
  3443                         }
       
  3444                     }
       
  3445                 else if ( name == XnPropertyNames::common::KClass )
       
  3446                     {
       
  3447                     CXnPointerArray* array( aEngine.FindNodeByClassL( value ) );
       
  3448                     CleanupStack::PushL( array );
       
  3449 
       
  3450                     const TInt count = array->Container().Count();
       
  3451 
       
  3452                     for ( TInt i = 0; i < count; ++i )
       
  3453                         {
       
  3454                         CXnNode* node = static_cast< CXnNode* >(
       
  3455                             array->Container()[i] );
       
  3456 
       
  3457                         if ( node &&
       
  3458                              node->IsStateSet( XnPropertyNames::style::common::KEdit ) )
       
  3459                             {
       
  3460                             node->UnsetStateL( XnPropertyNames::style::common::KEdit );                            
       
  3461                             }
       
  3462                         }
       
  3463 
       
  3464                     CleanupStack::PopAndDestroy( array );
       
  3465                     }
       
  3466                 }
       
  3467             }
       
  3468         }
       
  3469 
       
  3470     RPointerArray< CXnPluginData>& plugins( 
       
  3471             aEngine.ViewManager()->ActiveViewData().PluginData() );
       
  3472 
       
  3473     CXnDomStringPool& sp( aEventNode.StringPool() );
       
  3474 
       
  3475     if ( keyEditMode )
       
  3476         {
       
  3477         for ( TInt i = 0; i < plugins.Count(); i++ )
       
  3478             {
       
  3479             if ( plugins[i]->Occupied() )
       
  3480                 {
       
  3481                 CXnNode* node( plugins[i]->Owner()->LayoutNode() );
       
  3482                                              
       
  3483                 node->UnsetStateL( XnPropertyNames::style::common::KEdit );                                       
       
  3484                 }
       
  3485             }        
       
  3486         }
       
  3487     else
       
  3488         {
       
  3489         TBool useEmpty( aEngine.ViewManager()->ActiveViewData().UseEmptyWidget() );
       
  3490         
       
  3491         for ( TInt i = 0; i < plugins.Count(); i++ )
       
  3492             {
       
  3493             CXnNode* node( plugins[i]->Owner()->LayoutNode() );
       
  3494             
       
  3495             node->UnsetStateL( XnPropertyNames::style::common::KEdit );
       
  3496             
       
  3497             if ( !plugins[i]->Occupied() && useEmpty )
       
  3498                 {                               
       
  3499                 // Make empty space blank
       
  3500                 SetStringPropertyToNodeL( sp, *node,
       
  3501                     XnPropertyNames::style::common::KVisibility,
       
  3502                     XnPropertyNames::style::common::visibility::KBlank );                    
       
  3503                 }
       
  3504             }                
       
  3505         }
       
  3506     
       
  3507     aEngine.EditMode()->SetEditModeL( CXnEditMode::ENone );    
       
  3508 
       
  3509     aEngine.AppUiAdapter().ViewAdapter().UpdateRskByModeL();
       
  3510     }
       
  3511 
       
  3512 // -----------------------------------------------------------------------------
       
  3513 // RunDeactivateL
       
  3514 // -----------------------------------------------------------------------------
       
  3515 //
       
  3516 static void RunDeactivateL(
       
  3517     CXnNodeImpl* aThis,
       
  3518     CXnUiEngine& aEngine,
       
  3519     CXnDomNode& aEventNode )
       
  3520     {
       
  3521     CXnDomList& children = aEventNode.ChildNodes();
       
  3522     TInt count = children.Length();
       
  3523     for ( TInt i = 0; i < count; ++i )
       
  3524         {
       
  3525         CXnDomNode* dnode = static_cast< CXnDomNode* >( children.Item( i ) );
       
  3526         const TDesC8& type = dnode->Name();
       
  3527         if ( type == XnPropertyNames::action::KProperty )
       
  3528             {
       
  3529             const TDesC8& id = dnode->AttributeValue( KId );
       
  3530             CXnNode* node = aEngine.FindNodeByIdL( id, aThis->Namespace() );
       
  3531             if ( node )
       
  3532                 {
       
  3533                 node->UnsetStateL( XnPropertyNames::style::common::KActive );
       
  3534                 }
       
  3535             }
       
  3536         }
       
  3537     }
       
  3538 
       
  3539 // -----------------------------------------------------------------------------
       
  3540 // RunSystemSetPCDataL
       
  3541 // -----------------------------------------------------------------------------
       
  3542 //
       
  3543 static void RunSystemSetPCDataL(
       
  3544     CXnNodeImpl* aThis,
       
  3545     CXnUiEngine& aEngine,
       
  3546     const TDesC8& aId,
       
  3547     const TDesC8& aData )
       
  3548     {
       
  3549     CXnNode* node = aEngine.FindNodeByIdL( aId, aThis->Namespace() );
       
  3550 
       
  3551     if ( node )
       
  3552         {
       
  3553         node->SetPCDataL( aData );
       
  3554         }
       
  3555     }
       
  3556 
       
  3557 // -----------------------------------------------------------------------------
       
  3558 // GetNumberValues
       
  3559 // -----------------------------------------------------------------------------
       
  3560 //
       
  3561 static void GetNumberValues(
       
  3562     const TDesC8& aData,
       
  3563     TReal& aNumber,
       
  3564     CXnDomPropertyValue::TPrimitiveValueType& aValueType )
       
  3565     {
       
  3566     TLex8 lex( aData );
       
  3567     lex.Val( aNumber );
       
  3568     TPtrC8 rest = lex.Remainder();
       
  3569     if ( rest.FindF( _L8( "%" ) ) != KErrNotFound )
       
  3570         {
       
  3571         aValueType = CXnDomPropertyValue::EPercentage;
       
  3572         }
       
  3573     else if (rest.FindF( _L8( "em" ) ) != KErrNotFound )
       
  3574         {
       
  3575         aValueType = CXnDomPropertyValue::EEms;
       
  3576         }
       
  3577     else if ( rest.FindF( _L8( "ex" ) ) != KErrNotFound )
       
  3578         {
       
  3579         aValueType = CXnDomPropertyValue::EExs;
       
  3580         }
       
  3581     else if ( rest.FindF( _L8( "px" ) ) != KErrNotFound )
       
  3582         {
       
  3583         aValueType = CXnDomPropertyValue::EPx;
       
  3584         }
       
  3585     else if ( rest.FindF( _L8( "u" ) ) != KErrNotFound )
       
  3586         {
       
  3587         aValueType = CXnDomPropertyValue::EUnitValue;
       
  3588         }
       
  3589     else if ( rest.FindF( _L8( "cm" ) ) != KErrNotFound )
       
  3590         {
       
  3591         aValueType = CXnDomPropertyValue::ECm;
       
  3592         }
       
  3593     else if ( rest.FindF( _L8( "mm" ) ) != KErrNotFound )
       
  3594         {
       
  3595         aValueType = CXnDomPropertyValue::EMm;
       
  3596         }
       
  3597     else if ( rest.FindF( _L8( "in" ) ) != KErrNotFound )
       
  3598         {
       
  3599         aValueType = CXnDomPropertyValue::EIn;
       
  3600         }
       
  3601     else if ( rest.FindF( _L8( "pt" ) ) != KErrNotFound )
       
  3602         {
       
  3603         aValueType = CXnDomPropertyValue::EPt;
       
  3604         }
       
  3605     else if ( rest.FindF( _L8( "pc" ) ) != KErrNotFound )
       
  3606         {
       
  3607         aValueType = CXnDomPropertyValue::EPc;
       
  3608         }
       
  3609     else
       
  3610         {
       
  3611         aValueType = CXnDomPropertyValue::ENumber;
       
  3612         }
       
  3613     }
       
  3614 
       
  3615 // -----------------------------------------------------------------------------
       
  3616 // RunSystemSetNumberL
       
  3617 // -----------------------------------------------------------------------------
       
  3618 //
       
  3619 static void RunSystemSetNumberL(
       
  3620     CXnUiEngine& aEngine,
       
  3621     CXnNode* aNode,
       
  3622     const TDesC8& aName,
       
  3623     const RPointerArray< HBufC8 >& aValues )
       
  3624     {
       
  3625     if ( aNode )
       
  3626         {
       
  3627         CXnDomStringPool& sp = aEngine.ODT()->DomDocument().StringPool();
       
  3628         CXnDomProperty* prop = CXnDomProperty::NewL( aName, sp );
       
  3629         CleanupStack::PushL( prop );
       
  3630 
       
  3631         for ( TInt i = 0; i < aValues.Count(); i++ )
       
  3632             {
       
  3633             const TDesC8& value = ( *aValues[i] );
       
  3634 
       
  3635             CXnDomPropertyValue* propVal = CXnDomPropertyValue::NewL( sp );
       
  3636             CleanupStack::PushL( propVal );
       
  3637 
       
  3638             CXnDomPropertyValue::TPrimitiveValueType type;
       
  3639             TReal realValue;
       
  3640 
       
  3641             GetNumberValues( value, realValue, type );
       
  3642             propVal->SetFloatValueL( type, realValue );
       
  3643 
       
  3644             prop->PropertyValueList().AddItemL( propVal );
       
  3645             CleanupStack::Pop( propVal );
       
  3646             }
       
  3647 
       
  3648         CXnProperty* propertyValue = CXnProperty::NewL( prop );
       
  3649 
       
  3650         CleanupStack::Pop( prop );
       
  3651         CleanupStack::PushL( propertyValue );
       
  3652 
       
  3653         aNode->SetPropertyL( propertyValue );
       
  3654 
       
  3655         CleanupStack::Pop( propertyValue );
       
  3656         }
       
  3657     }
       
  3658 
       
  3659 // -----------------------------------------------------------------------------
       
  3660 // RunSystemSetRGBL
       
  3661 // -----------------------------------------------------------------------------
       
  3662 //
       
  3663 static void RunSystemSetRGBL(
       
  3664     CXnUiEngine& aEngine,
       
  3665     CXnNode* aNode,
       
  3666     const TDesC8& aName,
       
  3667     const RPointerArray< HBufC8 >& aValues )
       
  3668     {
       
  3669     if ( aNode )
       
  3670         {
       
  3671         CXnDomStringPool& sp = aEngine.ODT()->DomDocument().StringPool();
       
  3672         CXnDomProperty* prop = CXnDomProperty::NewL( aName, sp );
       
  3673         CleanupStack::PushL( prop );
       
  3674 
       
  3675         for ( TInt i = 0; i < aValues.Count(); i++ )
       
  3676             {
       
  3677             const TDesC8& value = ( *aValues[i] );
       
  3678 
       
  3679             CXnDomPropertyValue* propVal = CXnDomPropertyValue::NewL( sp );
       
  3680             CleanupStack::PushL( propVal );
       
  3681 
       
  3682             TRgb rgb;
       
  3683 
       
  3684             if ( CXnUtils::GetRgbValue( rgb, value ) )
       
  3685                 {
       
  3686                 propVal->SetRgbColorL( rgb );
       
  3687                 prop->PropertyValueList().AddItemL( propVal );
       
  3688                 CleanupStack::Pop( propVal );
       
  3689                 }
       
  3690             else
       
  3691                 {
       
  3692                 CleanupStack::PopAndDestroy( propVal );
       
  3693                 }
       
  3694             }
       
  3695 
       
  3696         CXnProperty* propertyValue = CXnProperty::NewL( prop );
       
  3697 
       
  3698         CleanupStack::Pop( prop );
       
  3699         CleanupStack::PushL( propertyValue );
       
  3700 
       
  3701         aNode->SetPropertyL( propertyValue );
       
  3702 
       
  3703         CleanupStack::Pop( propertyValue );
       
  3704         }
       
  3705     }
       
  3706 
       
  3707 // -----------------------------------------------------------------------------
       
  3708 // RunSystemSetStringL
       
  3709 // -----------------------------------------------------------------------------
       
  3710 //
       
  3711 static void RunSystemSetStringL(
       
  3712     CXnUiEngine& aEngine,
       
  3713     CXnNode* aNode,
       
  3714     const TDesC8& aName,
       
  3715     const RPointerArray< HBufC8 >& aValues,
       
  3716     const CXnDomPropertyValue::TPrimitiveValueType aValueType )
       
  3717     {
       
  3718     if ( aNode )
       
  3719         {
       
  3720         CXnDomStringPool& sp = aEngine.ODT()->DomDocument().StringPool();
       
  3721         CXnDomProperty* prop = CXnDomProperty::NewL( aName, sp );
       
  3722         CleanupStack::PushL( prop );
       
  3723 
       
  3724         for ( TInt i = 0; i < aValues.Count(); i++ )
       
  3725             {
       
  3726             const TDesC8& value = ( *aValues[i] );
       
  3727 
       
  3728             CXnDomPropertyValue* propVal = CXnDomPropertyValue::NewL( sp );
       
  3729             CleanupStack::PushL( propVal );
       
  3730 
       
  3731             propVal->SetStringValueL( aValueType, value );
       
  3732             prop->PropertyValueList().AddItemL( propVal );
       
  3733             CleanupStack::Pop( propVal );
       
  3734             }
       
  3735 
       
  3736         CXnProperty* propertyValue = CXnProperty::NewL( prop );
       
  3737 
       
  3738         CleanupStack::Pop( prop );
       
  3739         CleanupStack::PushL( propertyValue );
       
  3740 
       
  3741         aNode->SetPropertyL( propertyValue );
       
  3742 
       
  3743         CleanupStack::Pop( propertyValue );
       
  3744         }
       
  3745     }
       
  3746 
       
  3747 // -----------------------------------------------------------------------------
       
  3748 // RunResetStylusCounterL
       
  3749 // -----------------------------------------------------------------------------
       
  3750 //
       
  3751 static void RunResetStylusCounterL(
       
  3752     CXnNodeImpl* aThis,
       
  3753     CXnUiEngine& aEngine,
       
  3754     const TDesC8& aId )
       
  3755     {
       
  3756     CXnNode* node( aEngine.FindNodeByIdL( aId, aThis->Namespace() ) );
       
  3757 
       
  3758     if ( node )
       
  3759         {
       
  3760         CXnControlAdapter* adapter( node->Control() );
       
  3761 
       
  3762         if ( adapter )
       
  3763             {
       
  3764             adapter->ResetStylusCounter();
       
  3765             }
       
  3766         }
       
  3767     }
       
  3768 
       
  3769 // -----------------------------------------------------------------------------
       
  3770 // GetSystemSetDataL
       
  3771 // -----------------------------------------------------------------------------
       
  3772 //
       
  3773 static void GetSystemSetDataL(
       
  3774     CXnDomNode& aDomNode,
       
  3775     HBufC8*& aId,
       
  3776     const TDesC8** aPseudoClass,
       
  3777     const TDesC8** aName,
       
  3778     RPointerArray< HBufC8 >* aValues,
       
  3779     const TDesC8** aType,
       
  3780     TBool aSettings,
       
  3781     const TDesC8& aProvidedId,
       
  3782     const TDesC8** aClassId )
       
  3783     {
       
  3784     CXnDomList& children = aDomNode.ChildNodes();
       
  3785 
       
  3786     if ( aSettings )
       
  3787         {
       
  3788         aId = aProvidedId.AllocL();
       
  3789         }
       
  3790 
       
  3791     TInt count = children.Length();
       
  3792 
       
  3793     for ( TInt i = 0; i < count; ++i )
       
  3794         {
       
  3795         CXnDomNode* node = static_cast< CXnDomNode* >( children.Item( i ) );
       
  3796         const TDesC8& nodeType = node->Name();
       
  3797 
       
  3798         if ( nodeType == XnPropertyNames::action::KProperty )
       
  3799             {
       
  3800             const TDesC8& name = node->AttributeValue(
       
  3801                 XnPropertyNames::action::event::systemset::KName );
       
  3802             const TDesC8& value = node->AttributeValue(
       
  3803                 XnPropertyNames::action::event::systemset::KValue );
       
  3804 
       
  3805             if ( !aSettings &&
       
  3806                  ( name == XnPropertyNames::action::event::systemset::KId ) )
       
  3807                 {
       
  3808                 HBufC8* utfName = HBufC8::NewL( value.Length() );
       
  3809                 TPtr8 ptr = utfName->Des();
       
  3810                 ptr = value;
       
  3811                 aId = utfName;
       
  3812                 }
       
  3813             else if ( name == XnPropertyNames::action::event::systemset::KPseudoClass )
       
  3814                 {
       
  3815                 *aPseudoClass = &value;
       
  3816                 }
       
  3817             else if ( name == XnPropertyNames::action::event::systemset::KName )
       
  3818                 {
       
  3819                 *aName = &value;
       
  3820                 }
       
  3821             else if ( name == XnPropertyNames::action::event::systemset::KValue )
       
  3822                 {
       
  3823                 if ( aValues )
       
  3824                     {
       
  3825                     HBufC8* valueH = HBufC8::NewLC( value.Length() + KUnitMaxLen );
       
  3826                     TPtr8 ptr( valueH->Des() );
       
  3827                     ptr.Append( value );
       
  3828                     aValues->AppendL( valueH );     //take ownership
       
  3829                     CleanupStack::Pop( valueH );
       
  3830                     }
       
  3831                 }
       
  3832             else if ( name == XnPropertyNames::action::event::systemset::KType )
       
  3833                 {
       
  3834                 *aType = &value;
       
  3835                 }
       
  3836             else if ( name == XnPropertyNames::action::event::systemset::KUnit )
       
  3837                 {
       
  3838                 if ( value.Length() > KUnitMaxLen )
       
  3839                     {
       
  3840 #ifdef _XN_DEBUG_
       
  3841                     RDebug::Print( _L( "xnnodeimpl GetSystemSetDataL - unexpected length of type string" ) );
       
  3842 #endif
       
  3843                     User::Leave( KErrNotSupported );
       
  3844                     }
       
  3845                 if ( aValues )
       
  3846                     {
       
  3847                     TInt index = aValues->Count() - 1;
       
  3848                     HBufC8* valueH = ( *aValues )[index];
       
  3849                     TPtr8 ptr( valueH->Des() );
       
  3850                     ptr.Append( value );
       
  3851                     }
       
  3852                 }
       
  3853             else if ( name == XnPropertyNames::action::event::systemset::KClass )
       
  3854                 {
       
  3855                 *aClassId = &value;
       
  3856                 }
       
  3857             }
       
  3858         }
       
  3859     }
       
  3860 
       
  3861 // -----------------------------------------------------------------------------
       
  3862 // RunTryDisplayingMenuL
       
  3863 // -----------------------------------------------------------------------------
       
  3864 //
       
  3865 static void RunTryDisplayingMenuL( CXnUiEngine& aEngine, CXnDomNode& aEventNode )
       
  3866     {
       
  3867     CXnNode* menubar( aEngine.MenuBarNode() );
       
  3868 
       
  3869     if ( menubar )
       
  3870         {
       
  3871         CXnDomList& children( aEventNode.ChildNodes() );
       
  3872 
       
  3873         TInt count( children.Length() );
       
  3874 
       
  3875         for ( TInt i = 0; i < count; ++i )
       
  3876             {
       
  3877             CXnDomNode* node = static_cast< CXnDomNode* >( children.Item( i ) );
       
  3878 
       
  3879             const TDesC8& type( node->Name() );
       
  3880 
       
  3881             if ( type == XnPropertyNames::action::KProperty )
       
  3882                 {
       
  3883                 const TDesC8& id( node->AttributeValue( XnPropertyNames::action::KValue ) );
       
  3884 
       
  3885                 if ( id != KNullDesC8 )
       
  3886                     {
       
  3887                     HBufC* menuId( CnvUtfConverter::ConvertToUnicodeFromUtf8L( id ) );
       
  3888                     CleanupStack::PushL( menuId );
       
  3889 
       
  3890                     XnMenuInterface::MXnMenuInterface* menuIf( NULL );
       
  3891                     XnComponentInterface::MakeInterfaceL( menuIf, menubar->AppIfL() );
       
  3892 
       
  3893                     if ( menuIf )
       
  3894                         {
       
  3895                         menuIf->TryDisplayingMenuBarL( *menuId );
       
  3896                         }
       
  3897 
       
  3898                     CleanupStack::PopAndDestroy( menuId );
       
  3899                     }
       
  3900                 }
       
  3901             }
       
  3902         }
       
  3903     }
       
  3904 
       
  3905 // -----------------------------------------------------------------------------
       
  3906 // RunTryDisplayingListQueryDialogL
       
  3907 // -----------------------------------------------------------------------------
       
  3908 //
       
  3909 static void RunTryDisplayingListQueryDialogL(
       
  3910     CXnNodeImpl* aThis,
       
  3911     CXnUiEngine& aEngine,
       
  3912     CXnDomNode& aEventNode )
       
  3913     {
       
  3914     CXnDomList& children( aEventNode.ChildNodes() );
       
  3915 
       
  3916     TInt count( children.Length() );
       
  3917 
       
  3918     if ( count > 0 )
       
  3919         {
       
  3920         CXnDomNode* node = static_cast< CXnDomNode* >( children.Item( 0 ) );
       
  3921 
       
  3922         const TDesC8& type( node->Name() );
       
  3923 
       
  3924         if ( type == XnPropertyNames::action::KProperty )
       
  3925             {
       
  3926             const TDesC8& id(
       
  3927                 node->AttributeValue( XnPropertyNames::action::KValue ) );
       
  3928 
       
  3929             if ( id != KNullDesC8 )
       
  3930                 {
       
  3931                 CXnNode* dialog( aEngine.FindNodeByIdL( id, aThis->Namespace() ) );
       
  3932 
       
  3933                 if ( dialog && dialog->Type()->Type() == XnPropertyNames::listquerydialog::KListQueryDialog )
       
  3934                     {
       
  3935                     CXnListQueryDialogAdapter* adapter = 
       
  3936                         static_cast< CXnListQueryDialogAdapter* > ( dialog->Control() );                
       
  3937                     
       
  3938                     adapter->TryDisplayingDialogL();
       
  3939                     }
       
  3940                 
       
  3941                 }
       
  3942             }
       
  3943         }
       
  3944     }
       
  3945 
       
  3946 // -----------------------------------------------------------------------------
       
  3947 // RunTryDisplayingStylusPopupL
       
  3948 // -----------------------------------------------------------------------------
       
  3949 //
       
  3950 static void RunTryDisplayingStylusPopupL(
       
  3951     CXnNodeImpl* aThis,
       
  3952     CXnNode& aNode,
       
  3953     CXnUiEngine& aEngine,
       
  3954     CXnDomNode& aEventNode )
       
  3955     {    
       
  3956     CXnDomList& children( aEventNode.ChildNodes() );
       
  3957 
       
  3958     TInt count( children.Length() );
       
  3959 
       
  3960     if ( count > 0 )
       
  3961         {
       
  3962         CXnDomNode* node = static_cast< CXnDomNode* >( children.Item( 0 ) );
       
  3963 
       
  3964         const TDesC8& type( node->Name() );
       
  3965 
       
  3966         if ( type == XnPropertyNames::action::KProperty )
       
  3967             {
       
  3968             const TDesC8& id( node->AttributeValue(
       
  3969                 XnPropertyNames::action::KValue ) );
       
  3970 
       
  3971             if ( id != KNullDesC8 )
       
  3972                 {
       
  3973                 CXnNode* popup( aEngine.FindNodeByIdL( id, aThis->Namespace() ) );
       
  3974 
       
  3975                 if ( popup && popup->Type()->Type() == _L8("styluspopup") )
       
  3976                     {
       
  3977                     CXnPopupControlAdapter* adapter = 
       
  3978                         static_cast< CXnPopupControlAdapter* > ( popup->Control() );                
       
  3979                     
       
  3980                     adapter->TryDisplayingStylusPopupL( aNode );                                       
       
  3981                     }
       
  3982                 }
       
  3983             }
       
  3984         }
       
  3985     }
       
  3986 
       
  3987 // -----------------------------------------------------------------------------
       
  3988 // RunSetInitialFocusL
       
  3989 // -----------------------------------------------------------------------------
       
  3990 //
       
  3991 static void RunSetInitialFocusL( CXnUiEngine& aEngine )
       
  3992     {    
       
  3993     TBool editState( aEngine.EditMode()->EditState() );
       
  3994     
       
  3995     CXnViewManager* manager( aEngine.ViewManager() );
       
  3996         
       
  3997     RPointerArray< CXnNode >& pluginNodes( manager->PluginNodes() );
       
  3998 
       
  3999     if ( editState )
       
  4000         {
       
  4001         TBool pluginFocused( EFalse );
       
  4002         
       
  4003         for ( TInt i = 0; i < pluginNodes.Count(); i++ )
       
  4004             {
       
  4005             CXnNode* node( pluginNodes[i] );
       
  4006             
       
  4007             if ( node->IsStateSet( XnPropertyNames::style::common::KFocus ) )
       
  4008                 {
       
  4009                 pluginFocused = ETrue;
       
  4010                 break;
       
  4011                 }
       
  4012             }
       
  4013         
       
  4014         if ( !pluginFocused )
       
  4015             {
       
  4016             for ( TInt i = 0; i < pluginNodes.Count(); i++ )
       
  4017                 {
       
  4018                 CXnNode* node( pluginNodes[i] );
       
  4019                 
       
  4020                 node->SetStateWithoutNotificationL(
       
  4021                     XnPropertyNames::style::common::KFocus );
       
  4022     
       
  4023                 if ( node->IsStateSet( 
       
  4024                     XnPropertyNames::style::common::KFocus ) )
       
  4025                     {
       
  4026                     break;
       
  4027                     }
       
  4028                 }
       
  4029             }
       
  4030         }
       
  4031     else
       
  4032         {
       
  4033         CXnViewData& viewData( manager->ActiveViewData() );
       
  4034         
       
  4035         RPointerArray< CXnPluginData > plugins;
       
  4036         CleanupClosePushL( plugins );
       
  4037 
       
  4038         for( TInt i = 0; i < pluginNodes.Count(); i++ )
       
  4039             {
       
  4040             CXnPluginData& data( viewData.Plugin( pluginNodes[i] ) );
       
  4041             
       
  4042             if( data.Occupied() )
       
  4043                 {
       
  4044                 plugins.AppendL( &data );
       
  4045                 }
       
  4046             }
       
  4047         
       
  4048         plugins.Append( &viewData );
       
  4049             
       
  4050         RPointerArray< CXnNode > list;
       
  4051         CleanupClosePushL( list );
       
  4052 
       
  4053         for( TInt i = 0; i < plugins.Count(); i++ )
       
  4054             {
       
  4055             plugins[i]->InitialFocusNodesL( list );
       
  4056             }
       
  4057                
       
  4058         for ( TInt i = 0; i < list.Count(); i++ )
       
  4059             {
       
  4060             CXnNode* node( list[i] );
       
  4061 
       
  4062             node->SetStateWithoutNotificationL(
       
  4063                 XnPropertyNames::style::common::KFocus );
       
  4064 
       
  4065             if ( node->IsStateSet( XnPropertyNames::style::common::KFocus ) )
       
  4066                 {
       
  4067                 break;
       
  4068                 }
       
  4069             }
       
  4070 
       
  4071         CleanupStack::PopAndDestroy( 2, &plugins ); // list         
       
  4072         }
       
  4073     }
       
  4074 
       
  4075 // -----------------------------------------------------------------------------
       
  4076 // RunSystemSetL
       
  4077 // -----------------------------------------------------------------------------
       
  4078 //
       
  4079 static void RunSystemSetL(
       
  4080     CXnNodeImpl* aThis,
       
  4081     CXnUiEngine& aEngine,
       
  4082     CXnDomNode& aEventNode,
       
  4083     TBool aSettings,
       
  4084     const TDesC8& aId )
       
  4085     {
       
  4086     HBufC8* id = NULL;
       
  4087     const TDesC8* pseudoClass = NULL;
       
  4088     const TDesC8* name = NULL;
       
  4089     const TDesC8* type = NULL;
       
  4090     const TDesC8* classId = NULL;
       
  4091 
       
  4092     RPointerArray< HBufC8 > values;
       
  4093     CleanupResetAndDestroyPushL( values );
       
  4094 
       
  4095     GetSystemSetDataL(
       
  4096         aEventNode, id, &pseudoClass, &name,
       
  4097         &values, &type, aSettings, aId, &classId );
       
  4098 
       
  4099     CleanupStack::PushL( id );
       
  4100 
       
  4101     if ( !name && id )
       
  4102         {
       
  4103         for ( TInt i = 0; i < values.Count(); i++ )
       
  4104             {
       
  4105             const TDesC8* value = values[i];
       
  4106 
       
  4107             RunSystemSetPCDataL( aThis, aEngine, *id, *value );
       
  4108             }
       
  4109         }
       
  4110     else if ( name && id && type )
       
  4111         {
       
  4112         CXnNode* node = aEngine.FindNodeByIdL( *id, aThis->Namespace() );
       
  4113 
       
  4114         if ( *type == XnPropertyNames::action::event::systemset::type::KString )
       
  4115             {
       
  4116             RunSystemSetStringL(
       
  4117                 aEngine, node, *name, values, CXnDomPropertyValue::EString );
       
  4118             }
       
  4119         else if ( *type ==
       
  4120                   XnPropertyNames::action::event::systemset::type::KNumeric )
       
  4121             {
       
  4122             RunSystemSetNumberL(
       
  4123                 aEngine, node, *name, values );
       
  4124             }
       
  4125         else if ( *type == XnPropertyNames::action::event::systemset::type::KRGB )
       
  4126             {
       
  4127             RunSystemSetRGBL(
       
  4128                 aEngine, node, *name, values );
       
  4129             }
       
  4130         else if ( *type == XnPropertyNames::action::event::systemset::type::KUrl )
       
  4131             {
       
  4132             RunSystemSetStringL(
       
  4133                 aEngine, node, *name, values, CXnDomPropertyValue::EUri );
       
  4134             }
       
  4135         else if ( *type ==
       
  4136                   XnPropertyNames::action::event::systemset::type::KAttribute )
       
  4137             {
       
  4138             RunSystemSetStringL(
       
  4139                 aEngine, node, *name, values, CXnDomPropertyValue::EAttr );
       
  4140             }
       
  4141         }
       
  4142     else if ( name && classId && type )
       
  4143         {
       
  4144         CXnPointerArray* array = aEngine.FindNodeByClassL( *classId );
       
  4145         CleanupStack::PushL( array );
       
  4146 
       
  4147         const TInt count = array->Container().Count();
       
  4148 
       
  4149         for ( TInt i = 0; i < count; ++i )
       
  4150             {
       
  4151             CXnNode* node = static_cast< CXnNode* >(array->Container()[i]);
       
  4152             if ( *type == XnPropertyNames::action::event::systemset::type::KString )
       
  4153                 {
       
  4154                 RunSystemSetStringL(
       
  4155                     aEngine, node, *name, values, CXnDomPropertyValue::EString );
       
  4156                 }
       
  4157             else if ( *type ==
       
  4158                       XnPropertyNames::action::event::systemset::type::KNumeric )
       
  4159                 {
       
  4160                 RunSystemSetNumberL(
       
  4161                     aEngine, node, *name, values );
       
  4162                 }
       
  4163             else if ( *type == XnPropertyNames::action::event::systemset::type::KRGB )
       
  4164                 {
       
  4165                 RunSystemSetRGBL(
       
  4166                     aEngine, node, *name, values );
       
  4167                 }
       
  4168             else if ( *type == XnPropertyNames::action::event::systemset::type::KUrl )
       
  4169                 {
       
  4170                 RunSystemSetStringL(
       
  4171                     aEngine, node, *name, values, CXnDomPropertyValue::EUri );
       
  4172                 }
       
  4173             else if ( *type ==
       
  4174                       XnPropertyNames::action::event::systemset::type::KAttribute )
       
  4175                 {
       
  4176                 RunSystemSetStringL(
       
  4177                     aEngine, node, *name, values, CXnDomPropertyValue::EAttr );
       
  4178                 }
       
  4179             }
       
  4180         CleanupStack::PopAndDestroy( array );
       
  4181         }
       
  4182 
       
  4183     CleanupStack::PopAndDestroy( 2, &values );
       
  4184     }
       
  4185 
       
  4186 // -----------------------------------------------------------------------------
       
  4187 // ResolveTriggerDelayL
       
  4188 // -----------------------------------------------------------------------------
       
  4189 //
       
  4190 static void ResolveTriggerDelayL(
       
  4191     CXnUiEngine& /*aEngine*/,
       
  4192     CXnDomNode& aNode,
       
  4193     TInt& aDelay )
       
  4194     {
       
  4195     CXnDomList& children = aNode.ChildNodes();
       
  4196     for ( TInt i = 0; i < children.Length(); i++ )
       
  4197         {
       
  4198         CXnDomNode* child = static_cast< CXnDomNode* >( children.Item( i ) );
       
  4199         const TDesC8& name = child->AttributeValue( XnPropertyNames::action::KName );
       
  4200         if ( name == XnPropertyNames::action::trigger::KDelay )
       
  4201             {
       
  4202             const TDesC8& value = child->AttributeValue( XnPropertyNames::action::KValue );
       
  4203             if ( value != KNullDesC8 )
       
  4204                 {
       
  4205                 TInt triggerDelay( 0 );
       
  4206                 TLex8 lex;
       
  4207                 lex.Assign( value );
       
  4208                 lex.Val( triggerDelay );
       
  4209                 aDelay = triggerDelay;
       
  4210                 }
       
  4211             }
       
  4212         }
       
  4213     }
       
  4214 
       
  4215 // -----------------------------------------------------------------------------
       
  4216 // RunEventL
       
  4217 // -----------------------------------------------------------------------------
       
  4218 //
       
  4219 static TBool RunEventL(
       
  4220     CXnNodeImpl* aThis,
       
  4221     CXnUiEngine& aEngine,
       
  4222     CXnNode& aNode,
       
  4223     CXnDomNode& aEventNode,
       
  4224     CXnDomNode& aTriggerNode,
       
  4225     CXnNode& aEventData )
       
  4226     {
       
  4227     const TDesC8& nameString( aEventNode.AttributeValue( KName ) );
       
  4228 
       
  4229     if ( nameString == KNullDesC8 )
       
  4230         {
       
  4231         return EFalse;
       
  4232         }
       
  4233 
       
  4234     const TDesC8& system( XnPropertyNames::action::event::KSystemPrefix() );
       
  4235     
       
  4236     if ( nameString.Find( system ) != 0 )
       
  4237         {
       
  4238         // event doesn't contain "system/" prefix         
       
  4239         RunAppUiNotificationL( aEngine, aNode, 
       
  4240             aEventNode, aTriggerNode, aEventData );
       
  4241         }    
       
  4242     else if ( nameString == XnPropertyNames::action::event::KSetFocus )
       
  4243         {
       
  4244         RPointerArray< CXnNode > focusCandidates;
       
  4245         CleanupClosePushL( focusCandidates );
       
  4246 
       
  4247         GetFocusCandidatesL( aThis, aEngine, aEventNode, focusCandidates );
       
  4248 
       
  4249         TBool retval( aNode.RunFocusChangeL( focusCandidates ) );
       
  4250 
       
  4251         CleanupStack::PopAndDestroy( &focusCandidates );
       
  4252 
       
  4253         return retval;
       
  4254         }
       
  4255     else if ( nameString == XnPropertyNames::action::event::KSetInitialFocus )
       
  4256         {
       
  4257         RunSetInitialFocusL( aEngine );
       
  4258         return ETrue;
       
  4259         }
       
  4260     else if ( nameString == XnPropertyNames::action::event::KSet )
       
  4261         {
       
  4262         RunSystemSetL( aThis, aEngine, aEventNode );
       
  4263         return ETrue;
       
  4264         }
       
  4265     else if ( nameString == XnPropertyNames::action::event::KSetPassiveFocus ||
       
  4266               nameString == XnPropertyNames::action::event::KResetPassiveFocus ||
       
  4267               nameString == XnPropertyNames::action::event::KSetActiveFocus )
       
  4268         {
       
  4269         RunPassiveFocusChangeL( aThis, aEngine, aEventNode, nameString );
       
  4270         return ETrue;
       
  4271         }
       
  4272     else if ( nameString == XnPropertyNames::action::event::KClearPassiveFocuses )
       
  4273         {
       
  4274         aEngine.ClearPassiveFocusedNodesL();
       
  4275         return ETrue;
       
  4276         }
       
  4277     else if ( nameString == XnPropertyNames::action::event::KSetEditMode )
       
  4278         {
       
  4279         RunEditL( aThis, aEngine, aEventNode );
       
  4280         return ETrue;
       
  4281         }
       
  4282     else if ( nameString == XnPropertyNames::action::event::KResetEditMode )
       
  4283         {
       
  4284         RunResetEditL( aThis, aEngine, aEventNode );
       
  4285         return ETrue;
       
  4286         }
       
  4287     else if ( nameString == XnPropertyNames::action::event::KResetStylusCounter )
       
  4288         {
       
  4289         HBufC8* id( NULL );
       
  4290 
       
  4291         GetSystemSetDataL( aEventNode, id );
       
  4292         CleanupStack::PushL( id );
       
  4293 
       
  4294         RunResetStylusCounterL( aThis, aEngine, *id );
       
  4295 
       
  4296         CleanupStack::PopAndDestroy( id );
       
  4297 
       
  4298         return EFalse;
       
  4299         }
       
  4300     else if ( nameString == XnPropertyNames::action::event::KRunAddWidgetQuery )
       
  4301         {
       
  4302         aEngine.Editor()->AddWidgetL();
       
  4303         }
       
  4304     else if ( nameString == XnPropertyNames::action::event::KRemoveFocusedWidget )
       
  4305         {
       
  4306         aEngine.Editor()->RemoveWidgetL( aEngine.FocusedNode() );               
       
  4307         }
       
  4308     else if ( nameString == XnPropertyNames::action::event::KRunFullScreenEffect )
       
  4309         {
       
  4310         RunFullScreenEffectL( aEngine, aEventNode );
       
  4311         }
       
  4312     else if ( nameString == XnPropertyNames::action::event::KActivateNextView )
       
  4313         {
       
  4314         RunActivateNextViewL( aEngine );
       
  4315         }
       
  4316     else if ( nameString == XnPropertyNames::action::event::KActivatePreviousView )
       
  4317         {
       
  4318         RunActivatePreviousViewL( aEngine );
       
  4319         }
       
  4320     else if ( nameString == XnPropertyNames::action::event::KAddView )
       
  4321         {
       
  4322         RunAddViewL( aEngine );
       
  4323         }
       
  4324     else if ( nameString == XnPropertyNames::action::event::KRemoveView )
       
  4325         {
       
  4326         RunRemoveViewL( aEngine );
       
  4327         }
       
  4328     else if ( nameString == XnPropertyNames::action::event::KActivateView )
       
  4329         {
       
  4330         RunActivateViewL( aThis, aEngine, aEventNode );
       
  4331         }
       
  4332     else if ( nameString == XnPropertyNames::action::event::KActivate )
       
  4333         {
       
  4334         RunActivateL( aThis, aEngine, aEventNode );
       
  4335         return ETrue;
       
  4336         }
       
  4337     else if ( nameString == XnPropertyNames::action::event::KActivateSelectedItem )
       
  4338         {
       
  4339         CXnNode* focusedNode = aEngine.FocusedNode();
       
  4340         if ( focusedNode )
       
  4341             {
       
  4342             CXnNode* activate = BuildActivateTriggerNodeL( aEngine );
       
  4343             CleanupStack::PushL( activate );
       
  4344             focusedNode->ReportXuikonEventL( *activate );
       
  4345             CleanupStack::PopAndDestroy( activate );
       
  4346             }
       
  4347         return EFalse;
       
  4348         }
       
  4349     else if ( nameString == XnPropertyNames::action::event::KDeactivate )
       
  4350         {
       
  4351         RunDeactivateL( aThis, aEngine, aEventNode );
       
  4352         return ETrue;
       
  4353         }
       
  4354     else if ( nameString == XnPropertyNames::action::event::KExit )
       
  4355         {
       
  4356         RunAppExit( aEngine );
       
  4357         }
       
  4358     else if ( nameString == XnPropertyNames::action::event::KTryDisplayingMenu )
       
  4359         {
       
  4360         RunTryDisplayingMenuL( aEngine, aEventNode );
       
  4361         }
       
  4362     else if ( nameString ==
       
  4363               XnPropertyNames::action::event::KTryDisplayingListQueryDialog )
       
  4364         {
       
  4365         RunTryDisplayingListQueryDialogL( aThis, aEngine, aEventNode );
       
  4366         }
       
  4367     else if ( nameString == XnPropertyNames::action::event::KTryDisplayingStylusPopup )
       
  4368         {
       
  4369         RunTryDisplayingStylusPopupL( aThis, aNode, aEngine, aEventNode );
       
  4370         return ETrue;
       
  4371         }
       
  4372     else if ( nameString == XnPropertyNames::action::event::KToggleWidgetsVisibilty )
       
  4373         {
       
  4374         aEngine.Editor()->ToggleWidgetsVisibiltyL();
       
  4375 
       
  4376         // check if focused widget need to be changed
       
  4377         CXnNode* focused( aEngine.FocusedNode() );
       
  4378 
       
  4379         if ( !focused || !IsNodeNavigableL( focused ) )
       
  4380             {
       
  4381             RunSetInitialFocusL( aEngine );
       
  4382             }
       
  4383 
       
  4384         return ETrue;
       
  4385         }
       
  4386     else if ( nameString == XnPropertyNames::action::event::KReportEnterEditMode ) 
       
  4387             
       
  4388         {
       
  4389         CXnNode* trigger( BuildTriggerNodeL( aEngine,                    
       
  4390             XnPropertyNames::action::trigger::name::KEditMode ) );
       
  4391         CleanupStack::PushL( trigger );
       
  4392 
       
  4393         CXnDomStringPool& sp( aEngine.ODT()->DomDocument().StringPool() );
       
  4394         
       
  4395         CXnProperty* value( CXnProperty::NewL(
       
  4396             XnPropertyNames::action::KValue,
       
  4397             XnPropertyNames::action::trigger::name::editmode::KEnter, 
       
  4398             CXnDomPropertyValue::EString, sp ) );
       
  4399         CleanupStack::PushL( value );
       
  4400         
       
  4401         trigger->SetPropertyL( value );
       
  4402         CleanupStack::Pop( value );
       
  4403 
       
  4404         aEngine.ActiveView()->ReportXuikonEventL( *trigger );
       
  4405         
       
  4406         CleanupStack::PopAndDestroy( trigger );
       
  4407 
       
  4408         return ETrue;
       
  4409         }
       
  4410     else if( nameString == XnPropertyNames::action::event::KReportExitEditMode )
       
  4411         {
       
  4412         CXnNode* trigger( BuildTriggerNodeL( aEngine,                    
       
  4413             XnPropertyNames::action::trigger::name::KEditMode ) );
       
  4414         CleanupStack::PushL( trigger );
       
  4415         
       
  4416         CXnDomStringPool& sp( aEngine.ODT()->DomDocument().StringPool() );
       
  4417         
       
  4418         CXnProperty* value( CXnProperty::NewL(
       
  4419             XnPropertyNames::action::KValue,
       
  4420             XnPropertyNames::action::trigger::name::editmode::KExit, 
       
  4421             CXnDomPropertyValue::EString, sp ) );
       
  4422         CleanupStack::PushL( value );
       
  4423         
       
  4424         trigger->SetPropertyL( value );
       
  4425         CleanupStack::Pop( value );
       
  4426         
       
  4427         aEngine.ActiveView()->ReportXuikonEventL( *trigger );
       
  4428         
       
  4429         CleanupStack::PopAndDestroy( trigger );
       
  4430                 
       
  4431         return ETrue;
       
  4432         }
       
  4433     else if ( nameString == XnPropertyNames::action::event::KRestartTriggerTimer )
       
  4434         {
       
  4435         TInt delay( 0 );
       
  4436 
       
  4437         ResolveTriggerDelayL( aEngine, aEventNode, delay );
       
  4438 
       
  4439         if ( delay > 0 )
       
  4440             {
       
  4441             aNode.RestartTimedTrigger( delay );
       
  4442             }
       
  4443         else
       
  4444             {
       
  4445             TTimeIntervalMicroSeconds32 delayms = aNode.TriggerDelay();
       
  4446             aNode.RestartTimedTrigger( delayms.Int() );
       
  4447             }
       
  4448 
       
  4449         return ETrue;
       
  4450         }
       
  4451     else if ( nameString == XnPropertyNames::action::event::KCancelTriggerTimer )
       
  4452         {
       
  4453         aNode.RestartTimedTrigger();
       
  4454         return ETrue;
       
  4455         }
       
  4456     else if ( nameString == XnPropertyNames::action::event::KSetWallpaper )
       
  4457         {
       
  4458         aEngine.Editor()->SetWallpaperL();
       
  4459         return ETrue;
       
  4460         }
       
  4461            
       
  4462     return EFalse;
       
  4463     }
       
  4464 
       
  4465 // -----------------------------------------------------------------------------
       
  4466 // RunEventsL
       
  4467 // -----------------------------------------------------------------------------
       
  4468 //
       
  4469 static void RunEventsL(
       
  4470     CXnNodeImpl* aThis,
       
  4471     CXnUiEngine& aEngine,
       
  4472     CXnNode& aNode,
       
  4473     CXnDomNode& aActionNode,
       
  4474     CXnDomNode& aTriggerNode,
       
  4475     CXnNode& aEventData )
       
  4476     {
       
  4477     CXnDomList& children = aActionNode.ChildNodes();
       
  4478     TInt count = children.Length();
       
  4479     TBool render = EFalse;
       
  4480     for ( TInt i = 0; i < count; ++i )
       
  4481         {
       
  4482         CXnDomNode* node = static_cast< CXnDomNode* >(children.Item( i ) );
       
  4483         const TDesC8& type = node->Name();
       
  4484         if ( type == XnPropertyNames::action::KEvent )
       
  4485             {
       
  4486             TBool tmp = RunEventL(
       
  4487                 aThis, aEngine, aNode, *node, aTriggerNode, aEventData );
       
  4488             if ( !render )
       
  4489                 {
       
  4490                 render = tmp;
       
  4491                 }
       
  4492             }
       
  4493         }
       
  4494     if ( render )
       
  4495         {
       
  4496         aEngine.RenderUIL( NULL );
       
  4497         }
       
  4498     }
       
  4499 
       
  4500 // -----------------------------------------------------------------------------
       
  4501 // DoMatchTriggerForHighLevelKeyEventL
       
  4502 // -----------------------------------------------------------------------------
       
  4503 //
       
  4504 static TBool DoMatchTriggerForHighLevelKeyEventL(
       
  4505     CXnNode& aNode,
       
  4506     const TKeyEvent& aKeyEvent,
       
  4507     TEventCode aType,
       
  4508     const TDesC8& aHighLevelKey )
       
  4509     {
       
  4510     const TDesC8* key;
       
  4511 
       
  4512     switch ( aKeyEvent.iCode )
       
  4513         {
       
  4514         case EKeyLeftArrow:
       
  4515             key = &XnPropertyNames::action::trigger::name::KLeft;
       
  4516             break;
       
  4517         case EKeyRightArrow:
       
  4518             key = &XnPropertyNames::action::trigger::name::KRight;
       
  4519             break;
       
  4520         case EKeyUpArrow:
       
  4521             key = &XnPropertyNames::action::trigger::name::KUp;
       
  4522             break;
       
  4523         case EKeyDownArrow:
       
  4524             key = &XnPropertyNames::action::trigger::name::KDown;
       
  4525             break;
       
  4526         default:
       
  4527             key = NULL;
       
  4528             break;
       
  4529         }
       
  4530 
       
  4531     if ( !key || aType != EEventKey )
       
  4532         {
       
  4533         return EFalse;
       
  4534         }
       
  4535 
       
  4536     CXnNode* parent( aNode.Parent() );
       
  4537 
       
  4538     if ( !parent || aNode.ViewNodeImpl() )
       
  4539         {
       
  4540         if ( *key == aHighLevelKey )
       
  4541             {
       
  4542             return ETrue;
       
  4543             }
       
  4544         }
       
  4545     else
       
  4546         {
       
  4547         const TDesC8* direction(
       
  4548             &XnPropertyNames::style::common::direction::KLTR );
       
  4549         const TDesC8* orientation(
       
  4550             &XnPropertyNames::style::common::block_progression::KTB );
       
  4551 
       
  4552         CXnProperty* directionProperty( parent->DirectionL() );
       
  4553 
       
  4554         if ( directionProperty )
       
  4555             {
       
  4556             direction = &directionProperty->StringValue();
       
  4557             }
       
  4558 
       
  4559         CXnProperty* orientationProperty( parent->BlockProgressionL() );
       
  4560 
       
  4561         if ( orientationProperty )
       
  4562             {
       
  4563             orientation = &orientationProperty->StringValue();
       
  4564             }
       
  4565 
       
  4566         if ( *direction == XnPropertyNames::style::common::direction::KLTR &&
       
  4567              ( *orientation == XnPropertyNames::style::common::block_progression::KLR ||
       
  4568                *orientation == XnPropertyNames::style::common::block_progression::KRL ) )
       
  4569             {
       
  4570             if ( *key == aHighLevelKey )
       
  4571                 {
       
  4572                 return ETrue;
       
  4573                 }
       
  4574             }
       
  4575         else if ( *direction == XnPropertyNames::style::common::direction::KRTL &&
       
  4576                   ( *orientation == XnPropertyNames::style::common::block_progression::KLR ||
       
  4577                     *orientation == XnPropertyNames::style::common::block_progression::KRL ) )
       
  4578             {
       
  4579             if ( *key == XnPropertyNames::action::trigger::name::KRight &&
       
  4580                  aHighLevelKey == XnPropertyNames::action::trigger::name::KLeft )
       
  4581                 {
       
  4582                 return ETrue;
       
  4583                 }
       
  4584 
       
  4585             if ( *key == XnPropertyNames::action::trigger::name::KLeft &&
       
  4586                  aHighLevelKey == XnPropertyNames::action::trigger::name::KRight )
       
  4587                 {
       
  4588                 return ETrue;
       
  4589                 }
       
  4590 
       
  4591             if ( *key == XnPropertyNames::action::trigger::name::KDown &&
       
  4592                  aHighLevelKey == XnPropertyNames::action::trigger::name::KDown )
       
  4593                 {
       
  4594                 return ETrue;
       
  4595                 }
       
  4596 
       
  4597             if ( *key == XnPropertyNames::action::trigger::name::KUp &&
       
  4598                  aHighLevelKey == XnPropertyNames::action::trigger::name::KUp )
       
  4599                 {
       
  4600                 return ETrue;
       
  4601                 }
       
  4602             }
       
  4603         else if ( *direction == XnPropertyNames::style::common::direction::KLTR &&
       
  4604                   *orientation == XnPropertyNames::style::common::block_progression::KTB )
       
  4605             {
       
  4606             if ( *key == XnPropertyNames::action::trigger::name::KUp &&
       
  4607                  aHighLevelKey == XnPropertyNames::action::trigger::name::KLeft )
       
  4608                 {
       
  4609                 return ETrue;
       
  4610                 }
       
  4611 
       
  4612             if ( *key == XnPropertyNames::action::trigger::name::KDown &&
       
  4613                  aHighLevelKey == XnPropertyNames::action::trigger::name::KRight )
       
  4614                 {
       
  4615                 return ETrue;
       
  4616                 }
       
  4617 
       
  4618             if ( *key == XnPropertyNames::action::trigger::name::KLeft &&
       
  4619                  aHighLevelKey == XnPropertyNames::action::trigger::name::KDown )
       
  4620                 {
       
  4621                 return ETrue;
       
  4622                 }
       
  4623 
       
  4624             if ( *key == XnPropertyNames::action::trigger::name::KRight &&
       
  4625                  aHighLevelKey == XnPropertyNames::action::trigger::name::KUp )
       
  4626                 {
       
  4627                 return ETrue;
       
  4628                 }
       
  4629             }
       
  4630         else if ( *direction == XnPropertyNames::style::common::direction::KRTL &&
       
  4631                   *orientation == XnPropertyNames::style::common::block_progression::KTB )
       
  4632             {
       
  4633             if ( *key == XnPropertyNames::action::trigger::name::KDown &&
       
  4634                  aHighLevelKey == XnPropertyNames::action::trigger::name::KLeft )
       
  4635                 {
       
  4636                 return ETrue;
       
  4637                 }
       
  4638 
       
  4639             if ( *key == XnPropertyNames::action::trigger::name::KUp &&
       
  4640                  aHighLevelKey == XnPropertyNames::action::trigger::name::KRight )
       
  4641                 {
       
  4642                 return ETrue;
       
  4643                 }
       
  4644 
       
  4645             if ( *key == XnPropertyNames::action::trigger::name::KLeft &&
       
  4646                  aHighLevelKey == XnPropertyNames::action::trigger::name::KDown )
       
  4647                 {
       
  4648                 return ETrue;
       
  4649                 }
       
  4650 
       
  4651             if ( *key == XnPropertyNames::action::trigger::name::KRight &&
       
  4652                  aHighLevelKey == XnPropertyNames::action::trigger::name::KUp )
       
  4653                 {
       
  4654                 return ETrue;
       
  4655                 }
       
  4656             }
       
  4657         }
       
  4658 
       
  4659     return EFalse;
       
  4660     }
       
  4661 
       
  4662 // -----------------------------------------------------------------------------
       
  4663 // MatchActionForKeyEventL
       
  4664 // -----------------------------------------------------------------------------
       
  4665 //
       
  4666 static TBool MatchActionForKeyEventL(
       
  4667     CXnNodeImpl* aThis,
       
  4668     CXnUiEngine& aEngine,
       
  4669     CXnNode& aNode,
       
  4670     const TKeyEvent& aKeyEvent, TEventCode aType,
       
  4671     CXnDomNode& aActionNode )
       
  4672     {
       
  4673     CXnDomList& children = aActionNode.ChildNodes();
       
  4674     TInt count = children.Length();
       
  4675     for ( TInt i = 0; i < count; ++i )
       
  4676         {
       
  4677         CXnDomNode* node = static_cast< CXnDomNode* >( children.Item( i ) );
       
  4678         const TDesC8& type = node->Name();
       
  4679         if ( type == XnPropertyNames::action::KTrigger )
       
  4680             {
       
  4681             if ( node && ( IsTriggerRunnableL( *node ) || IsTriggerActiveL( *node ) ) )
       
  4682                 {
       
  4683                 TBool match = MatchTriggerForKeyEventL(
       
  4684                     aThis, aEngine, aNode, aKeyEvent, aType, aActionNode, *node );
       
  4685                 if ( match )
       
  4686                     {
       
  4687                     return match;
       
  4688                     }
       
  4689                 }
       
  4690             }
       
  4691         }
       
  4692     return EFalse;
       
  4693     }
       
  4694 
       
  4695 // -----------------------------------------------------------------------------
       
  4696 // IsTriggerActiveL
       
  4697 // -----------------------------------------------------------------------------
       
  4698 //
       
  4699 static TBool IsTriggerActiveL( CXnDomNode& aNode )
       
  4700     {
       
  4701     CXnDomList& propList = aNode.PropertyList();
       
  4702     TInt count = propList.Length();
       
  4703     for ( TInt j = 0; j < count; j++ )
       
  4704         {
       
  4705         CXnDomProperty* prop = static_cast< CXnDomProperty* >( propList.Item( j ) );
       
  4706         const TDesC8& propName = prop->Name();
       
  4707         if ( propName == XnPropertyNames::style::common::KDisplay )
       
  4708             {
       
  4709             CXnDomList& propValList = prop->PropertyValueList();
       
  4710             TInt propValCount(propValList.Length());
       
  4711             for ( TInt k = 0; k < propValCount; k++ )
       
  4712                 {
       
  4713                 CXnDomPropertyValue* propVal =
       
  4714                     static_cast< CXnDomPropertyValue* >( propValList.Item( k ) );
       
  4715                 CXnDomPropertyValue::TPrimitiveValueType type =
       
  4716                     propVal->PrimitiveValueType();
       
  4717                 switch ( type )
       
  4718                     {
       
  4719                     case CXnDomPropertyValue::EString:
       
  4720                     case CXnDomPropertyValue::EIdent:
       
  4721                     case CXnDomPropertyValue::EUri:
       
  4722                     case CXnDomPropertyValue::EAttr:
       
  4723                     case CXnDomPropertyValue::EUnknown:
       
  4724                         {
       
  4725                         const TDesC8& value = propVal->StringValueL();
       
  4726                         if ( value == XnPropertyNames::style::common::display::KNone )
       
  4727                             {
       
  4728                             return EFalse;
       
  4729                             }
       
  4730                         else
       
  4731                             {
       
  4732                             return ETrue;
       
  4733                             }
       
  4734                         }
       
  4735                     }
       
  4736                 }
       
  4737             }
       
  4738         }
       
  4739     return ETrue;
       
  4740     }
       
  4741 
       
  4742 // -----------------------------------------------------------------------------
       
  4743 // MatchActionForEventL
       
  4744 // -----------------------------------------------------------------------------
       
  4745 //
       
  4746 static TBool MatchActionForEventL(
       
  4747     CXnNodeImpl* aThis,
       
  4748     CXnUiEngine& aEngine,
       
  4749     CXnNode& aNode,
       
  4750     CXnNode& aEventData,
       
  4751     CXnDomNode& aActionNode,
       
  4752     TInt aSource )
       
  4753     {
       
  4754     CXnDomList& children = aActionNode.ChildNodes();
       
  4755     TInt count = children.Length();
       
  4756     for ( TInt i = 0; i < count; ++i )
       
  4757         {
       
  4758         CXnDomNode* node = static_cast< CXnDomNode* >( children.Item( i ) );
       
  4759         const TDesC8& type = node->Name();
       
  4760         if ( type == XnPropertyNames::action::KTrigger &&
       
  4761              node && IsTriggerRunnableL( *node ) )
       
  4762             {
       
  4763             TBool match = MatchTriggerForEventL(
       
  4764                 aThis, aEngine, aNode, aEventData, aActionNode, *node, aSource );
       
  4765             if ( match )
       
  4766                 {
       
  4767                 return match;
       
  4768                 }
       
  4769             }
       
  4770         }
       
  4771     return EFalse;
       
  4772     }
       
  4773 
       
  4774 // -----------------------------------------------------------------------------
       
  4775 // FindLoopedFocusableNodeL
       
  4776 // -----------------------------------------------------------------------------
       
  4777 //
       
  4778 static CXnNode* FindLoopedFocusableNodeL( CXnNode& aNode, TBool aForward )
       
  4779     {
       
  4780     if ( aNode.ViewNodeImpl() )
       
  4781         {
       
  4782         return NULL;
       
  4783         }
       
  4784     CXnNode* nextNode = NULL;
       
  4785     CXnProperty* navLoopProperty = aNode.GetPropertyL(
       
  4786         XnPropertyNames::style::common::KS60NavLooping );
       
  4787     if ( navLoopProperty )
       
  4788         {
       
  4789         const TDesC8& loopValue = navLoopProperty->StringValue();
       
  4790         if ( loopValue != KNullDesC8 &&
       
  4791              loopValue == XnPropertyNames::grid::s60_focus_looping::KStop )
       
  4792             {
       
  4793             return NULL;
       
  4794             }
       
  4795         }
       
  4796     if ( aForward )
       
  4797         {
       
  4798         nextNode = ForwardLoopL( aNode );
       
  4799         }
       
  4800     else
       
  4801         {
       
  4802         nextNode = BackwardLoopL( aNode );
       
  4803         }
       
  4804     return nextNode;
       
  4805     }
       
  4806 
       
  4807 // -----------------------------------------------------------------------------
       
  4808 // GetNavIndexL
       
  4809 // -----------------------------------------------------------------------------
       
  4810 //
       
  4811 static CXnDomPropertyValue* GetNavIndexL( CXnNode& aNode )
       
  4812     {
       
  4813     CXnProperty* navIndexProperty = aNode.NavIndexL();
       
  4814     CXnDomPropertyValue* value = NULL;
       
  4815     if ( navIndexProperty )
       
  4816         {
       
  4817         value = static_cast< CXnDomPropertyValue* >(
       
  4818             navIndexProperty->Property()->PropertyValueList().Item( 0 ) );
       
  4819         }
       
  4820     return value;
       
  4821     }
       
  4822 
       
  4823 // -----------------------------------------------------------------------------
       
  4824 // ForwardL
       
  4825 // -----------------------------------------------------------------------------
       
  4826 //
       
  4827 static CXnNode* ForwardL( CXnNode& aNode )
       
  4828     {
       
  4829     RPointerArray< CXnNode >& siblings = aNode.Parent()->Children();
       
  4830     CXnNode* nextNode = NULL;
       
  4831     CXnDomPropertyValue* navIndexValue = GetNavIndexL( aNode );
       
  4832     CXnDomPropertyValue* prevIndexValue = NULL;
       
  4833     CXnDomPropertyValue* tmpIndexValue = NULL;
       
  4834     TInt count = siblings.Count();
       
  4835     TInt nodePosition = count;
       
  4836     TBool first = ETrue;
       
  4837     for ( TInt i = 0; i < count; ++i )
       
  4838         {
       
  4839         CXnNode* tmpNode = siblings[i];
       
  4840         if ( tmpNode == &aNode )
       
  4841             {
       
  4842             nodePosition = i;
       
  4843             continue;
       
  4844             }
       
  4845         if ( !IsNodeNavigableL( *tmpNode ) )
       
  4846             {
       
  4847             continue;
       
  4848             }
       
  4849         tmpIndexValue = GetNavIndexL( *tmpNode );
       
  4850         if ( tmpIndexValue )
       
  4851             {
       
  4852             if ( tmpIndexValue->IsNoneIdent() )
       
  4853                 {
       
  4854                 // nav index set as none, skipping
       
  4855                 continue;
       
  4856                 }
       
  4857             }
       
  4858         if ( ( CompareNavIndexesL( tmpIndexValue, navIndexValue ) == 0 ) &&
       
  4859              ( first ||
       
  4860                ( CompareNavIndexesL( tmpIndexValue, prevIndexValue ) < 0 ) ) &&
       
  4861              ( i > nodePosition ) )
       
  4862             {
       
  4863             first = EFalse;
       
  4864             prevIndexValue = tmpIndexValue;
       
  4865             nextNode = tmpNode;
       
  4866             }
       
  4867         else if ( ( CompareNavIndexesL( tmpIndexValue, navIndexValue ) > 0 ) &&
       
  4868                   ( first ||
       
  4869                     ( CompareNavIndexesL( tmpIndexValue, prevIndexValue ) < 0 ) ) )
       
  4870             {
       
  4871             first = EFalse;
       
  4872             prevIndexValue = tmpIndexValue;
       
  4873             nextNode = tmpNode;
       
  4874             }
       
  4875         }
       
  4876     return nextNode;
       
  4877     }
       
  4878 
       
  4879 // -----------------------------------------------------------------------------
       
  4880 // ForwardLoopL
       
  4881 // -----------------------------------------------------------------------------
       
  4882 //
       
  4883 static CXnNode*  ForwardLoopL( CXnNode& aNode )
       
  4884     {
       
  4885     RPointerArray< CXnNode >& siblings = aNode.Parent()->Children();
       
  4886     CXnNode* nextNode = NULL;
       
  4887     CXnDomPropertyValue* navIndexValue = GetNavIndexL( aNode );
       
  4888     CXnDomPropertyValue* tmpIndexValue = NULL;
       
  4889     CXnDomPropertyValue* prevIndexValue = NULL;
       
  4890     TInt count = siblings.Count();
       
  4891     TInt nodePosition = count;
       
  4892     TBool first = ETrue;
       
  4893     for ( TInt i = 0; i < count; ++i )
       
  4894         {
       
  4895         CXnNode* tmpNode = siblings[i];
       
  4896         if ( tmpNode == &aNode )
       
  4897             {
       
  4898             nodePosition = i;
       
  4899             continue;
       
  4900             }
       
  4901         if ( !IsNodeNavigableL( *tmpNode ) )
       
  4902             {
       
  4903             continue;
       
  4904             }
       
  4905         tmpIndexValue = GetNavIndexL( *tmpNode );
       
  4906         if ( tmpIndexValue )
       
  4907             {
       
  4908             if ( tmpIndexValue->IsNoneIdent() )
       
  4909                 {
       
  4910                 // nav index set as none, skipping
       
  4911                 continue;
       
  4912                 }
       
  4913             }
       
  4914        if ( ( CompareNavIndexesL( navIndexValue, tmpIndexValue ) == 0 ) &&
       
  4915               ( first ||
       
  4916                 ( CompareNavIndexesL( tmpIndexValue, prevIndexValue ) < 0 ) ) &&
       
  4917               ( i < nodePosition ) )
       
  4918             {
       
  4919             first = EFalse;
       
  4920             prevIndexValue = tmpIndexValue;
       
  4921             nextNode = tmpNode;
       
  4922             }
       
  4923         else if ( ( CompareNavIndexesL( tmpIndexValue, navIndexValue ) < 0 ) &&
       
  4924                   ( first ||
       
  4925                     ( CompareNavIndexesL( tmpIndexValue, prevIndexValue ) < 0 ) ) )
       
  4926             {
       
  4927             first = EFalse;
       
  4928             prevIndexValue = tmpIndexValue;
       
  4929             nextNode = tmpNode;
       
  4930             }
       
  4931         }
       
  4932     return nextNode;
       
  4933     }
       
  4934 
       
  4935 // -----------------------------------------------------------------------------
       
  4936 // BackwardL
       
  4937 // -----------------------------------------------------------------------------
       
  4938 //
       
  4939 static CXnNode* BackwardL( CXnNode& aNode )
       
  4940     {
       
  4941     RPointerArray< CXnNode >& siblings = aNode.Parent()->Children();
       
  4942     CXnNode* nextNode = NULL;
       
  4943     CXnDomPropertyValue* navIndexValue = GetNavIndexL( aNode );
       
  4944     CXnDomPropertyValue* tmpIndexValue = NULL;
       
  4945     TInt count = siblings.Count();
       
  4946     CXnDomPropertyValue* nextIndexValue = GetNavIndexL( *siblings[count - 1] );
       
  4947     TInt nodePosition = 0;
       
  4948     TBool first = ETrue;
       
  4949     for ( TInt i = count - 1; i > -1; --i )
       
  4950         {
       
  4951         CXnNode* tmpNode = siblings[i];
       
  4952         if ( tmpNode == &aNode )
       
  4953             {
       
  4954             nodePosition = i;
       
  4955             continue;
       
  4956             }
       
  4957         if ( !IsNodeNavigableL( *tmpNode ) )
       
  4958             {
       
  4959             continue;
       
  4960             }
       
  4961         tmpIndexValue = GetNavIndexL( *tmpNode );
       
  4962         if ( tmpIndexValue )
       
  4963             {
       
  4964             if ( tmpIndexValue->IsNoneIdent() )
       
  4965                 {
       
  4966                 // nav index set as none, skipping
       
  4967                 continue;
       
  4968                 }
       
  4969             }
       
  4970        if ( ( CompareNavIndexesL( navIndexValue, tmpIndexValue ) == 0 ) &&
       
  4971              ( first ||
       
  4972                ( CompareNavIndexesL( tmpIndexValue, nextIndexValue ) > 0 ) ) &&
       
  4973                ( i < nodePosition ) )
       
  4974             {
       
  4975             first = EFalse;
       
  4976             nextIndexValue = tmpIndexValue;
       
  4977             nextNode = tmpNode;
       
  4978             }
       
  4979        else if ( ( CompareNavIndexesL( tmpIndexValue, navIndexValue ) < 0 ) &&
       
  4980                  ( first ||
       
  4981                    ( CompareNavIndexesL( tmpIndexValue, nextIndexValue ) > 0 ) ) )
       
  4982             {
       
  4983             first = EFalse;
       
  4984             nextIndexValue = tmpIndexValue;
       
  4985             nextNode = tmpNode;
       
  4986             }
       
  4987         }
       
  4988     return nextNode;
       
  4989     }
       
  4990 
       
  4991 // -----------------------------------------------------------------------------
       
  4992 // BackwardLoopL
       
  4993 // -----------------------------------------------------------------------------
       
  4994 //
       
  4995 static CXnNode* BackwardLoopL( CXnNode& aNode )
       
  4996     {
       
  4997     RPointerArray<CXnNode>& siblings = aNode.Parent()->Children();
       
  4998     CXnNode* nextNode = NULL;
       
  4999     CXnDomPropertyValue* navIndexValue = GetNavIndexL( aNode );
       
  5000     CXnDomPropertyValue* tmpIndexValue = NULL;
       
  5001     TInt count = siblings.Count();
       
  5002     CXnDomPropertyValue* nextIndexValue = GetNavIndexL( *siblings[count - 1] );
       
  5003     TInt nodePosition = 0;
       
  5004     TBool first = ETrue;
       
  5005     for ( TInt i = count - 1; i > -1; --i )
       
  5006         {
       
  5007         CXnNode* tmpNode = siblings[i];
       
  5008         if ( tmpNode == &aNode )
       
  5009             {
       
  5010             nodePosition = i;
       
  5011             continue;
       
  5012             }
       
  5013         if ( !IsNodeNavigableL( *tmpNode ) )
       
  5014             {
       
  5015             continue;
       
  5016             }
       
  5017         tmpIndexValue = GetNavIndexL( *tmpNode );
       
  5018         if ( tmpIndexValue )
       
  5019             {
       
  5020             if ( tmpIndexValue->IsNoneIdent() )
       
  5021                 {
       
  5022                 // nav index set as none, skipping
       
  5023                 continue;
       
  5024                 }
       
  5025             }
       
  5026        if ( ( CompareNavIndexesL( tmpIndexValue, navIndexValue ) == 0 ) &&
       
  5027              ( first ||
       
  5028                ( CompareNavIndexesL( tmpIndexValue, nextIndexValue ) > 0 ) ) &&
       
  5029              ( i > nodePosition ) )
       
  5030             {
       
  5031             first = EFalse;
       
  5032             nextIndexValue = tmpIndexValue;
       
  5033             nextNode = tmpNode;
       
  5034             }
       
  5035        else if ( ( CompareNavIndexesL( tmpIndexValue, navIndexValue ) > 0 ) &&
       
  5036                  ( first ||
       
  5037                    ( CompareNavIndexesL( tmpIndexValue, nextIndexValue ) > 0 ) ) )
       
  5038             {
       
  5039             first = EFalse;
       
  5040             nextIndexValue = tmpIndexValue;
       
  5041             nextNode = tmpNode;
       
  5042             }
       
  5043         }
       
  5044     return nextNode;
       
  5045     }
       
  5046 
       
  5047 // -----------------------------------------------------------------------------
       
  5048 // CompareNavIndexesL
       
  5049 // -----------------------------------------------------------------------------
       
  5050 //
       
  5051 static TInt CompareNavIndexesL(
       
  5052     CXnDomPropertyValue* aCurrentPropertyValue,
       
  5053     CXnDomPropertyValue* aNextPropertyValue )
       
  5054     {
       
  5055     if ( !aCurrentPropertyValue && !aNextPropertyValue )
       
  5056         {
       
  5057         return 0;
       
  5058         }
       
  5059     else if ( aCurrentPropertyValue && !aNextPropertyValue )
       
  5060         {
       
  5061         if ( aCurrentPropertyValue->IsAutoIdent() )
       
  5062             {
       
  5063             return 0;
       
  5064             }
       
  5065         return 1;
       
  5066         }
       
  5067     else if ( !aCurrentPropertyValue && aNextPropertyValue )
       
  5068         {
       
  5069         if ( aNextPropertyValue->IsAutoIdent() )
       
  5070             {
       
  5071             return 0;
       
  5072             }
       
  5073         return -1;
       
  5074         }
       
  5075     else if ( aCurrentPropertyValue->IsAutoIdent() &&
       
  5076               aNextPropertyValue->IsAutoIdent() )
       
  5077         {
       
  5078         return 0;
       
  5079         }
       
  5080     else if ( !aCurrentPropertyValue->IsAutoIdent() &&
       
  5081               aNextPropertyValue->IsAutoIdent() )
       
  5082         {
       
  5083         return 1;
       
  5084         }
       
  5085     else if ( aCurrentPropertyValue->IsAutoIdent() &&
       
  5086               !aNextPropertyValue->IsAutoIdent() )
       
  5087         {
       
  5088         return -1;
       
  5089         }
       
  5090     else
       
  5091         {
       
  5092         return
       
  5093             aCurrentPropertyValue->FloatValueL() < aNextPropertyValue->FloatValueL() ?
       
  5094             -1 :
       
  5095             aCurrentPropertyValue->FloatValueL() == aNextPropertyValue->FloatValueL() ?
       
  5096             0 :
       
  5097             1;
       
  5098         }
       
  5099     }
       
  5100 
       
  5101 // -----------------------------------------------------------------------------
       
  5102 // FindNextFocusableNodeByNavIndexL
       
  5103 // -----------------------------------------------------------------------------
       
  5104 //
       
  5105 static CXnNode* FindNextFocusableNodeByNavIndexL( CXnNode& aNode, TBool aForward )
       
  5106     {
       
  5107     if ( aNode.ViewNodeImpl() )
       
  5108         {
       
  5109         return NULL;
       
  5110         }
       
  5111     CXnNode* nextNode = NULL;
       
  5112     if ( aForward )
       
  5113         {
       
  5114         nextNode = ForwardL( aNode );
       
  5115         }
       
  5116     else
       
  5117         {
       
  5118         nextNode = BackwardL( aNode );
       
  5119         }
       
  5120     return nextNode;
       
  5121     }
       
  5122 
       
  5123 // -----------------------------------------------------------------------------
       
  5124 // FindNextFocusableNodeL
       
  5125 // -----------------------------------------------------------------------------
       
  5126 //
       
  5127 TBool FindNextFocusableNodeL( CXnNode& aNode, TBool aForward )
       
  5128     {
       
  5129     CXnNode* node( FindNextFocusableNodeByNavIndexL( aNode, aForward ) );
       
  5130 
       
  5131     if ( !node )
       
  5132         {
       
  5133         node = FindLoopedFocusableNodeL( aNode, aForward );
       
  5134         }
       
  5135 
       
  5136     if ( node )
       
  5137         {
       
  5138         node->SetStateL( XnPropertyNames::style::common::KFocus );
       
  5139         if( node && node->ScrollableControl() )
       
  5140             {
       
  5141             node->ScrollableControl()->ShowItem( *node );
       
  5142             }
       
  5143         return ETrue;
       
  5144         }
       
  5145 
       
  5146     return EFalse;
       
  5147     }
       
  5148 
       
  5149 // -----------------------------------------------------------------------------
       
  5150 // FindNextNodeFromRightL
       
  5151 // -----------------------------------------------------------------------------
       
  5152 //
       
  5153 static CXnNode* FindNextNodeFromRightL(
       
  5154     RPointerArray< CXnNode >& aArray,
       
  5155     CXnNode& aNode,
       
  5156     TBool stayInNamespace,
       
  5157     CXnUiEngine* aEngine )
       
  5158     {
       
  5159     
       
  5160     CXnNode* nextNode = NULL;
       
  5161     TRect rect = aNode.PaddingRect();
       
  5162 
       
  5163     for ( TInt i = 0; i < aArray.Count(); ++i )
       
  5164         {
       
  5165         CXnNode* tmpNode = aArray[i];
       
  5166         if ( tmpNode == &aNode )
       
  5167             {
       
  5168             continue;
       
  5169             }
       
  5170         if ( !IsNodeNavigableL( *tmpNode ) )
       
  5171             {
       
  5172             continue;
       
  5173             }
       
  5174         if ( tmpNode->FindViewNode() != tmpNode->UiEngine()->ActiveView() )
       
  5175             {
       
  5176             // do not shift focus to another view
       
  5177             continue;
       
  5178             }
       
  5179         
       
  5180         const TDesC8& tmpNamespace = tmpNode->Impl()->Namespace();
       
  5181         const TDesC8& nodeNamespace = aNode.Impl()->Namespace();
       
  5182                
       
  5183         if ( stayInNamespace && tmpNamespace != nodeNamespace )
       
  5184             {
       
  5185             // if staying in the same namespace is required,
       
  5186             // do not shift focus to a different namespace
       
  5187             continue;
       
  5188             }
       
  5189         
       
  5190         // TODO: only plugin widgets are available in edit mode
       
  5191 
       
  5192         TRect tmpRect = tmpNode->PaddingRect();
       
  5193 
       
  5194         // temp node qualification:
       
  5195         // 1. left edge of temp node is to the right from focused's right edge
       
  5196         // 2. top edge of temp node is NOT below the bottom edge of focused node
       
  5197         // 3. bottom edge of temp node is NOT above the top edge of focused node
       
  5198         if ( rect.iBr.iX - 1 < tmpRect.iTl.iX &&
       
  5199              rect.iBr.iY - 1 >= tmpRect.iTl.iY &&
       
  5200              rect.iTl.iY <= tmpRect.iBr.iY - 1 )
       
  5201             {
       
  5202             if ( !nextNode )
       
  5203                 {
       
  5204                 nextNode = tmpNode;
       
  5205                 }
       
  5206             else
       
  5207                 {
       
  5208                 // left edge of temp node is closer to focused than next node's
       
  5209                 // left edge
       
  5210                 if ( tmpRect.iTl.iX < nextNode->PaddingRect().iTl.iX )
       
  5211                     {
       
  5212                     nextNode = tmpNode;
       
  5213                     continue;
       
  5214                     }
       
  5215                 // left edge of temp and next are at the same level
       
  5216                 else if ( tmpRect.iTl.iX == nextNode->PaddingRect().iTl.iX )
       
  5217                     {
       
  5218                     // top edges are at the same level, choose this one
       
  5219                     if ( tmpRect.iTl.iY == rect.iTl.iY )
       
  5220                         {
       
  5221                         nextNode = tmpNode;
       
  5222                         continue;
       
  5223                         }
       
  5224                     // top edges are not at the same level
       
  5225                     else
       
  5226                         {
       
  5227                         if ( !AknLayoutUtils::LayoutMirrored() )
       
  5228                             {
       
  5229                             // candidate's top edge is below focused's top edge
       
  5230                             // and previous candidate's top edge is above
       
  5231                             // focused's top edge
       
  5232                             if ( nextNode->PaddingRect().iTl.iY < rect.iTl.iY &&
       
  5233                                  tmpRect.iTl.iY > rect.iTl.iY )
       
  5234                                 {
       
  5235                                 nextNode = tmpNode;
       
  5236                                 continue;
       
  5237                                 }
       
  5238                             // previous candidate's top edge is below focused's
       
  5239                             // top edge. Also, candidate's top edge is below
       
  5240                             // focused's top edge. Select the highest one.
       
  5241                             else if ( nextNode->PaddingRect().iTl.iY > rect.iTl.iY &&
       
  5242                                       tmpRect.iTl.iY > rect.iTl.iY &&
       
  5243                                       tmpRect.iTl.iY < nextNode->PaddingRect().iTl.iY )
       
  5244                                 {
       
  5245                                 nextNode = tmpNode;
       
  5246                                 continue;
       
  5247                                 }
       
  5248                             }
       
  5249                         else // arabic/hebrew layout
       
  5250                             {
       
  5251                             // candidate's top edge is above focused's top edge
       
  5252                             // and previous candidate's top edge is below
       
  5253                             // focused's top edge
       
  5254                             if ( nextNode->PaddingRect().iTl.iY > rect.iTl.iY &&
       
  5255                                  tmpRect.iTl.iY < rect.iTl.iY )
       
  5256                                 {
       
  5257                                 nextNode = tmpNode;
       
  5258                                 continue;
       
  5259                                 }
       
  5260                             // candidate's and previous' top edge is below focused's
       
  5261                             // top edge. Select the highest one.
       
  5262                             else if ( nextNode->PaddingRect().iTl.iY > rect.iTl.iY &&
       
  5263                                       tmpRect.iTl.iY > rect.iTl.iY &&
       
  5264                                       tmpRect.iTl.iY < nextNode->PaddingRect().iTl.iY )
       
  5265                                 {
       
  5266                                 nextNode = tmpNode;
       
  5267                                 continue;
       
  5268                                 }
       
  5269                             }
       
  5270                         }
       
  5271                     }
       
  5272                 else
       
  5273                     {
       
  5274                     continue;
       
  5275                     }
       
  5276                 }
       
  5277             }
       
  5278         }
       
  5279 
       
  5280     // find node below or above to the right
       
  5281     if ( !nextNode )
       
  5282         {
       
  5283         if ( !stayInNamespace && aEngine &&
       
  5284              aEngine->ViewManager()->ViewAmount() != KOneView )
       
  5285             {
       
  5286             aEngine->ViewManager()->ActivateNextViewL();
       
  5287             return nextNode;
       
  5288             }
       
  5289         CXnNode* candidateAbove = NULL;
       
  5290         CXnNode* candidateBelow = NULL;
       
  5291 
       
  5292         for ( TInt i = 0; i < aArray.Count(); ++i )
       
  5293             {
       
  5294             CXnNode* tmpNode = aArray[i];
       
  5295             if ( tmpNode == &aNode )
       
  5296                 {
       
  5297                 continue;
       
  5298                 }
       
  5299             if ( !IsNodeNavigableL( *tmpNode ) )
       
  5300                 {
       
  5301                 continue;
       
  5302                 }
       
  5303             if ( tmpNode->FindViewNode() != tmpNode->UiEngine()->ActiveView() )
       
  5304                 {
       
  5305                 // do not shift focus to another view
       
  5306                 continue;
       
  5307                 }
       
  5308             
       
  5309             const TDesC8& tmpNamespace = tmpNode->Impl()->Namespace();
       
  5310             const TDesC8& nodeNamespace = aNode.Impl()->Namespace();
       
  5311 
       
  5312             if ( stayInNamespace && tmpNamespace != nodeNamespace )
       
  5313                 {
       
  5314                 // if staying in the same namespace is required,
       
  5315                 // do not shift focus to a different namespace
       
  5316                 continue;
       
  5317                 }
       
  5318             // TODO: only plugin widgets are available in edit mode
       
  5319 
       
  5320             TRect tmpRect = tmpNode->PaddingRect();
       
  5321 
       
  5322             // temp node qualification:
       
  5323             // left edge of temp node is to the right from focused's right edge
       
  5324             if ( rect.iBr.iX - 1 < tmpRect.iTl.iX )
       
  5325                 {
       
  5326                 // tmp is above the focused node
       
  5327                 if ( tmpRect.iBr.iY - 1 < rect.iTl.iY )
       
  5328                     {
       
  5329                     if ( candidateAbove == NULL )
       
  5330                         {
       
  5331                         candidateAbove = tmpNode;
       
  5332                         }
       
  5333                     else
       
  5334                         {
       
  5335                         // use pythagorean theorem to determine the closest node
       
  5336                         TInt xDistTmp = tmpRect.iTl.iX - rect.iBr.iX;
       
  5337                         TInt yDistTmp = tmpRect.iBr.iY - rect.iTl.iY;
       
  5338                         TReal tmpDist = Abs( ( xDistTmp * xDistTmp ) + ( yDistTmp * yDistTmp ) );
       
  5339 
       
  5340                         TInt xCand = candidateAbove->PaddingRect().iTl.iX - rect.iBr.iX;
       
  5341                         TInt yCand = candidateAbove->PaddingRect().iBr.iY - rect.iTl.iY;
       
  5342                         TReal cDist = Abs( ( xCand * xCand ) + ( yCand * yCand ) );
       
  5343 
       
  5344                         if ( tmpDist < cDist )
       
  5345                             {
       
  5346                             candidateAbove = tmpNode;
       
  5347                             }
       
  5348                         }
       
  5349                     }
       
  5350                 else
       
  5351                     {
       
  5352                     if ( candidateBelow == NULL )
       
  5353                         {
       
  5354                         candidateBelow = tmpNode;
       
  5355                         }
       
  5356                     else
       
  5357                         {
       
  5358                         // use pythagorean theorem to determine the closest node
       
  5359                         TInt xDistTmp = tmpRect.iTl.iX - rect.iBr.iX;
       
  5360                         TInt yDistTmp = tmpRect.iTl.iY - rect.iBr.iY;
       
  5361                         TReal tmpDist = Abs( ( xDistTmp * xDistTmp ) + ( yDistTmp * yDistTmp ) );
       
  5362 
       
  5363                         TInt xCand = candidateBelow->PaddingRect().iTl.iX - rect.iBr.iX;
       
  5364                         TInt yCand = candidateBelow->PaddingRect().iTl.iY - rect.iBr.iY;
       
  5365                         TReal cDist = Abs( ( xCand * xCand ) + ( yCand * yCand ) );
       
  5366 
       
  5367                         if ( tmpDist < cDist )
       
  5368                             {
       
  5369                             candidateBelow = tmpNode;
       
  5370                             }
       
  5371                         }
       
  5372                     }
       
  5373                 }
       
  5374             }
       
  5375 
       
  5376         if ( !AknLayoutUtils::LayoutMirrored() )
       
  5377             {
       
  5378             if ( candidateBelow )
       
  5379                 {
       
  5380                 nextNode = candidateBelow;
       
  5381                 }
       
  5382             else
       
  5383                 {
       
  5384                 if ( candidateAbove )
       
  5385                     {
       
  5386                     nextNode = candidateAbove;
       
  5387                     }
       
  5388                 }
       
  5389             }
       
  5390         else
       
  5391             {
       
  5392             if ( candidateAbove )
       
  5393                 {
       
  5394                 nextNode = candidateAbove;
       
  5395                 }
       
  5396             else
       
  5397                 {
       
  5398                 if ( candidateBelow )
       
  5399                     {
       
  5400                     nextNode = candidateBelow;
       
  5401                     }
       
  5402                 }
       
  5403             }
       
  5404         }
       
  5405 
       
  5406     // loop to the right
       
  5407     if ( !nextNode )
       
  5408         {
       
  5409         CXnNode* candidateAbove = NULL;
       
  5410         CXnNode* candidateBelow = NULL;
       
  5411 
       
  5412         for ( TInt i = 0; i < aArray.Count(); ++i )
       
  5413             {
       
  5414             CXnNode* tmpNode = aArray[i];
       
  5415             if ( !IsNodeNavigableL( *tmpNode ) )
       
  5416                 {
       
  5417                 continue;
       
  5418                 }
       
  5419             if ( tmpNode->FindViewNode() != tmpNode->UiEngine()->ActiveView() )
       
  5420                 {
       
  5421                 // do not shift focus to another view
       
  5422                 continue;
       
  5423                 }
       
  5424             
       
  5425             const TDesC8& tmpNamespace = tmpNode->Impl()->Namespace();
       
  5426             const TDesC8& nodeNamespace = aNode.Impl()->Namespace();
       
  5427                    
       
  5428             if ( stayInNamespace && tmpNamespace != nodeNamespace )
       
  5429                 {
       
  5430                 // if staying in the same namespace is required,
       
  5431                 // do not shift focus to a different namespace
       
  5432                 continue;
       
  5433                 }
       
  5434             
       
  5435             // TODO: only plugin widgets are available in edit mode
       
  5436             TRect tmpRect = tmpNode->PaddingRect();
       
  5437 
       
  5438             // tmp is above the focused node
       
  5439             if ( tmpRect.iBr.iY <= rect.iTl.iY )
       
  5440                 {
       
  5441                 if ( candidateAbove == NULL )
       
  5442                     {
       
  5443                     candidateAbove = tmpNode;
       
  5444                     }
       
  5445                 else
       
  5446                     {
       
  5447                     // use pythagorean theorem to determine the closest node
       
  5448                     TInt xDistTmp = tmpRect.iTl.iX;
       
  5449                     TInt yDistTmp = tmpRect.iTl.iY - rect.iTl.iY;
       
  5450                     TReal tmpDist = Abs( ( xDistTmp * xDistTmp ) + ( yDistTmp * yDistTmp ) );
       
  5451 
       
  5452                     TInt xCand = candidateAbove->PaddingRect().iTl.iX;
       
  5453                     TInt yCand = candidateAbove->PaddingRect().iTl.iY - rect.iTl.iY;
       
  5454                     TReal cDist = Abs( ( xCand * xCand ) + ( yCand * yCand ) );
       
  5455 
       
  5456                     if ( tmpDist < cDist )
       
  5457                         {
       
  5458                         candidateAbove = tmpNode;
       
  5459                         }
       
  5460                     }
       
  5461                 }
       
  5462             else
       
  5463                 {
       
  5464                 if ( candidateBelow == NULL )
       
  5465                     {
       
  5466                     candidateBelow = tmpNode;
       
  5467                     }
       
  5468                 else
       
  5469                     {
       
  5470                     // use pythagorean theorem to determine the closest node
       
  5471                     TInt xDistTmp = tmpRect.iTl.iX;
       
  5472                     TInt yDistTmp = rect.iTl.iY - tmpRect.iTl.iY;
       
  5473                     TReal tmpDist = Abs( ( xDistTmp * xDistTmp ) + ( yDistTmp * yDistTmp ) );
       
  5474 
       
  5475                     TInt xCand = candidateBelow->PaddingRect().iTl.iX;
       
  5476                     TInt yCand = rect.iTl.iY - candidateBelow->PaddingRect().iTl.iY;
       
  5477                     TReal cDist = Abs( ( xCand * xCand ) + ( yCand * yCand ) );
       
  5478 
       
  5479                     if ( tmpDist < cDist )
       
  5480                         {
       
  5481                         candidateBelow = tmpNode;
       
  5482                         }
       
  5483                     }
       
  5484                 }
       
  5485             }
       
  5486 
       
  5487         if ( candidateAbove && candidateBelow )
       
  5488             {
       
  5489             CXnNode* pluginAbove = FindPluginNode( *candidateAbove );
       
  5490             CXnNode* pluginBelow = FindPluginNode( *candidateBelow );
       
  5491 
       
  5492             TReal aboveDist = 0;
       
  5493             TReal belowDist = 0;
       
  5494 
       
  5495             if ( pluginAbove )
       
  5496                 {
       
  5497                 TInt xAbove = pluginAbove->PaddingRect().iTl.iX;
       
  5498                 TInt yAbove = 0;
       
  5499                 if ( !AknLayoutUtils::LayoutMirrored() )
       
  5500                     {
       
  5501                     yAbove = rect.iTl.iY - pluginAbove->PaddingRect().iTl.iY;
       
  5502                     }
       
  5503                 else
       
  5504                     {
       
  5505                     yAbove = rect.iTl.iY - pluginAbove->PaddingRect().iBr.iY;
       
  5506                     }
       
  5507                 aboveDist = Abs( ( xAbove * xAbove ) + ( yAbove * yAbove ) );
       
  5508                 }
       
  5509             else
       
  5510                 {
       
  5511                 TInt xAbove = candidateAbove->PaddingRect().iTl.iX;
       
  5512                 TInt yAbove = 0;
       
  5513                 if ( !AknLayoutUtils::LayoutMirrored() )
       
  5514                     {
       
  5515                     yAbove = rect.iTl.iY - candidateAbove->PaddingRect().iTl.iY;
       
  5516                     }
       
  5517                 else
       
  5518                     {
       
  5519                     yAbove = rect.iTl.iY - candidateAbove->PaddingRect().iBr.iY;
       
  5520                     }
       
  5521 
       
  5522                 aboveDist = Abs( ( xAbove * xAbove ) + ( yAbove * yAbove ) );
       
  5523                 }
       
  5524 
       
  5525             if ( pluginBelow )
       
  5526                 {
       
  5527                 TInt xBelow = pluginBelow->PaddingRect().iTl.iX;
       
  5528                 TInt yBelow = pluginBelow->PaddingRect().iTl.iY - rect.iTl.iY;
       
  5529                 belowDist = Abs( ( xBelow * xBelow ) + ( yBelow * yBelow ) );
       
  5530                 }
       
  5531             else
       
  5532                 {
       
  5533                 TInt xBelow = candidateBelow->PaddingRect().iTl.iX;
       
  5534                 TInt yBelow = candidateBelow->PaddingRect().iTl.iY - rect.iTl.iY;
       
  5535                 belowDist = Abs( ( xBelow * xBelow ) + ( yBelow * yBelow ) );
       
  5536                 }
       
  5537 
       
  5538             if ( aboveDist < belowDist )
       
  5539                 {
       
  5540                 nextNode = candidateAbove;
       
  5541                 }
       
  5542             else if ( belowDist < aboveDist )
       
  5543                 {
       
  5544                 nextNode = candidateBelow;
       
  5545                 }
       
  5546             else
       
  5547                 {
       
  5548                 if ( !AknLayoutUtils::LayoutMirrored() )
       
  5549                     {
       
  5550                     nextNode = candidateBelow;
       
  5551                     }
       
  5552                 else
       
  5553                     {
       
  5554                     nextNode = candidateAbove;
       
  5555                     }
       
  5556                 }
       
  5557             }
       
  5558         else if ( candidateAbove )
       
  5559             {
       
  5560             nextNode = candidateAbove;
       
  5561             }
       
  5562         else if ( candidateBelow )
       
  5563             {
       
  5564             nextNode = candidateBelow;
       
  5565             }
       
  5566         else
       
  5567             {
       
  5568             // do nothing
       
  5569             }
       
  5570         }
       
  5571     
       
  5572     if ( stayInNamespace && !nextNode )
       
  5573         {
       
  5574         return &aNode;
       
  5575         }
       
  5576     
       
  5577     return nextNode;
       
  5578     }
       
  5579 
       
  5580 // -----------------------------------------------------------------------------
       
  5581 // FindNextNodeFromLeftL
       
  5582 // -----------------------------------------------------------------------------
       
  5583 //
       
  5584 static CXnNode* FindNextNodeFromLeftL(
       
  5585     RPointerArray< CXnNode >& aArray,
       
  5586     CXnNode& aNode,
       
  5587     TBool stayInNamespace,
       
  5588     CXnUiEngine* aEngine )
       
  5589     {
       
  5590     CXnNode* nextNode = NULL;
       
  5591     TRect rect = aNode.PaddingRect();
       
  5592 
       
  5593     for ( TInt i = 0; i < aArray.Count(); ++i )
       
  5594         {
       
  5595         CXnNode* tmpNode = aArray[i];
       
  5596         if ( tmpNode == &aNode )
       
  5597             {
       
  5598             continue;
       
  5599             }
       
  5600         if ( !IsNodeNavigableL( *tmpNode ) )
       
  5601             {
       
  5602             continue;
       
  5603             }
       
  5604         if ( tmpNode->FindViewNode() != tmpNode->UiEngine()->ActiveView() )
       
  5605             {
       
  5606             // do not shift focus to another view
       
  5607             continue;
       
  5608             }
       
  5609         
       
  5610         const TDesC8& tmpNamespace = tmpNode->Impl()->Namespace();
       
  5611         const TDesC8& nodeNamespace = aNode.Impl()->Namespace();
       
  5612                
       
  5613         if ( stayInNamespace && tmpNamespace != nodeNamespace )
       
  5614             {
       
  5615             // if staying in the same namespace is required,
       
  5616             // do not shift focus to a different namespace
       
  5617             continue;
       
  5618             }
       
  5619         
       
  5620         // TODO: only plugin widgets are available in edit mode
       
  5621 
       
  5622         TRect tmpRect = tmpNode->PaddingRect();
       
  5623 
       
  5624         // temp node qualification:
       
  5625         // 1. right edge of temp node is to the left from focused's left edge
       
  5626         // 2. top edge of temp node is NOT below the bottom edge of focused node
       
  5627         // 3. bottom edge of temp node is NOT above the top edge of focused node
       
  5628         if ( rect.iTl.iX > tmpRect.iBr.iX - 1 &&
       
  5629              rect.iBr.iY - 1 >= tmpRect.iTl.iY &&
       
  5630              rect.iTl.iY <= tmpRect.iBr.iY - 1 )
       
  5631             {
       
  5632             if ( !nextNode )
       
  5633                 {
       
  5634                 nextNode = tmpNode;
       
  5635                 }
       
  5636             else
       
  5637                 {
       
  5638                 // right edge of temp node is closer to focused than next node's
       
  5639                 // right edge
       
  5640                 if ( tmpRect.iBr.iX - 1 > nextNode->PaddingRect().iBr.iX - 1 )
       
  5641                     {
       
  5642                     nextNode = tmpNode;
       
  5643                     continue;
       
  5644                     }
       
  5645                 // left edge of temp and next are at the same level
       
  5646                 else if ( tmpRect.iBr.iX - 1 == nextNode->PaddingRect().iBr.iX - 1 )
       
  5647                     {
       
  5648                     // top edges are at the same level, choose this one
       
  5649                     if ( tmpRect.iTl.iY == rect.iTl.iY )
       
  5650                         {
       
  5651                         nextNode = tmpNode;
       
  5652                         continue;
       
  5653                         }
       
  5654                     // top edges are not at the same level
       
  5655                     else
       
  5656                         {
       
  5657                         if ( !AknLayoutUtils::LayoutMirrored() )
       
  5658                             {
       
  5659                             // candidate's top edge is below focused's top edge
       
  5660                             // and previous candidate's top edge is above focused's
       
  5661                             // top edge
       
  5662                             if ( nextNode->PaddingRect().iTl.iY > rect.iTl.iY &&
       
  5663                                  tmpRect.iTl.iY < rect.iTl.iY )
       
  5664                                 {
       
  5665                                 nextNode = tmpNode;
       
  5666                                 continue;
       
  5667                                 }
       
  5668                             // candidate's and previous candidate's top edge is
       
  5669                             // above focused's top edge. Select highest one.
       
  5670                             else if ( nextNode->PaddingRect().iTl.iY < rect.iTl.iY &&
       
  5671                                       tmpRect.iTl.iY < rect.iTl.iY &&
       
  5672                                       tmpRect.iTl.iY < nextNode->PaddingRect().iTl.iY )
       
  5673                                 {
       
  5674                                 nextNode = tmpNode;
       
  5675                                 continue;
       
  5676                                 }
       
  5677                             }
       
  5678                         else // arabic/hebrew layout
       
  5679                             {
       
  5680                             // candidate's top edge is below focused's top edge
       
  5681                             // and previous candidate's top edge is above
       
  5682                             // focused's top edge
       
  5683                             if ( nextNode->PaddingRect().iTl.iY < rect.iTl.iY &&
       
  5684                                  tmpRect.iTl.iY > rect.iTl.iY )
       
  5685                                 {
       
  5686                                 nextNode = tmpNode;
       
  5687                                 continue;
       
  5688                                 }
       
  5689                             // previous candidate's top edge is below focused's
       
  5690                             // top edge. Also, candidate's top edge is below
       
  5691                             // focused's top edge. Select the highest one.
       
  5692                             else if ( nextNode->PaddingRect().iTl.iY > rect.iTl.iY &&
       
  5693                                       tmpRect.iTl.iY > rect.iTl.iY &&
       
  5694                                       tmpRect.iTl.iY < nextNode->PaddingRect().iTl.iY )
       
  5695                                 {
       
  5696                                 nextNode = tmpNode;
       
  5697                                 continue;
       
  5698                                 }
       
  5699                             }
       
  5700                         }
       
  5701                     }
       
  5702                 else
       
  5703                     {
       
  5704                     continue;
       
  5705                     }
       
  5706                 }
       
  5707             }
       
  5708         }
       
  5709 
       
  5710     if ( !nextNode )
       
  5711         {
       
  5712         if ( !stayInNamespace && aEngine &&
       
  5713              aEngine->ViewManager()->ViewAmount() != KOneView )
       
  5714             {
       
  5715             aEngine->ViewManager()->ActivatePreviousViewL();
       
  5716             return nextNode;
       
  5717             }
       
  5718         CXnNode* candidateAbove = NULL;
       
  5719         CXnNode* candidateBelow = NULL;
       
  5720 
       
  5721         for ( TInt i = 0; i < aArray.Count(); ++i )
       
  5722             {
       
  5723             CXnNode* tmpNode = aArray[i];
       
  5724             if ( tmpNode == &aNode )
       
  5725                 {
       
  5726                 continue;
       
  5727                 }
       
  5728             if ( !IsNodeNavigableL( *tmpNode ) )
       
  5729                 {
       
  5730                 continue;
       
  5731                 }
       
  5732             if ( tmpNode->FindViewNode() != tmpNode->UiEngine()->ActiveView() )
       
  5733                 {
       
  5734                 // do not shift focus to another view
       
  5735                 continue;
       
  5736                 }
       
  5737             
       
  5738             const TDesC8& tmpNamespace = tmpNode->Impl()->Namespace();
       
  5739             const TDesC8& nodeNamespace = aNode.Impl()->Namespace();       
       
  5740                    
       
  5741             if ( stayInNamespace && tmpNamespace != nodeNamespace )
       
  5742                 {
       
  5743                 // if staying in the same namespace is required,
       
  5744                 // do not shift focus to a different namespace
       
  5745                 continue;
       
  5746                 }
       
  5747             
       
  5748             // TODO: only plugin widgets are available in edit mode
       
  5749             TRect tmpRect = tmpNode->PaddingRect();
       
  5750 
       
  5751             // temp node qualification:
       
  5752             // right edge of temp node is to the left from focused's left edge
       
  5753             if ( tmpRect.iBr.iX < rect.iTl.iX - 1 )
       
  5754                 {
       
  5755                 // tmp is above the focused node
       
  5756                 if ( tmpRect.iBr.iY < rect.iTl.iY )
       
  5757                     {
       
  5758                     if ( candidateAbove == NULL )
       
  5759                         {
       
  5760                         candidateAbove = tmpNode;
       
  5761                         }
       
  5762                     else
       
  5763                         {
       
  5764                         // use pythagorean theorem to determine the closest node
       
  5765                         TInt xDistTmp = rect.iTl.iX - tmpRect.iBr.iX;
       
  5766                         TInt yDistTmp = rect.iTl.iY - tmpRect.iBr.iY;
       
  5767                         TReal tmpDist = Abs( ( xDistTmp * xDistTmp ) + ( yDistTmp * yDistTmp ) );
       
  5768 
       
  5769                         TInt xCand = rect.iTl.iX - candidateAbove->PaddingRect().iTl.iX;
       
  5770                         TInt yCand = rect.iTl.iY - candidateAbove->PaddingRect().iBr.iY;
       
  5771                         TReal cDist = Abs( ( xCand * xCand ) + ( yCand * yCand ) );
       
  5772 
       
  5773                         if ( tmpDist < cDist )
       
  5774                             {
       
  5775                             candidateAbove = tmpNode;
       
  5776                             }
       
  5777                         }
       
  5778                     }
       
  5779                 else
       
  5780                     {
       
  5781                     if ( candidateBelow == NULL )
       
  5782                         {
       
  5783                         candidateBelow = tmpNode;
       
  5784                         }
       
  5785                     else
       
  5786                         {
       
  5787                         // use pythagorean theorem to determine the closest node
       
  5788                         TInt xDistTmp = rect.iTl.iX - tmpRect.iBr.iX;
       
  5789                         TInt yDistTmp = rect.iBr.iY - tmpRect.iTl.iY;
       
  5790                         TReal tmpDist = Abs( ( xDistTmp * xDistTmp ) + ( yDistTmp * yDistTmp ) );
       
  5791 
       
  5792                         TInt xCand = rect.iTl.iX - candidateBelow->PaddingRect().iBr.iX;
       
  5793                         TInt yCand = rect.iBr.iY - candidateBelow->PaddingRect().iTl.iY;
       
  5794                         TReal cDist = Abs( ( xCand * xCand ) + ( yCand * yCand ) );
       
  5795 
       
  5796                         if ( tmpDist < cDist )
       
  5797                             {
       
  5798                             candidateBelow = tmpNode;
       
  5799                             }
       
  5800                         }
       
  5801                     }
       
  5802                 }
       
  5803             }
       
  5804 
       
  5805         if ( !AknLayoutUtils::LayoutMirrored() )
       
  5806             {
       
  5807             if ( candidateAbove )
       
  5808                 {
       
  5809                 nextNode = candidateAbove;
       
  5810                 }
       
  5811             else
       
  5812                 {
       
  5813                 if ( candidateBelow )
       
  5814                     {
       
  5815                     nextNode = candidateBelow;
       
  5816                     }
       
  5817                 }
       
  5818             }
       
  5819         else
       
  5820             {
       
  5821             if ( candidateBelow )
       
  5822                 {
       
  5823                 nextNode = candidateBelow;
       
  5824                 }
       
  5825             else
       
  5826                 {
       
  5827                 if ( candidateAbove )
       
  5828                     {
       
  5829                     nextNode = candidateAbove;
       
  5830                     }
       
  5831                 }
       
  5832             }
       
  5833         }
       
  5834 
       
  5835     // get view width to get looping x point
       
  5836     TInt viewWidth = aNode.FindViewNode()->PaddingRect().Width();
       
  5837 
       
  5838     // loop to the left
       
  5839     if ( !nextNode )
       
  5840         {
       
  5841         CXnNode* candidateAbove = NULL;
       
  5842         CXnNode* candidateBelow = NULL;
       
  5843 
       
  5844         for ( TInt i = 0; i < aArray.Count(); ++i )
       
  5845             {
       
  5846             CXnNode* tmpNode = aArray[i];
       
  5847             /*
       
  5848             if ( tmpNode == &aNode )
       
  5849                 {
       
  5850                 continue;
       
  5851                 }
       
  5852             */
       
  5853             if ( !IsNodeNavigableL( *tmpNode ) )
       
  5854                 {
       
  5855                 continue;
       
  5856                 }
       
  5857             if ( tmpNode->FindViewNode() != tmpNode->UiEngine()->ActiveView() )
       
  5858                 {
       
  5859                 // do not shift focus to another view
       
  5860                 continue;
       
  5861                 }
       
  5862             
       
  5863             const TDesC8& tmpNamespace = tmpNode->Impl()->Namespace();
       
  5864             const TDesC8& nodeNamespace = aNode.Impl()->Namespace();
       
  5865                    
       
  5866             if ( stayInNamespace && tmpNamespace != nodeNamespace )
       
  5867                 {
       
  5868                 // if staying in the same namespace is required,
       
  5869                 // do not shift focus to a different namespace
       
  5870                 continue;
       
  5871                 }
       
  5872             
       
  5873             
       
  5874             // TODO: only plugin widgets are available in edit mode
       
  5875             TRect tmpRect = tmpNode->PaddingRect();
       
  5876 
       
  5877             // tmp is above the focused node
       
  5878             if ( tmpRect.iBr.iY <= rect.iTl.iY )
       
  5879                 {
       
  5880                 if ( candidateAbove == NULL )
       
  5881                     {
       
  5882                     candidateAbove = tmpNode;
       
  5883                     }
       
  5884                 else
       
  5885                     {
       
  5886                     // use pythagorean theorem to determine the closest node
       
  5887                     TInt xDistTmp = viewWidth - tmpRect.iBr.iX;
       
  5888                     TInt yDistTmp = rect.iTl.iY - tmpRect.iBr.iY;
       
  5889                     TReal tmpDist = Abs( ( xDistTmp * xDistTmp ) + ( yDistTmp * yDistTmp ) );
       
  5890 
       
  5891                     TInt xCand = viewWidth - candidateAbove->PaddingRect().iBr.iX;
       
  5892                     TInt yCand = rect.iTl.iY - candidateAbove->PaddingRect().iTl.iY;
       
  5893                     TReal cDist = Abs( ( xCand * xCand ) + ( yCand * yCand ) );
       
  5894 
       
  5895                     if ( tmpDist < cDist )
       
  5896                         {
       
  5897                         candidateAbove = tmpNode;
       
  5898                         }
       
  5899                     }
       
  5900                 }
       
  5901             else
       
  5902                 {
       
  5903                 if ( candidateBelow == NULL )
       
  5904                     {
       
  5905                     candidateBelow = tmpNode;
       
  5906                     }
       
  5907                 else
       
  5908                     {
       
  5909                     // use pythagorean theorem to determine the closest node
       
  5910                     TInt xDistTmp = viewWidth - tmpRect.iBr.iX;
       
  5911                     TInt yDistTmp = tmpRect.iTl.iY - rect.iTl.iY;
       
  5912                     TReal tmpDist = Abs( ( xDistTmp * xDistTmp ) + ( yDistTmp * yDistTmp ) );
       
  5913 
       
  5914                     TInt xCand = viewWidth - candidateBelow->PaddingRect().iBr.iX;
       
  5915                     TInt yCand = candidateBelow->PaddingRect().iTl.iY - rect.iTl.iY;
       
  5916                     TReal cDist = Abs( ( xCand * xCand ) + ( yCand * yCand ) );
       
  5917 
       
  5918                     if ( tmpDist < cDist )
       
  5919                         {
       
  5920                         candidateBelow = tmpNode;
       
  5921                         }
       
  5922                     }
       
  5923                 }
       
  5924             }
       
  5925 
       
  5926         if ( candidateAbove && candidateBelow )
       
  5927             {
       
  5928             CXnNode* pluginAbove = FindPluginNode( *candidateAbove );
       
  5929             CXnNode* pluginBelow = FindPluginNode( *candidateBelow );
       
  5930 
       
  5931             TReal aboveDist = 0;
       
  5932             TReal belowDist = 0;
       
  5933 
       
  5934             if ( pluginAbove )
       
  5935                 {
       
  5936                 // compare to bottom right when looping to left
       
  5937                 TInt xAbove = viewWidth - pluginAbove->PaddingRect().iBr.iX;
       
  5938                 TInt yAbove = 0;
       
  5939                 if ( !AknLayoutUtils::LayoutMirrored() )
       
  5940                     {
       
  5941                     yAbove = rect.iTl.iY - pluginAbove->PaddingRect().iBr.iY;
       
  5942                     }
       
  5943                 else
       
  5944                     {
       
  5945                     yAbove = rect.iTl.iY - pluginAbove->PaddingRect().iTl.iY;
       
  5946                     }
       
  5947 
       
  5948                 aboveDist = Abs( (xAbove * xAbove) + (yAbove * yAbove) );
       
  5949                 }
       
  5950             else
       
  5951                 {
       
  5952                 TInt xAbove = viewWidth - candidateAbove->PaddingRect().iBr.iX;
       
  5953                 TInt yAbove = 0;
       
  5954                 if ( !AknLayoutUtils::LayoutMirrored() )
       
  5955                     {
       
  5956                     yAbove = rect.iTl.iY - candidateAbove->PaddingRect().iBr.iY;
       
  5957                     }
       
  5958                 else
       
  5959                     {
       
  5960                     yAbove = rect.iTl.iY - candidateAbove->PaddingRect().iTl.iY;
       
  5961                     }
       
  5962                 aboveDist = Abs( ( xAbove * xAbove ) + ( yAbove * yAbove ) );
       
  5963                 }
       
  5964 
       
  5965             if ( pluginBelow )
       
  5966                 {
       
  5967                 TInt xBelow = viewWidth - pluginBelow->PaddingRect().iBr.iX;
       
  5968                 TInt yBelow = pluginBelow->PaddingRect().iTl.iY - rect.iTl.iY;
       
  5969                 belowDist = Abs( ( xBelow * xBelow ) + ( yBelow * yBelow ) );
       
  5970                 }
       
  5971             else
       
  5972                 {
       
  5973                 TInt xBelow = viewWidth - candidateBelow->PaddingRect().iBr.iX;
       
  5974                 TInt yBelow = candidateBelow->PaddingRect().iTl.iY - rect.iTl.iY;
       
  5975                 belowDist = Abs( ( xBelow * xBelow ) + ( yBelow * yBelow ) );
       
  5976                 }
       
  5977 
       
  5978             if ( aboveDist < belowDist )
       
  5979                 {
       
  5980                 nextNode = candidateAbove;
       
  5981                 }
       
  5982             else if ( belowDist < aboveDist )
       
  5983                 {
       
  5984                 nextNode = candidateBelow;
       
  5985                 }
       
  5986             else
       
  5987                 {
       
  5988                 if ( !AknLayoutUtils::LayoutMirrored() )
       
  5989                     {
       
  5990                     nextNode = candidateBelow;
       
  5991                     }
       
  5992                 else
       
  5993                     {
       
  5994                     nextNode = candidateAbove;
       
  5995                     }
       
  5996                 }
       
  5997             }
       
  5998         else if ( candidateAbove )
       
  5999             {
       
  6000             nextNode = candidateAbove;
       
  6001             }
       
  6002         else if ( candidateBelow )
       
  6003             {
       
  6004             nextNode = candidateBelow;
       
  6005             }
       
  6006         else
       
  6007             {
       
  6008             // do nothing
       
  6009             }
       
  6010         }
       
  6011 
       
  6012     if ( stayInNamespace && !nextNode )
       
  6013         {
       
  6014         return &aNode;
       
  6015         }
       
  6016     
       
  6017     return nextNode;
       
  6018     }
       
  6019 
       
  6020 // -----------------------------------------------------------------------------
       
  6021 // FindNextNodeFromBelowL
       
  6022 // -----------------------------------------------------------------------------
       
  6023 //
       
  6024 static CXnNode* FindNextNodeFromBelowL(
       
  6025     RPointerArray< CXnNode >& aArray,
       
  6026     CXnNode& aNode, TBool stayInNamespace )
       
  6027     {
       
  6028     CXnNode* nextNode = NULL;
       
  6029     TRect rect = aNode.PaddingRect();
       
  6030 
       
  6031     for ( TInt i = 0; i < aArray.Count(); ++i )
       
  6032         {
       
  6033         CXnNode* tmpNode = aArray[i];
       
  6034         if ( tmpNode == &aNode )
       
  6035             {
       
  6036             continue;
       
  6037             }
       
  6038         if ( !IsNodeNavigableL( *tmpNode ) )
       
  6039             {
       
  6040             continue;
       
  6041             }
       
  6042         if ( tmpNode->FindViewNode() != tmpNode->UiEngine()->ActiveView() )
       
  6043             {
       
  6044             // do not shift focus to another view
       
  6045             continue;
       
  6046             }        
       
  6047         
       
  6048         const TDesC8& tmpNamespace = tmpNode->Impl()->Namespace();
       
  6049         const TDesC8& nodeNamespace = aNode.Impl()->Namespace();
       
  6050                
       
  6051         if ( stayInNamespace && tmpNamespace != nodeNamespace )
       
  6052             {
       
  6053             // if staying in the same namespace is required,
       
  6054             // do not shift focus to a different namespace
       
  6055             continue;
       
  6056             }
       
  6057         
       
  6058         // TODO: only plugin widgets are available in edit mode
       
  6059 
       
  6060         TRect tmpRect = tmpNode->PaddingRect();
       
  6061 
       
  6062         // temp node qualification:
       
  6063         // 1. top edge of the temp node is below bottom edge of focused node
       
  6064         // 2. temp node's right or left edge is between focused's left or right edge
       
  6065         if ( tmpRect.iTl.iY > rect.iBr.iY - 1 &&
       
  6066              tmpRect.iBr.iX - 1 >= rect.iTl.iX &&
       
  6067              tmpRect.iTl.iX <= rect.iBr.iX - 1 )
       
  6068             {
       
  6069             if ( !nextNode )
       
  6070                 {
       
  6071                 nextNode = tmpNode;
       
  6072                 }
       
  6073             else
       
  6074                 {
       
  6075                 // temp node is closer than next node
       
  6076                 if ( tmpRect.iTl.iY < nextNode->PaddingRect().iTl.iY )
       
  6077                     {
       
  6078                     nextNode = tmpNode;
       
  6079                     continue;
       
  6080                     }
       
  6081                 // top edge of temp node and next are at the same level
       
  6082                 else if ( tmpRect.iTl.iY == nextNode->PaddingRect().iTl.iY )
       
  6083                     {
       
  6084                     // western layout: take the leftmost one
       
  6085                     if ( !AknLayoutUtils::LayoutMirrored() &&
       
  6086                          tmpRect.iBr.iX - 1 < nextNode->PaddingRect().iBr.iX - 1 )
       
  6087                         {
       
  6088                         nextNode = tmpNode;
       
  6089                         continue;
       
  6090                         }
       
  6091                     // arabic/hebrew layout: take the rightmost one
       
  6092                     if ( AknLayoutUtils::LayoutMirrored() &&
       
  6093                          tmpRect.iBr.iX - 1 > nextNode->PaddingRect().iBr.iX - 1 )
       
  6094                         {
       
  6095                         nextNode = tmpNode;
       
  6096                         continue;
       
  6097                         }
       
  6098                     }
       
  6099                 else
       
  6100                     {
       
  6101                     continue;
       
  6102                     }
       
  6103                 }
       
  6104             }
       
  6105         }
       
  6106 
       
  6107     // no nodes found on the right, try looping
       
  6108     if ( !nextNode )
       
  6109         {
       
  6110         for ( TInt i = 0; i < aArray.Count(); ++i )
       
  6111             {
       
  6112             CXnNode* tmpNode = aArray[i];
       
  6113             TRect tmpRect = tmpNode->PaddingRect();
       
  6114             if ( tmpNode == &aNode )
       
  6115                 {
       
  6116                 continue;
       
  6117                 }
       
  6118             if ( !IsNodeNavigableL( *tmpNode ) )
       
  6119                 {
       
  6120                 continue;
       
  6121                 }
       
  6122             if ( tmpRect.Intersects( rect ) )
       
  6123                 {
       
  6124                 continue;
       
  6125                 }
       
  6126             if ( tmpNode->FindViewNode() != tmpNode->UiEngine()->ActiveView() )
       
  6127                 {
       
  6128                 // do not shift focus to another view
       
  6129                 continue;
       
  6130                 }
       
  6131             
       
  6132             const TDesC8& tmpNamespace = tmpNode->Impl()->Namespace();
       
  6133             const TDesC8& nodeNamespace = aNode.Impl()->Namespace();
       
  6134 
       
  6135             if ( stayInNamespace && tmpNamespace != nodeNamespace )
       
  6136                 {
       
  6137                 // if staying in the same namespace is required,
       
  6138                 // do not shift focus to a different namespace
       
  6139                 continue;
       
  6140                 }
       
  6141             
       
  6142             // TODO: only plugin widgets are available in edit mode
       
  6143 
       
  6144             // temp node's right or left edge must be between focused's left or
       
  6145             // right edge
       
  6146             if ( tmpRect.iBr.iX - 1 >= rect.iTl.iX &&
       
  6147                  tmpRect.iTl.iX <= rect.iBr.iX - 1 )
       
  6148                 {
       
  6149                 if ( !nextNode )
       
  6150                     {
       
  6151                     nextNode = tmpNode;
       
  6152                     }
       
  6153                 else
       
  6154                     {
       
  6155                     // temp node is closer than next node
       
  6156                     if ( tmpRect.iTl.iY < nextNode->PaddingRect().iTl.iY )
       
  6157                         {
       
  6158                         nextNode = tmpNode;
       
  6159                         continue;
       
  6160                         }
       
  6161                     // top edge of temp node and next are at the same level
       
  6162                     else if ( tmpRect.iTl.iY == nextNode->PaddingRect().iTl.iY )
       
  6163                         {
       
  6164                         // western layout: take the leftmost one
       
  6165                         if ( !AknLayoutUtils::LayoutMirrored() &&
       
  6166                              tmpRect.iBr.iX - 1 < nextNode->PaddingRect().iBr.iX - 1 )
       
  6167                             {
       
  6168                             nextNode = tmpNode;
       
  6169                             continue;
       
  6170                             }
       
  6171                         // arabic/hebrew layout: take the rightmost one
       
  6172                         if ( AknLayoutUtils::LayoutMirrored() &&
       
  6173                              tmpRect.iBr.iX - 1 > nextNode->PaddingRect().iBr.iX - 1 )
       
  6174                             {
       
  6175                             nextNode = tmpNode;
       
  6176                             continue;
       
  6177                             }
       
  6178                         }
       
  6179                     else
       
  6180                         {
       
  6181                         continue;
       
  6182                         }
       
  6183                     }
       
  6184                 }
       
  6185             }
       
  6186         }
       
  6187     
       
  6188     if ( stayInNamespace && !nextNode )
       
  6189         {
       
  6190         return &aNode;
       
  6191         }
       
  6192     
       
  6193     return nextNode;
       
  6194     }
       
  6195 
       
  6196 // -----------------------------------------------------------------------------
       
  6197 // FindNextNodeFromAboveL
       
  6198 // -----------------------------------------------------------------------------
       
  6199 //
       
  6200 static CXnNode* FindNextNodeFromAboveL(
       
  6201     RPointerArray< CXnNode >& aArray,
       
  6202     CXnNode& aNode, TBool stayInNamespace )
       
  6203     {
       
  6204     CXnNode* nextNode = NULL;
       
  6205     TRect rect = aNode.PaddingRect();
       
  6206 
       
  6207     for ( TInt i = 0; i < aArray.Count(); ++i )
       
  6208         {
       
  6209         CXnNode* tmpNode = aArray[i];
       
  6210         if ( tmpNode == &aNode )
       
  6211             {
       
  6212             continue;
       
  6213             }
       
  6214         if ( !IsNodeNavigableL( *tmpNode ) )
       
  6215             {
       
  6216             continue;
       
  6217             }
       
  6218         if ( tmpNode->FindViewNode() != tmpNode->UiEngine()->ActiveView() )
       
  6219             {
       
  6220             // do not shift focus to another view
       
  6221             continue;
       
  6222             }
       
  6223         
       
  6224         const TDesC8& tmpNamespace = tmpNode->Impl()->Namespace();
       
  6225         const TDesC8& nodeNamespace = aNode.Impl()->Namespace();       
       
  6226        
       
  6227         if ( stayInNamespace && tmpNamespace != nodeNamespace )
       
  6228             {
       
  6229             // if staying in the same namespace is required,
       
  6230             // do not shift focus to a different namespace
       
  6231             continue;
       
  6232             }
       
  6233         
       
  6234         // TODO: only plugin widgets are available in edit mode
       
  6235         TRect tmpRect = tmpNode->PaddingRect();
       
  6236 
       
  6237         // temp node qualification:
       
  6238         // 1. bottom edge of the temp node is above the top edge of focused node
       
  6239         // 2. temp node's right or left edge is between focused's left or right edge
       
  6240         if ( tmpRect.iBr.iY - 1 < rect.iTl.iY &&
       
  6241              tmpRect.iBr.iX - 1 >= rect.iTl.iX &&
       
  6242              tmpRect.iTl.iX <= rect.iBr.iX - 1 )
       
  6243             {
       
  6244             if ( !nextNode )
       
  6245                 {
       
  6246                 nextNode = tmpNode;
       
  6247                 }
       
  6248             else
       
  6249                 {
       
  6250                 // temp node is closer than next node
       
  6251                 if ( tmpRect.iBr.iY - 1 > nextNode->PaddingRect().iBr.iY - 1 )
       
  6252                     {
       
  6253                     nextNode = tmpNode;
       
  6254                     continue;
       
  6255                     }
       
  6256                 // bottom edge of temp and next node are at the same level
       
  6257                 else if ( tmpRect.iBr.iY - 1 == nextNode->PaddingRect().iBr.iY - 1 )
       
  6258                     {
       
  6259                     // western layout: take the leftmost one
       
  6260                     if ( !AknLayoutUtils::LayoutMirrored() &&
       
  6261                          tmpRect.iBr.iX - 1 < nextNode->PaddingRect().iBr.iX - 1 )
       
  6262                         {
       
  6263                         nextNode = tmpNode;
       
  6264                         continue;
       
  6265                         }
       
  6266                     // arabic/hebrew layout: take the rightmost one
       
  6267                     if ( AknLayoutUtils::LayoutMirrored() &&
       
  6268                          tmpRect.iBr.iX - 1 > nextNode->PaddingRect().iBr.iX - 1 )
       
  6269                         {
       
  6270                         nextNode = tmpNode;
       
  6271                         continue;
       
  6272                         }
       
  6273                     }
       
  6274                 else
       
  6275                     {
       
  6276                     continue;
       
  6277                     }
       
  6278                 }
       
  6279             }
       
  6280         }
       
  6281 
       
  6282     // no nodes found on the right, try looping
       
  6283     if ( !nextNode )
       
  6284         {
       
  6285         for ( TInt i = 0; i < aArray.Count(); ++i )
       
  6286             {
       
  6287             CXnNode* tmpNode = aArray[i];
       
  6288             TRect tmpRect = tmpNode->PaddingRect();
       
  6289             if ( tmpNode == &aNode )
       
  6290                 {
       
  6291                 continue;
       
  6292                 }
       
  6293             if ( !IsNodeNavigableL( *tmpNode ) )
       
  6294                 {
       
  6295                 continue;
       
  6296                 }
       
  6297             if ( tmpRect.Intersects( rect ) )
       
  6298                 {
       
  6299                 continue;
       
  6300                 }
       
  6301             if ( tmpNode->FindViewNode() != tmpNode->UiEngine()->ActiveView() )
       
  6302                 {
       
  6303                 // do not shift focus to another view
       
  6304                 continue;
       
  6305                 }
       
  6306             
       
  6307             const TDesC8& tmpNamespace = tmpNode->Impl()->Namespace();
       
  6308             const TDesC8& nodeNamespace = aNode.Impl()->Namespace();       
       
  6309                    
       
  6310             if ( stayInNamespace && tmpNamespace != nodeNamespace )
       
  6311                 {
       
  6312                 // if staying in the same namespace is required,
       
  6313                 // do not shift focus to a different namespace
       
  6314                 continue;
       
  6315                 }
       
  6316             
       
  6317             // TODO: only plugin widgets are available in edit mode
       
  6318 
       
  6319             // temp node's right or left edge must be between focused's left or
       
  6320             // right edge
       
  6321             if ( tmpRect.iBr.iX - 1 >= rect.iTl.iX &&
       
  6322                  tmpRect.iTl.iX <= rect.iBr.iX - 1 )
       
  6323                 {
       
  6324                 if ( !nextNode )
       
  6325                     {
       
  6326                     nextNode = tmpNode;
       
  6327                     }
       
  6328                 else
       
  6329                     {
       
  6330                     // temp node is closer than next node
       
  6331                     if ( tmpRect.iBr.iY - 1 > nextNode->PaddingRect().iBr.iY - 1 )
       
  6332                         {
       
  6333                         nextNode = tmpNode;
       
  6334                         continue;
       
  6335                         }
       
  6336                     // bottom edge of temp and next node are at the same level
       
  6337                     else if ( tmpRect.iBr.iY - 1 == nextNode->PaddingRect().iBr.iY - 1 )
       
  6338                         {
       
  6339                         // western layout: take the leftmost one
       
  6340                         if ( !AknLayoutUtils::LayoutMirrored() &&
       
  6341                              tmpRect.iBr.iX - 1 < nextNode->PaddingRect().iBr.iX - 1 )
       
  6342                             {
       
  6343                             nextNode = tmpNode;
       
  6344                             continue;
       
  6345                             }
       
  6346                         // arabic/hebrew layout: take the rightmost one
       
  6347                         if ( AknLayoutUtils::LayoutMirrored() &&
       
  6348                              tmpRect.iBr.iX - 1 > nextNode->PaddingRect().iBr.iX - 1 )
       
  6349                             {
       
  6350                             nextNode = tmpNode;
       
  6351                             continue;
       
  6352                             }
       
  6353                         }
       
  6354                     else
       
  6355                         {
       
  6356                         continue;
       
  6357                         }
       
  6358                     }
       
  6359                 }
       
  6360             }
       
  6361         }
       
  6362     
       
  6363     if ( stayInNamespace && !nextNode )
       
  6364         {
       
  6365         return &aNode;
       
  6366         }
       
  6367     
       
  6368     return nextNode;
       
  6369     }
       
  6370 
       
  6371 // -----------------------------------------------------------------------------
       
  6372 // FindPluginNode
       
  6373 // -----------------------------------------------------------------------------
       
  6374 //
       
  6375 static CXnNode* FindPluginNode( CXnNode& aNode )
       
  6376     {
       
  6377     _LIT8( KPlugin, "plugin" );
       
  6378 
       
  6379     CXnNode* pluginNode = NULL;
       
  6380     CXnNode* tmp = &aNode;
       
  6381 
       
  6382     while( tmp->Parent() )
       
  6383         {
       
  6384         tmp = tmp->Parent();
       
  6385         const TDesC8& nodeType = tmp->DomNode()->Name();
       
  6386 
       
  6387         if ( nodeType == KPlugin )
       
  6388             {
       
  6389             pluginNode = tmp;
       
  6390             break;
       
  6391             }
       
  6392         }
       
  6393 
       
  6394     return pluginNode;
       
  6395     }
       
  6396 
       
  6397 // -----------------------------------------------------------------------------
       
  6398 // DoInternalFocusChangeL
       
  6399 // -----------------------------------------------------------------------------
       
  6400 //
       
  6401 static TBool DoInternalFocusChangeL( CXnUiEngine& aEngine,
       
  6402     CXnNode& aNode, const TKeyEvent& aKeyEvent, TEventCode aType )
       
  6403     {
       
  6404     if ( aNode.ViewNodeImpl() )
       
  6405         {
       
  6406         return EFalse;
       
  6407         }
       
  6408     if ( aType != 1 )
       
  6409         {
       
  6410         return EFalse;
       
  6411         }
       
  6412     if ( aKeyEvent.iScanCode != EStdKeyLeftArrow &&
       
  6413          aKeyEvent.iScanCode != EStdKeyRightArrow &&
       
  6414          aKeyEvent.iScanCode != EStdKeyDownArrow &&
       
  6415          aKeyEvent.iScanCode != EStdKeyUpArrow )
       
  6416         {
       
  6417         return EFalse;
       
  6418         }
       
  6419     CXnNode* parent = aNode.Parent();
       
  6420     if ( !parent )
       
  6421         {
       
  6422         return EFalse;
       
  6423         }
       
  6424 
       
  6425     // Handle 'appearance' navigation first, if the current node has 
       
  6426     // "nav-index: appearance"...
       
  6427     CXnProperty* navind = aNode.NavIndexL();
       
  6428     if ( navind && navind->StringValue() == XnPropertyNames::style::common::KAppearance )
       
  6429         {
       
  6430         
       
  6431         CXnAppUiAdapter& appui = static_cast< CXnAppUiAdapter& >( *iAvkonAppUi );
       
  6432         CXnPluginData& plugin( 
       
  6433                     appui.ViewManager().ActiveViewData().Plugin( &aNode ) );
       
  6434         
       
  6435         // find if node is in a widget that contatins some opened popup window
       
  6436        
       
  6437         TBool containsPopUp = plugin.IsDisplayingPopup();
       
  6438         
       
  6439         CXnNode* nextNode( NULL );
       
  6440         RPointerArray< CXnNode >& array = aEngine.ViewManager()->AppearanceNodes();
       
  6441         if ( aKeyEvent.iScanCode == EStdKeyDownArrow )
       
  6442             {
       
  6443             nextNode = FindNextNodeFromBelowL( array, aNode, containsPopUp );
       
  6444             }
       
  6445         else if ( aKeyEvent.iScanCode == EStdKeyUpArrow )
       
  6446             {
       
  6447             nextNode = FindNextNodeFromAboveL( array, aNode, containsPopUp );
       
  6448             }
       
  6449         else if ( aKeyEvent.iScanCode == EStdKeyRightArrow )
       
  6450             {
       
  6451             nextNode = FindNextNodeFromRightL( array, aNode, containsPopUp, &aEngine );
       
  6452             }
       
  6453         else if ( aKeyEvent.iScanCode == EStdKeyLeftArrow )
       
  6454             {
       
  6455             nextNode = FindNextNodeFromLeftL( array, aNode, containsPopUp, &aEngine );
       
  6456             }
       
  6457         if ( nextNode )
       
  6458             {
       
  6459             if( nextNode && nextNode->ScrollableControl() )
       
  6460                 {
       
  6461                 nextNode->ScrollableControl()->ShowItem( *nextNode );
       
  6462                 }
       
  6463             nextNode->SetStateL( XnPropertyNames::style::common::KFocus );
       
  6464             return ETrue;
       
  6465             }
       
  6466         }
       
  6467     else
       
  6468         {
       
  6469         const TDesC8* direction( &XnPropertyNames::style::common::direction::KLTR );
       
  6470         const TDesC8* orientation( &XnPropertyNames::style::common::block_progression::KTB );
       
  6471 
       
  6472         CXnProperty* directionProperty( parent->DirectionL() );
       
  6473 
       
  6474         if ( directionProperty )
       
  6475             {
       
  6476             direction = &directionProperty->StringValue();
       
  6477             }
       
  6478 
       
  6479         CXnProperty* orientationProperty( parent->BlockProgressionL() );
       
  6480 
       
  6481         if ( orientationProperty )
       
  6482             {
       
  6483             orientation = &orientationProperty->StringValue();
       
  6484             }
       
  6485 
       
  6486         TBool match = EFalse;
       
  6487 
       
  6488         if ( *direction == XnPropertyNames::style::common::direction::KLTR &&
       
  6489              ( *orientation == XnPropertyNames::style::common::block_progression::KLR ||
       
  6490                *orientation == XnPropertyNames::style::common::block_progression::KRL ) )
       
  6491             {
       
  6492             if ( aKeyEvent.iScanCode == EStdKeyLeftArrow )
       
  6493                 {
       
  6494                 match = FindNextFocusableNodeL( aNode, EFalse );
       
  6495                 }
       
  6496             if ( aKeyEvent.iScanCode == EStdKeyRightArrow )
       
  6497                 {
       
  6498                 match = FindNextFocusableNodeL( aNode, ETrue );
       
  6499                 }
       
  6500             }
       
  6501         else if ( *direction == XnPropertyNames::style::common::direction::KRTL &&
       
  6502                   ( *orientation == XnPropertyNames::style::common::block_progression::KLR ||
       
  6503                     *orientation == XnPropertyNames::style::common::block_progression::KRL ) )
       
  6504             {
       
  6505             if ( aKeyEvent.iScanCode == EStdKeyRightArrow )
       
  6506                 {
       
  6507                 match = FindNextFocusableNodeL( aNode, EFalse );
       
  6508                 }
       
  6509             if ( aKeyEvent.iScanCode == EStdKeyLeftArrow )
       
  6510                 {
       
  6511                 match = FindNextFocusableNodeL( aNode, ETrue );
       
  6512                 }
       
  6513             }
       
  6514         else if ( *direction == XnPropertyNames::style::common::direction::KLTR &&
       
  6515                   *orientation == XnPropertyNames::style::common::block_progression::KTB )
       
  6516             {
       
  6517             if ( aKeyEvent.iScanCode == EStdKeyUpArrow )
       
  6518                 {
       
  6519                 match = FindNextFocusableNodeL( aNode, EFalse );
       
  6520                 }
       
  6521             if ( aKeyEvent.iScanCode == EStdKeyDownArrow )
       
  6522                 {
       
  6523                 match = FindNextFocusableNodeL( aNode, ETrue );
       
  6524                 }
       
  6525             }
       
  6526         else if ( *direction == XnPropertyNames::style::common::direction::KRTL &&
       
  6527                   *orientation == XnPropertyNames::style::common::block_progression::KTB )
       
  6528             {
       
  6529             if ( aKeyEvent.iScanCode == EStdKeyDownArrow )
       
  6530                 {
       
  6531                 match = FindNextFocusableNodeL( aNode, EFalse );
       
  6532                 }
       
  6533             if ( aKeyEvent.iScanCode == EStdKeyUpArrow )
       
  6534                 {
       
  6535                 match = FindNextFocusableNodeL( aNode, ETrue );
       
  6536                 }
       
  6537             }
       
  6538         return match;
       
  6539         }
       
  6540     return EFalse;
       
  6541     }
       
  6542 
       
  6543 // -----------------------------------------------------------------------------
       
  6544 // DoTriggerKeyEventL
       
  6545 // -----------------------------------------------------------------------------
       
  6546 //
       
  6547 static TBool DoTriggerKeyEventL(
       
  6548     CXnNodeImpl* aThis,
       
  6549     CXnUiEngine& aEngine,
       
  6550     CXnNode& aNode,
       
  6551     const TKeyEvent& aKeyEvent,
       
  6552     TEventCode aType )
       
  6553     {
       
  6554     CXnDomNode* domNode = aNode.DomNode();
       
  6555     CXnDomList& children = domNode->ChildNodes();
       
  6556     TInt count = children.Length();
       
  6557     TBool returnValue = EFalse;
       
  6558     for ( TInt i = 0; i < count; ++i )
       
  6559         {
       
  6560         CXnDomNode* node = static_cast< CXnDomNode* >( children.Item( i ) );
       
  6561         const TDesC8& type = node->Name();
       
  6562         if ( type == XnPropertyNames::action::KActions )
       
  6563             {
       
  6564             CXnDomList& actionChildren = node->ChildNodes();
       
  6565             TInt actionCount = actionChildren.Length();
       
  6566             for ( TInt j = 0; j < actionCount; ++j )
       
  6567                 {
       
  6568                 CXnDomNode* actionNode =
       
  6569                     static_cast< CXnDomNode* >( actionChildren.Item( j ) );
       
  6570                 const TDesC8& actionType = actionNode->Name();
       
  6571                 if ( actionType == XnPropertyNames::action::KAction )
       
  6572                     {
       
  6573                     TBool match = MatchActionForKeyEventL(
       
  6574                         aThis, aEngine, aNode, aKeyEvent, aType, *actionNode );
       
  6575                     if ( match )
       
  6576                         {
       
  6577                         returnValue = ETrue;
       
  6578                         }
       
  6579                     }
       
  6580                 }
       
  6581             }
       
  6582         }
       
  6583 
       
  6584     if ( returnValue )
       
  6585         {
       
  6586         // Return is removed from here to enable auto navigation altough the
       
  6587         // action is alreadytriggered. This enables simpler theme definitions
       
  6588         // especially in AI2 case. If regression is observed then return should
       
  6589         // be restored here. Task ou1s60ui#3386.
       
  6590         //return returnValue;
       
  6591         }
       
  6592 
       
  6593     DoCompoundNodeScrollingL( aNode, aKeyEvent, aType );
       
  6594 
       
  6595     returnValue = DoInternalFocusChangeL( aEngine, aNode, aKeyEvent, aType );
       
  6596 
       
  6597     if ( returnValue )
       
  6598         {
       
  6599         aEngine.RenderUIL();
       
  6600         }
       
  6601 
       
  6602     return returnValue;
       
  6603     }
       
  6604 
       
  6605 // -----------------------------------------------------------------------------
       
  6606 // DoTriggerEventL
       
  6607 // -----------------------------------------------------------------------------
       
  6608 //
       
  6609 static void DoTriggerEventL(
       
  6610     CXnNodeImpl* aThis,
       
  6611     CXnUiEngine& aEngine,
       
  6612     CXnNode& aNode,
       
  6613     CXnNode& aActionsParent,
       
  6614     CXnNode& aEventData,    
       
  6615     TInt aSource )
       
  6616     {    
       
  6617     CXnDomList& children( aActionsParent.DomNode()->ChildNodes() );
       
  6618     
       
  6619     TInt count( children.Length() );
       
  6620     
       
  6621     for ( TInt i = 0; i < count; ++i )
       
  6622         {
       
  6623         CXnDomNode* node = static_cast< CXnDomNode* >( children.Item( i ) );
       
  6624         const TDesC8& type = node->Name();
       
  6625         if ( type == XnPropertyNames::action::KActions )
       
  6626             {
       
  6627             CXnDomList& actionChildren = node->ChildNodes();
       
  6628             TInt actionCount = actionChildren.Length();
       
  6629             for ( TInt j = 0; j < actionCount; ++j )
       
  6630                 {
       
  6631                 CXnDomNode* actionNode =
       
  6632                     static_cast< CXnDomNode* >( actionChildren.Item( j ) );
       
  6633                 const TDesC8& actionType = actionNode->Name();
       
  6634                 if ( actionType == XnPropertyNames::action::KAction )
       
  6635                     {
       
  6636                     TBool match = MatchActionForEventL(
       
  6637                         aThis, aEngine, aNode, aEventData, *actionNode, aSource );
       
  6638                     }
       
  6639                 }
       
  6640             }
       
  6641         }
       
  6642     }
       
  6643 
       
  6644 // -----------------------------------------------------------------------------
       
  6645 // DoReceiveFocusL
       
  6646 // -----------------------------------------------------------------------------
       
  6647 //
       
  6648 static TBool DoReceiveFocusL( CXnNode& aNode, CXnUiEngine& /*aEngine*/ )
       
  6649     {
       
  6650     CXnProperty* focusable = aNode.GetPropertyL(
       
  6651         XnPropertyNames::common::KFocusable );
       
  6652     CXnProperty* disabled = aNode.GetPropertyL(
       
  6653         XnPropertyNames::common::KDisabled );
       
  6654     if ( focusable )
       
  6655         {
       
  6656         const TDesC8& focusValue = focusable->StringValue();
       
  6657         if ( focusValue != KNullDesC8 )
       
  6658             {
       
  6659             if ( focusValue != XnPropertyNames::KTrue )
       
  6660                 {
       
  6661                 return EFalse;
       
  6662                 }
       
  6663             }
       
  6664         }
       
  6665     else
       
  6666         {
       
  6667         return EFalse;
       
  6668         }
       
  6669     if ( disabled )
       
  6670         {
       
  6671         const TDesC8& disabledValue = disabled->StringValue();
       
  6672         if ( disabledValue != KNullDesC8 )
       
  6673             {
       
  6674             if ( disabledValue == XnPropertyNames::KTrue )
       
  6675                 {
       
  6676                 return EFalse;
       
  6677                 }
       
  6678             }
       
  6679         }
       
  6680     if ( !IsNodeNavigableL( aNode ) )
       
  6681         {
       
  6682         return EFalse;
       
  6683         }
       
  6684 
       
  6685     return ETrue;
       
  6686     }
       
  6687 
       
  6688 // -----------------------------------------------------------------------------
       
  6689 // DoSetActiveL
       
  6690 // -----------------------------------------------------------------------------
       
  6691 //
       
  6692 static void DoSetActiveL( CXnNode& aNode, CXnUiEngine& aUiEngine )
       
  6693     {
       
  6694     CXnNode* activate = BuildActivateTriggerNodeL( aUiEngine );
       
  6695     activate->SetUiEngine( aUiEngine );
       
  6696     CleanupStack::PushL( activate );
       
  6697     aNode.ReportXuikonEventL( *activate );
       
  6698     CleanupStack::PopAndDestroy( activate );
       
  6699     }
       
  6700 
       
  6701 // -----------------------------------------------------------------------------
       
  6702 // Informs the component about the property change.
       
  6703 // -----------------------------------------------------------------------------
       
  6704 //
       
  6705 static void InformPropertyChangeL( CXnNode& aNode, CXnProperty* aProperty )
       
  6706     {
       
  6707     //Inform the component about the property change.
       
  6708     CXnNode* parent( aNode.Parent() );
       
  6709 
       
  6710     if ( parent )
       
  6711         {
       
  6712         if ( parent->Type()->Type() == KMenuBar )
       
  6713             {
       
  6714             CXnMenuAdapter* adapter =
       
  6715                 static_cast< CXnMenuAdapter* >( parent->Control() );
       
  6716 
       
  6717             if ( adapter )
       
  6718                 {
       
  6719                 adapter->HandleMenuPropertyChangeL( &aNode.PluginIfL(), aProperty );
       
  6720                 }
       
  6721             }
       
  6722         else if ( aNode.IsLayoutCapable() )
       
  6723             {
       
  6724             CXnControlAdapter* adapter( aNode.Control() );
       
  6725 
       
  6726             if ( adapter )
       
  6727                 {
       
  6728                 adapter->HandlePropertyChangeL( aProperty );
       
  6729                 }
       
  6730             }
       
  6731         }
       
  6732     }
       
  6733 
       
  6734 // -----------------------------------------------------------------------------
       
  6735 // Informs parent and its children about the property change.
       
  6736 // -----------------------------------------------------------------------------
       
  6737 //
       
  6738 static void InformChildrenPropertyChangeL(
       
  6739     CXnNode& aParent,
       
  6740     CXnProperty* aProperty,
       
  6741     TBool aInformParent = ETrue )
       
  6742     {
       
  6743     RPointerArray< CXnNode >& children( aParent.Children() );
       
  6744     if ( aInformParent )
       
  6745         {
       
  6746         InformPropertyChangeL( aParent, aProperty );
       
  6747         }
       
  6748     TInt count( children.Count() );
       
  6749     for ( TInt i = 0 ; i < count; i++ )
       
  6750         {
       
  6751         InformChildrenPropertyChangeL( *children[i], aProperty, ETrue );
       
  6752         }
       
  6753     }
       
  6754 
       
  6755 // -----------------------------------------------------------------------------
       
  6756 // DisplayValueMatchL
       
  6757 // -----------------------------------------------------------------------------
       
  6758 //
       
  6759 static TBool DisplayValueMatchL(
       
  6760     CXnNode& aNode,
       
  6761     const TDesC8& aDisplayValue )
       
  6762     {
       
  6763     CXnProperty* display = aNode.GetPropertyL( KDisplay );
       
  6764     if ( display )
       
  6765         {
       
  6766         const TDesC8& value = display->StringValue();
       
  6767         if ( value.Compare( aDisplayValue ) == KErrNone )
       
  6768             {
       
  6769             return ETrue;
       
  6770             }
       
  6771         }
       
  6772     return EFalse;
       
  6773     }
       
  6774 
       
  6775 // -----------------------------------------------------------------------------
       
  6776 // SetFloatPropertyToNodeL
       
  6777 // Set float property to a node
       
  6778 // -----------------------------------------------------------------------------
       
  6779 //
       
  6780 static void SetFloatPropertyToNodeL(
       
  6781     CXnDomStringPool& aStringPool, CXnNode& aNode,
       
  6782     const TDesC8& aPropertyName, TReal aPropertyValue,
       
  6783     CXnDomPropertyValue::TPrimitiveValueType aValueType )
       
  6784     {
       
  6785     // create property
       
  6786     CXnProperty* prop = CXnProperty::NewL(
       
  6787         aPropertyName, aPropertyValue, aValueType, aStringPool );
       
  6788 
       
  6789     CleanupStack::PushL( prop );
       
  6790     aNode.SetPropertyL( prop );
       
  6791     CleanupStack::Pop( prop );
       
  6792     }
       
  6793 
       
  6794 // -----------------------------------------------------------------------------
       
  6795 // SetStringPropertyToNodeL
       
  6796 // Set string property to a node
       
  6797 // -----------------------------------------------------------------------------
       
  6798 //
       
  6799 static void SetStringPropertyToNodeL(
       
  6800     CXnDomStringPool& aStringPool,
       
  6801     CXnNode& aNode,
       
  6802     const TDesC8& aPropertyName,
       
  6803     const TDesC8& aPropertyValue )
       
  6804     {
       
  6805     // create property
       
  6806     CXnProperty* prop = CXnProperty::NewL(
       
  6807         aPropertyName, aPropertyValue, CXnDomPropertyValue::EString, aStringPool );
       
  6808 
       
  6809     CleanupStack::PushL( prop );
       
  6810     aNode.SetPropertyL( prop );
       
  6811     CleanupStack::Pop( prop );
       
  6812     }
       
  6813 
       
  6814 // -----------------------------------------------------------------------------
       
  6815 // FindYoungestSiblingWithDisplayL
       
  6816 // Seek youngest sibling node with given display value
       
  6817 // -----------------------------------------------------------------------------
       
  6818 //
       
  6819 static CXnNode* FindYoungestSiblingWithDisplayL(
       
  6820     RPointerArray< CXnNode >& aSiblingArray,
       
  6821     const TDesC8& aDisplayValue,
       
  6822     TInt& aIndex )
       
  6823     {
       
  6824     aIndex = KErrNotFound;
       
  6825     CXnNode* node = NULL;
       
  6826     TInt siblingCount( aSiblingArray.Count() );
       
  6827     //Find youngest sibling with display block
       
  6828     for ( TInt i = siblingCount; i > 0; )
       
  6829         {
       
  6830         node = aSiblingArray[--i];
       
  6831         if ( DisplayValueMatchL( *node, aDisplayValue ) )
       
  6832             {
       
  6833             aIndex = i;
       
  6834             return node;
       
  6835             }
       
  6836         }
       
  6837     return NULL;
       
  6838     }
       
  6839 
       
  6840 // -----------------------------------------------------------------------------
       
  6841 // FindOldestSiblingWithDisplayL
       
  6842 // Seek oldest sibling node with given display value
       
  6843 // -----------------------------------------------------------------------------
       
  6844 //
       
  6845 static CXnNode* FindOldestSiblingWithDisplayL(
       
  6846     RPointerArray< CXnNode >& aSiblingArray,
       
  6847     const TDesC8& aDisplayValue,
       
  6848     TInt& aIndex )
       
  6849     {
       
  6850     aIndex = KErrNotFound;
       
  6851     CXnNode* node = NULL;
       
  6852     TInt siblingCount( aSiblingArray.Count() );
       
  6853     //Find oldest sibling with display block
       
  6854     for ( TInt i = 0; i < siblingCount; i++ )
       
  6855         {
       
  6856         node = aSiblingArray[i];
       
  6857         if ( DisplayValueMatchL( *node, aDisplayValue ) )
       
  6858             {
       
  6859             aIndex = i;
       
  6860             return node;
       
  6861             }
       
  6862         }
       
  6863     return NULL;
       
  6864     }
       
  6865 
       
  6866 // -----------------------------------------------------------------------------
       
  6867 // ScrollBoxToBeginningL
       
  6868 // Show the oldest siblings that fit into the compound box.
       
  6869 // -----------------------------------------------------------------------------
       
  6870 //
       
  6871 static void ScrollBoxToBeginningL( RPointerArray< CXnNode >& aSiblingArray )
       
  6872     {
       
  6873     CXnNode* node = NULL;
       
  6874     TInt toBeDisplayed(0);
       
  6875     TInt siblingCount( aSiblingArray.Count() );
       
  6876     for ( TInt i = 0; i < siblingCount; i++ )
       
  6877         {
       
  6878         node = aSiblingArray[i];
       
  6879         if ( DisplayValueMatchL( *node, KBlock ) )
       
  6880             {
       
  6881             CXnDomStringPool& sp = node->DomNode()->StringPool();
       
  6882             //Switch the display to 'none' to visible siblings.
       
  6883             SetStringPropertyToNodeL( sp, *node, KDisplay, KNone );
       
  6884             node = aSiblingArray[toBeDisplayed];
       
  6885             toBeDisplayed++;
       
  6886             //Switch the display to 'block' to hidden siblings.
       
  6887             SetStringPropertyToNodeL( sp, *node, KDisplay, KBlock );
       
  6888             }
       
  6889         }
       
  6890     }
       
  6891 
       
  6892 // -----------------------------------------------------------------------------
       
  6893 // ScrollBoxToEndL
       
  6894 // Show the youngest siblings that fit into the compound box.
       
  6895 // -----------------------------------------------------------------------------
       
  6896 //
       
  6897 static void ScrollBoxToEndL( RPointerArray< CXnNode >& aSiblingArray )
       
  6898     {
       
  6899     CXnNode* node = NULL;
       
  6900     TInt siblingCount( aSiblingArray.Count() );
       
  6901     TInt toBeDisplayed( siblingCount - 1 );
       
  6902     for ( TInt i = siblingCount; i > 0; )
       
  6903         {
       
  6904         node = aSiblingArray[--i];
       
  6905         if ( DisplayValueMatchL( *node, KBlock ) )
       
  6906             {
       
  6907             CXnDomStringPool& sp = node->DomNode()->StringPool();
       
  6908             //Switch the display to 'none' to visible siblings.
       
  6909             SetStringPropertyToNodeL( sp, *node, KDisplay, KNone );
       
  6910             node = aSiblingArray[toBeDisplayed];
       
  6911             toBeDisplayed--;
       
  6912             //Switch the display to 'block' to hidden siblings.
       
  6913             SetStringPropertyToNodeL( sp, *node, KDisplay, KBlock );
       
  6914             }
       
  6915         }
       
  6916     }
       
  6917 
       
  6918 // -----------------------------------------------------------------------------
       
  6919 // IsCompoundNodeL
       
  6920 // Checks whether the node is coumound node.
       
  6921 // -----------------------------------------------------------------------------
       
  6922 //
       
  6923 static TBool IsCompoundNodeL( CXnNode* aNode )
       
  6924     {
       
  6925     if ( !aNode )
       
  6926         {
       
  6927         return EFalse;
       
  6928         }
       
  6929     CXnProperty* compoundProperty = aNode->GetPropertyL( KCompound );
       
  6930     if ( compoundProperty )
       
  6931         {
       
  6932         const TDesC8& value = compoundProperty->StringValue();
       
  6933         if ( !value.Compare( KTrue ) )
       
  6934             {
       
  6935             return ETrue;
       
  6936             }
       
  6937         }
       
  6938     return EFalse;
       
  6939     }
       
  6940 
       
  6941 // -----------------------------------------------------------------------------
       
  6942 // IsLoopingSetL
       
  6943 // Checks whether the node is set to loop.
       
  6944 // -----------------------------------------------------------------------------
       
  6945 //
       
  6946 static TBool IsLoopingNodeL( CXnNode* aNode )
       
  6947     {
       
  6948     if ( !aNode )
       
  6949         {
       
  6950         return EFalse;
       
  6951         }
       
  6952     CXnProperty* navLoopProperty = aNode->GetPropertyL(
       
  6953         XnPropertyNames::style::common::KS60NavLooping );
       
  6954     if ( navLoopProperty )
       
  6955         {
       
  6956         const TDesC8& loopValue = navLoopProperty->StringValue();
       
  6957         if ( loopValue == XnPropertyNames::grid::s60_focus_looping::KStop )
       
  6958             {
       
  6959             return EFalse;
       
  6960             }
       
  6961         }
       
  6962     return ETrue;
       
  6963     }
       
  6964 
       
  6965 // -----------------------------------------------------------------------------
       
  6966 // NotifyScrollNodeL
       
  6967 // Notify scroll node i.e compound box first and last siblings that there is
       
  6968 // nothing more to scroll
       
  6969 // -----------------------------------------------------------------------------
       
  6970 //
       
  6971 static void NotifyScrollNodeL( CXnNode* aNode, TBool aBegin, TBool aGainEnd )
       
  6972     {
       
  6973     RPointerArray< CXnNode >& siblings = aNode->Parent()->Children();
       
  6974     // Last sibling is assumend to be an end scrolling node
       
  6975     CXnNode* scrollNode = siblings[0];
       
  6976     if ( !aBegin )
       
  6977         {
       
  6978         scrollNode = siblings[siblings.Count() - 1];
       
  6979         }
       
  6980     CXnNode* triggerNode =
       
  6981         BuildTriggerNodeL( *scrollNode->UiEngine(), aGainEnd?KGainEnd:KLoseEnd );
       
  6982     triggerNode->SetUiEngine( *scrollNode->UiEngine() );
       
  6983     CleanupStack::PushL( triggerNode );
       
  6984     scrollNode->ReportXuikonEventL( *triggerNode );
       
  6985     CleanupStack::PopAndDestroy( triggerNode );
       
  6986     }
       
  6987 
       
  6988 // -----------------------------------------------------------------------------
       
  6989 // DoCompoundNodeBeginKeyL
       
  6990 // If key towards begin of list was pressed scroll to that direction
       
  6991 // -----------------------------------------------------------------------------
       
  6992 //
       
  6993 static void DoCompoundNodeBeginKeyL(
       
  6994     RPointerArray< CXnNode >& aChildren,
       
  6995     CXnNode* aFocusedNode )
       
  6996     {
       
  6997     TInt oldestIndex( 0 );
       
  6998     // Notify scrollNode if aFocusedNode is node end of the list
       
  6999     CXnNode* lastItem = aChildren[aChildren.Count() - 1];
       
  7000     if ( aFocusedNode == lastItem && !IsLoopingNodeL( lastItem ) )
       
  7001         {
       
  7002         NotifyScrollNodeL( aChildren[0]->Parent(), EFalse, EFalse );
       
  7003         }
       
  7004     CXnNode* node = FindOldestSiblingWithDisplayL( aChildren, KBlock, oldestIndex );
       
  7005     // Set next node's display to block
       
  7006     if ( node && node == aFocusedNode )
       
  7007         {
       
  7008         if ( oldestIndex - 1 >= 0 )
       
  7009             {
       
  7010             node = aChildren[oldestIndex - 1];
       
  7011             CXnDomStringPool& sp = node->DomNode()->StringPool();
       
  7012             SetStringPropertyToNodeL( sp, *node, KDisplay, KBlock );
       
  7013             // find youngest sibling with display block
       
  7014             TInt index( 0 );
       
  7015             node = FindYoungestSiblingWithDisplayL( aChildren, KBlock, index );
       
  7016             if ( node )
       
  7017                 {
       
  7018                 SetStringPropertyToNodeL( sp, *node, KDisplay, KNone );
       
  7019                 }
       
  7020             }
       
  7021         else
       
  7022             {
       
  7023             if ( IsLoopingNodeL( node ) )
       
  7024                 {
       
  7025                 ScrollBoxToEndL( aChildren );
       
  7026                 }
       
  7027             else
       
  7028                 {
       
  7029                 NotifyScrollNodeL( aChildren[0]->Parent(), ETrue, ETrue );
       
  7030                 }
       
  7031             }
       
  7032         }
       
  7033     }
       
  7034 
       
  7035 // -----------------------------------------------------------------------------
       
  7036 // DoCompoundNodeEndKeyL
       
  7037 // If key towards end of list was pressed scroll to that direction
       
  7038 // -----------------------------------------------------------------------------
       
  7039 //
       
  7040 static void DoCompoundNodeEndKeyL(
       
  7041     RPointerArray< CXnNode >& aChildren,
       
  7042     CXnNode* aFocusedNode )
       
  7043     {
       
  7044     TInt index( 0 );
       
  7045     TInt siblingCount( aChildren.Count() );
       
  7046     // Notify scrollNode if aFocusedNode is first node of the list
       
  7047     CXnNode* firstItem = aChildren[0];
       
  7048     if ( aFocusedNode == firstItem && !IsLoopingNodeL( firstItem ) )
       
  7049         {
       
  7050         NotifyScrollNodeL( aChildren[0]->Parent(), ETrue, EFalse );
       
  7051         }
       
  7052     CXnNode* node = FindYoungestSiblingWithDisplayL( aChildren, KBlock, index );
       
  7053     // Set next node's display to block
       
  7054     if ( node && node == aFocusedNode )
       
  7055         {
       
  7056         if ( index < siblingCount - 1 )
       
  7057             {
       
  7058             node = aChildren[index + 1];
       
  7059             CXnDomStringPool& sp = node->DomNode()->StringPool();
       
  7060             SetStringPropertyToNodeL( sp , *node, KDisplay, KBlock );
       
  7061             // find oldest sibling with display block
       
  7062             TInt oldestIndex( 0 );
       
  7063             node = FindOldestSiblingWithDisplayL( aChildren, KBlock, oldestIndex );
       
  7064             if ( node )
       
  7065                 {
       
  7066                 SetStringPropertyToNodeL( sp, *node, KDisplay, KNone );
       
  7067                 }
       
  7068             }
       
  7069         else // we are end of list
       
  7070             {
       
  7071             if ( IsLoopingNodeL( node ) )
       
  7072                 {
       
  7073                 ScrollBoxToBeginningL( aChildren );
       
  7074                 }
       
  7075             else
       
  7076                 {
       
  7077                 NotifyScrollNodeL( aChildren[0]->Parent(), EFalse, ETrue );
       
  7078                 }
       
  7079             }
       
  7080         }
       
  7081     }
       
  7082 
       
  7083 // -----------------------------------------------------------------------------
       
  7084 // DoCompoundNodeScrollingL
       
  7085 // Process compound node key events
       
  7086 // -----------------------------------------------------------------------------
       
  7087 //
       
  7088 static void DoCompoundNodeScrollingL(
       
  7089     CXnNode& aFocusedNode,
       
  7090     const TKeyEvent& aKeyEvent,
       
  7091     TEventCode aType )
       
  7092     {
       
  7093     if ( aType != EEventKey )
       
  7094         {
       
  7095         return;
       
  7096         }
       
  7097     CXnNode* compoundNode = aFocusedNode.Parent();
       
  7098     if ( IsCompoundNodeL( compoundNode ) )
       
  7099         {
       
  7100         RPointerArray< CXnNode >& children = compoundNode->Children();
       
  7101 
       
  7102         if ( aKeyEvent.iScanCode != EStdKeyLeftArrow  &&
       
  7103              aKeyEvent.iScanCode != EStdKeyRightArrow &&
       
  7104              aKeyEvent.iScanCode != EStdKeyDownArrow &&
       
  7105              aKeyEvent.iScanCode != EStdKeyUpArrow )
       
  7106             {
       
  7107             return;
       
  7108             }
       
  7109         CXnNode* parent = aFocusedNode.Parent();
       
  7110         if ( !parent )
       
  7111             {
       
  7112             return;
       
  7113             }
       
  7114         else
       
  7115             {
       
  7116             const TDesC8* direction(
       
  7117                 &XnPropertyNames::style::common::direction::KLTR );
       
  7118             const TDesC8* orientation(
       
  7119                 &XnPropertyNames::style::common::block_progression::KTB );
       
  7120 
       
  7121             CXnProperty* directionProperty( parent->DirectionL() );
       
  7122 
       
  7123             if ( directionProperty )
       
  7124                 {
       
  7125                 direction = &directionProperty->StringValue();
       
  7126                 }
       
  7127 
       
  7128             CXnProperty* orientationProperty( parent->BlockProgressionL() );
       
  7129 
       
  7130             if ( orientationProperty )
       
  7131                 {
       
  7132                 orientation = &orientationProperty->StringValue();
       
  7133                 }
       
  7134 
       
  7135             if ( *direction == XnPropertyNames::style::common::direction::KLTR &&
       
  7136                  ( *orientation == XnPropertyNames::style::common::block_progression::KLR ||
       
  7137                    *orientation == XnPropertyNames::style::common::block_progression::KRL ) )
       
  7138                 {
       
  7139                 if ( aKeyEvent.iScanCode == EStdKeyLeftArrow )
       
  7140                     {
       
  7141                     DoCompoundNodeBeginKeyL( children, &aFocusedNode );
       
  7142                     }
       
  7143                 if ( aKeyEvent.iScanCode == EStdKeyRightArrow )
       
  7144                     {
       
  7145                     DoCompoundNodeEndKeyL( children, &aFocusedNode );
       
  7146                     }
       
  7147                 }
       
  7148             else if ( *direction == XnPropertyNames::style::common::direction::KRTL &&
       
  7149                       ( *orientation == XnPropertyNames::style::common::block_progression::KLR ||
       
  7150                         *orientation == XnPropertyNames::style::common::block_progression::KRL ) )
       
  7151                 {
       
  7152                 if ( aKeyEvent.iScanCode == EStdKeyLeftArrow )
       
  7153                     {
       
  7154                     DoCompoundNodeEndKeyL( children, &aFocusedNode );
       
  7155                     }
       
  7156                 if ( aKeyEvent.iScanCode == EStdKeyRightArrow )
       
  7157                     {
       
  7158                     DoCompoundNodeBeginKeyL( children, &aFocusedNode );
       
  7159                     }
       
  7160                 }
       
  7161             else if ( *direction == XnPropertyNames::style::common::direction::KLTR &&
       
  7162                       *orientation == XnPropertyNames::style::common::block_progression::KTB )
       
  7163                 {
       
  7164                 if ( aKeyEvent.iScanCode == EStdKeyUpArrow )
       
  7165                     {
       
  7166                     DoCompoundNodeBeginKeyL( children, &aFocusedNode );
       
  7167                     }
       
  7168                 else if ( aKeyEvent.iScanCode == EStdKeyDownArrow )
       
  7169                     {
       
  7170                     DoCompoundNodeEndKeyL( children, &aFocusedNode );
       
  7171                     }
       
  7172                 }
       
  7173             else if ( *direction == XnPropertyNames::style::common::direction::KRTL &&
       
  7174                       *orientation == XnPropertyNames::style::common::block_progression::KTB )
       
  7175                 {
       
  7176                 if ( aKeyEvent.iScanCode == EStdKeyDownArrow )
       
  7177                     {
       
  7178                     DoCompoundNodeBeginKeyL( children, &aFocusedNode );
       
  7179                     }
       
  7180                 else if ( aKeyEvent.iScanCode == EStdKeyUpArrow )
       
  7181                     {
       
  7182                     DoCompoundNodeEndKeyL( children, &aFocusedNode );
       
  7183                     }
       
  7184                 }
       
  7185             }
       
  7186         }
       
  7187     }
       
  7188 
       
  7189 // -----------------------------------------------------------------------------
       
  7190 // BuildTriggerNodeL
       
  7191 // Builds a trigger node
       
  7192 // -----------------------------------------------------------------------------
       
  7193 //
       
  7194 static CXnNode* BuildTriggerNodeL(
       
  7195     CXnUiEngine& aUiEngine,
       
  7196     const TDesC8& aTriggerName )
       
  7197     {
       
  7198     CXnNode* node = CXnNode::NewL();
       
  7199     CleanupStack::PushL( node );
       
  7200     CXnType* type = CXnType::NewL( XnPropertyNames::action::KTrigger );
       
  7201     CleanupStack::PushL( type );
       
  7202     CXnNodeImpl* impl = CXnNodeImpl::NewL( type );
       
  7203     CleanupStack::Pop( type );
       
  7204     node->SetImpl( impl );
       
  7205     node->SetUiEngine( aUiEngine );
       
  7206     CXnDomPropertyValue* nameValue =
       
  7207         CXnDomPropertyValue::NewL( aUiEngine.ODT()->DomDocument().StringPool() );
       
  7208     CleanupStack::PushL( nameValue );
       
  7209     nameValue->SetStringValueL( CXnDomPropertyValue::EString, aTriggerName );
       
  7210     CXnProperty* name = CXnProperty::NewL(
       
  7211         XnPropertyNames::action::trigger::KName,
       
  7212         nameValue,
       
  7213         aUiEngine.ODT()->DomDocument().StringPool() );
       
  7214     CleanupStack::Pop( nameValue );
       
  7215     CleanupStack::PushL( name );
       
  7216     node->SetPropertyL( name );
       
  7217     CleanupStack::Pop( name );
       
  7218     CleanupStack::Pop( node );
       
  7219     return node;
       
  7220     }
       
  7221 
       
  7222 // ============================ MEMBER FUNCTIONS ===============================
       
  7223 
       
  7224 // -----------------------------------------------------------------------------
       
  7225 // CXnNodeImpl::NewL()
       
  7226 // Two-phased constructor.
       
  7227 // -----------------------------------------------------------------------------
       
  7228 //
       
  7229 CXnNodeImpl* CXnNodeImpl::NewL( CXnType* aType )
       
  7230     {
       
  7231     CXnNodeImpl* self = new ( ELeave ) CXnNodeImpl;
       
  7232 
       
  7233     CleanupStack::PushL( self );
       
  7234     self->ConstructL( aType );
       
  7235     CleanupStack::Pop();
       
  7236 
       
  7237     return self;
       
  7238     }
       
  7239 
       
  7240 // -----------------------------------------------------------------------------
       
  7241 // CXnNodeImpl::ConstructL()
       
  7242 // Symbian 2nd phase constructor can leave.
       
  7243 // -----------------------------------------------------------------------------
       
  7244 //
       
  7245 void CXnNodeImpl::ConstructL( CXnType* aType )
       
  7246     {
       
  7247     iType = aType;
       
  7248     iPropertyList = CXnPropertyList::NewL();
       
  7249     iLayoutCapable = ETrue;
       
  7250     iHandleTooltip = ETrue;
       
  7251     }
       
  7252 
       
  7253 // -----------------------------------------------------------------------------
       
  7254 // CXnNodeImpl::CXnNodeImpl()
       
  7255 // C++ default constructor can NOT contain any code, that
       
  7256 // might leave.
       
  7257 // -----------------------------------------------------------------------------
       
  7258 //
       
  7259 CXnNodeImpl::CXnNodeImpl()
       
  7260     : iDropped( 0 ), iChildren( 1 ), iAdaptive( 0 )
       
  7261     {
       
  7262     }
       
  7263 
       
  7264 // -----------------------------------------------------------------------------
       
  7265 // CXnNodeImpl::~CXnNodeImpl()
       
  7266 // C++ default destructor.
       
  7267 // -----------------------------------------------------------------------------
       
  7268 //
       
  7269 CXnNodeImpl::~CXnNodeImpl()
       
  7270     {
       
  7271     delete iPropertyList;
       
  7272     delete iType;
       
  7273     iPropertyPseudoClasses.Reset();
       
  7274     iStates.Reset();
       
  7275     iChildren.ResetAndDestroy();
       
  7276     delete iGridPropertyCache;
       
  7277     delete iLayoutPropertyCache;
       
  7278     DeletePeriodic();
       
  7279     }
       
  7280 
       
  7281 // -----------------------------------------------------------------------------
       
  7282 // CXnNodeImpl::SetNode
       
  7283 // -----------------------------------------------------------------------------
       
  7284 //
       
  7285 void CXnNodeImpl::SetNode( CXnNode& aNode )
       
  7286     {
       
  7287     iNode = &aNode;
       
  7288     }
       
  7289 
       
  7290 // -----------------------------------------------------------------------------
       
  7291 // CXnNodeImpl::Node
       
  7292 // -----------------------------------------------------------------------------
       
  7293 //
       
  7294 CXnNode* CXnNodeImpl::Node()
       
  7295     {
       
  7296     return iNode;
       
  7297     }
       
  7298 
       
  7299 // -----------------------------------------------------------------------------
       
  7300 // CXnNodeImpl::SetRect
       
  7301 // -----------------------------------------------------------------------------
       
  7302 //
       
  7303 void CXnNodeImpl::SetRect( const TRect& aRect )
       
  7304     {
       
  7305     iRect = aRect;
       
  7306     }
       
  7307 
       
  7308 // -----------------------------------------------------------------------------
       
  7309 // CXnNodeImpl::Rect
       
  7310 // -----------------------------------------------------------------------------
       
  7311 //
       
  7312 TRect CXnNodeImpl::Rect()
       
  7313     {
       
  7314     return AdjustRectIfNeeded(iRect);
       
  7315     }
       
  7316 
       
  7317 // -----------------------------------------------------------------------------
       
  7318 // CXnNodeImpl::SetBorderRect
       
  7319 // -----------------------------------------------------------------------------
       
  7320 //
       
  7321 void CXnNodeImpl::SetBorderRect( const TRect& aRect )
       
  7322     {
       
  7323     iBorderRect = aRect;
       
  7324     }
       
  7325 
       
  7326 // -----------------------------------------------------------------------------
       
  7327 // CXnNodeImpl::BorderRect
       
  7328 // -----------------------------------------------------------------------------
       
  7329 //
       
  7330 TRect CXnNodeImpl::BorderRect()
       
  7331     {
       
  7332     return AdjustRectIfNeeded(iBorderRect);
       
  7333     }
       
  7334 
       
  7335 // -----------------------------------------------------------------------------
       
  7336 // CXnNodeImpl::SetNormalFlowBorderRect
       
  7337 // -----------------------------------------------------------------------------
       
  7338 //
       
  7339 void CXnNodeImpl::SetNormalFlowBorderRect( const TRect& aRect )
       
  7340     {
       
  7341     iNormalFlowBorderRect = aRect;
       
  7342     }
       
  7343 
       
  7344 // -----------------------------------------------------------------------------
       
  7345 // CXnNodeImpl::NormalFlowBorderRect
       
  7346 // -----------------------------------------------------------------------------
       
  7347 //
       
  7348 TRect CXnNodeImpl::NormalFlowBorderRect()
       
  7349     {
       
  7350     return AdjustRectIfNeeded(iNormalFlowBorderRect);
       
  7351     }
       
  7352 
       
  7353 // -----------------------------------------------------------------------------
       
  7354 // CXnNodeImpl::SetMarginRect
       
  7355 // -----------------------------------------------------------------------------
       
  7356 //
       
  7357 void CXnNodeImpl::SetMarginRect( const TRect& aRect )
       
  7358     {
       
  7359     iMarginRect = aRect;
       
  7360     }
       
  7361 
       
  7362 // -----------------------------------------------------------------------------
       
  7363 // CXnNodeImpl::MarginRect
       
  7364 // -----------------------------------------------------------------------------
       
  7365 //
       
  7366 TRect CXnNodeImpl::MarginRect()
       
  7367     {
       
  7368     return AdjustRectIfNeeded(iMarginRect);
       
  7369     }
       
  7370 
       
  7371 // -----------------------------------------------------------------------------
       
  7372 // CXnNodeImpl::SetPaddingRect
       
  7373 // -----------------------------------------------------------------------------
       
  7374 //
       
  7375 void CXnNodeImpl::SetPaddingRect( const TRect& aRect )
       
  7376     {
       
  7377     iPaddingRect = aRect;
       
  7378     }
       
  7379 
       
  7380 // -----------------------------------------------------------------------------
       
  7381 // CXnNodeImpl::PaddingRect
       
  7382 // -----------------------------------------------------------------------------
       
  7383 //
       
  7384 TRect CXnNodeImpl::PaddingRect()
       
  7385     {
       
  7386     return AdjustRectIfNeeded(iPaddingRect);
       
  7387     }
       
  7388 
       
  7389 // -----------------------------------------------------------------------------
       
  7390 // CXnNodeImpl::Type()
       
  7391 // Returns control type.
       
  7392 // -----------------------------------------------------------------------------
       
  7393 //
       
  7394 CXnType* CXnNodeImpl::Type()
       
  7395     {
       
  7396     return iType;
       
  7397     }
       
  7398 
       
  7399 // -----------------------------------------------------------------------------
       
  7400 // CXnNodeImpl::Parent
       
  7401 // Get component parent
       
  7402 // -----------------------------------------------------------------------------
       
  7403 //
       
  7404 CXnNode* CXnNodeImpl::Parent() const
       
  7405     {
       
  7406     return iParent;
       
  7407     }
       
  7408 
       
  7409 // -----------------------------------------------------------------------------
       
  7410 // CXnNodeImpl::SetParent
       
  7411 // Set component parent
       
  7412 // -----------------------------------------------------------------------------
       
  7413 //
       
  7414 void CXnNodeImpl::SetParent( CXnNode& aParent )
       
  7415     {
       
  7416     iParent = &aParent;
       
  7417     }
       
  7418 
       
  7419 // -----------------------------------------------------------------------------
       
  7420 // CXnNodeImpl::AddChildL
       
  7421 // Adds a child to this container.
       
  7422 // -----------------------------------------------------------------------------
       
  7423 //
       
  7424 void CXnNodeImpl::AddChildL( CXnNode* aChild )
       
  7425     {
       
  7426     TInt err = iChildren.Append( aChild );
       
  7427     if ( err != KErrNone )
       
  7428         {
       
  7429         User::Leave( KXnErrAddChildToAreaFailed );
       
  7430         }
       
  7431     aChild->SetParent( *iNode );
       
  7432     }
       
  7433 
       
  7434 // -----------------------------------------------------------------------------
       
  7435 // CXnNodeImpl::Children
       
  7436 // -----------------------------------------------------------------------------
       
  7437 //
       
  7438 RPointerArray< CXnNode >& CXnNodeImpl::Children()
       
  7439     {
       
  7440     return iChildren;
       
  7441     }
       
  7442 
       
  7443 // -----------------------------------------------------------------------------
       
  7444 // CXnNodeImpl::SetPCDataL
       
  7445 // Set a property.
       
  7446 // -----------------------------------------------------------------------------
       
  7447 //
       
  7448 void CXnNodeImpl::SetPCDataL( const TDesC8& aData )
       
  7449     {
       
  7450     iDomNode->SetPCDataL( aData );
       
  7451 
       
  7452     SetDirtyL( XnDirtyLevel::ERender );
       
  7453 
       
  7454     CXnDomStringPool& sp( iDomNode->StringPool() );
       
  7455 
       
  7456     CXnDomPropertyValue* newValue = CXnDomPropertyValue::NewL( sp );
       
  7457     CleanupStack::PushL( newValue );
       
  7458     newValue->SetStringValueL( CXnDomPropertyValue::EString, KNullDesC8 );
       
  7459     // create property
       
  7460     CXnProperty* prop = CXnProperty::NewL(
       
  7461         XnPropertyNames::common::KPCData, newValue, sp );
       
  7462     CleanupStack::Pop( newValue );
       
  7463     CleanupStack::PushL( prop );
       
  7464 
       
  7465     InformPropertyChangeL( *iNode, prop );
       
  7466 
       
  7467     CleanupStack::PopAndDestroy( prop );
       
  7468     }
       
  7469 
       
  7470 // -----------------------------------------------------------------------------
       
  7471 // CXnNodeImpl::GetPCData
       
  7472 // Set a property.
       
  7473 // -----------------------------------------------------------------------------
       
  7474 //
       
  7475 const TDesC8& CXnNodeImpl::GetPCData()
       
  7476     {
       
  7477     if ( iRef )
       
  7478         {
       
  7479         CXnNode* refNode( NULL );
       
  7480         TRAP_IGNORE( refNode = RefNodeL( this, iRef, iUiEngine ) );
       
  7481 
       
  7482         if ( refNode )
       
  7483             {
       
  7484             return refNode->GetPCData();
       
  7485             }
       
  7486         }
       
  7487 
       
  7488     return iDomNode->PCData();
       
  7489     }
       
  7490 
       
  7491 // -----------------------------------------------------------------------------
       
  7492 // CXnNodeImpl::SetHandleTooltip()
       
  7493 // Sets wheter to handle tooltips
       
  7494 // -----------------------------------------------------------------------------
       
  7495 //
       
  7496 void CXnNodeImpl::SetHandleTooltip( TBool aFlag )
       
  7497     {
       
  7498     iHandleTooltip = aFlag;
       
  7499     }
       
  7500 
       
  7501 // -----------------------------------------------------------------------------
       
  7502 // CXnNodeImpl::ShowPopupsL()
       
  7503 // Searchs and shoes tooltips
       
  7504 // -----------------------------------------------------------------------------
       
  7505 //
       
  7506 void CXnNodeImpl::ShowPopupsL( TRect aRect, TInt aSource )
       
  7507     {
       
  7508     if ( iHandleTooltip )
       
  7509         {
       
  7510         for ( TInt i = 0; i < iChildren.Count(); i++ )
       
  7511             {
       
  7512             CXnNode* node( iChildren[i] );
       
  7513 
       
  7514             if ( node->Type()->Type() == KToolTip )
       
  7515                 {
       
  7516                 CXnNodeAppIf& tooltipNode( node->AppIfL() );
       
  7517                 CXnPopup* popup( NULL );
       
  7518 
       
  7519                 XnComponentInterface::MakeInterfaceL( popup, tooltipNode );
       
  7520 
       
  7521                 if ( popup )
       
  7522                     {
       
  7523                     if ( aSource == XnEventSource::EStylus )
       
  7524                         {
       
  7525                         const TTimeIntervalMicroSeconds32 delay( 0 );                       
       
  7526                         const TTimeIntervalMicroSeconds32 display( 1000 * 1000 * 6 );                                                
       
  7527                         
       
  7528                         popup->ShowPopupL( aRect, delay, display );
       
  7529                         }
       
  7530                     else
       
  7531                         {
       
  7532                         popup->ShowPopupL( aRect );
       
  7533                         }                    
       
  7534                     }
       
  7535                 }
       
  7536             }
       
  7537         }
       
  7538     }
       
  7539 
       
  7540 // -----------------------------------------------------------------------------
       
  7541 // CXnNodeImpl::HidePopupsL()
       
  7542 // Searchs and hides tooltips
       
  7543 // -----------------------------------------------------------------------------
       
  7544 //
       
  7545 void CXnNodeImpl::HidePopupsL()
       
  7546     {
       
  7547     if ( iHandleTooltip )
       
  7548         {
       
  7549         for ( TInt i = 0; i < iChildren.Count(); i++ )
       
  7550             {
       
  7551             CXnNode* node( iChildren[i] );
       
  7552 
       
  7553             if ( node->Type()->Type() == KToolTip )
       
  7554                 {
       
  7555                 CXnNodeAppIf& tooltipNode( node->AppIfL() );
       
  7556                 CXnPopup* popup( NULL );
       
  7557 
       
  7558                 XnComponentInterface::MakeInterfaceL( popup, tooltipNode );
       
  7559 
       
  7560                 if ( popup )
       
  7561                     {
       
  7562                     popup->HidePopupL();
       
  7563                     }
       
  7564                 }
       
  7565             }
       
  7566         }
       
  7567     }
       
  7568 
       
  7569 // -----------------------------------------------------------------------------
       
  7570 // CXnNodeImpl::SetPropertyL
       
  7571 // Sets a property, informs property change and builds trigger.
       
  7572 // -----------------------------------------------------------------------------
       
  7573 //
       
  7574 void CXnNodeImpl::SetPropertyL( CXnProperty* aProperty, TBool aNotify )
       
  7575     {
       
  7576     TInt level( DoSetPropertyL( aProperty ) );
       
  7577 
       
  7578     if ( !aNotify || level == XnDirtyLevel::ENone )
       
  7579         {
       
  7580         // all done
       
  7581         return;
       
  7582         }
       
  7583 
       
  7584     InformPropertyChangeL( *iNode, aProperty );
       
  7585 
       
  7586     if ( iLayoutCapable && iNode->Parent() )
       
  7587         {
       
  7588         const TDesC8* value( NULL );
       
  7589         const TDesC8& name( aProperty->Property()->Name() );
       
  7590         TBool informChildren( EFalse );
       
  7591 
       
  7592         if ( name == XnPropertyNames::style::common::KDisplay )
       
  7593             {
       
  7594             value = &XnPropertyNames::style::common::display::KNone;
       
  7595             informChildren = ETrue;
       
  7596             }
       
  7597         else if ( name == XnPropertyNames::style::common::KVisibility )
       
  7598             {
       
  7599             value = &XnPropertyNames::style::common::visibility::KHidden;
       
  7600             informChildren = ETrue;
       
  7601             }
       
  7602 
       
  7603         if ( value )
       
  7604             {
       
  7605             if ( *value == aProperty->StringValue() )
       
  7606                 {
       
  7607                 CXnNode* loseVisualisation(
       
  7608                     BuildTriggerNodeL(
       
  7609                         *iUiEngine,
       
  7610                         XnPropertyNames::action::trigger::name::KLoseVisualisation ) );
       
  7611 
       
  7612                 CleanupStack::PushL( loseVisualisation );
       
  7613 
       
  7614                 CXnNode* focused( iUiEngine->FocusedNode() );
       
  7615 
       
  7616                 for ( CXnNode* node = focused; node; node = node->Parent() )
       
  7617                     {
       
  7618                     if ( node == iNode )
       
  7619                         {
       
  7620                         // Focus is either in this node or
       
  7621                         // somewhere in this node's childrens
       
  7622                         focused->UnsetStateL(
       
  7623                             XnPropertyNames::style::common::KFocus );
       
  7624 
       
  7625                         focused->UnsetStateL(
       
  7626                             XnPropertyNames::style::common::KHold );
       
  7627 
       
  7628                         focused->UnsetStateL(
       
  7629                             XnPropertyNames::style::common::KActive );
       
  7630 
       
  7631                         // Report losevisualisation to focused node if the node
       
  7632                         // is 'visualisationaware'
       
  7633                         CXnProperty* visaware = GetPropertyL(
       
  7634                             XnPropertyNames::common::KVisualisationAware );
       
  7635 
       
  7636                         if ( visaware && visaware->StringValue() ==
       
  7637                              XnPropertyNames::KTrue )
       
  7638                             {
       
  7639                             focused->ReportXuikonEventL( *loseVisualisation );
       
  7640                             }
       
  7641 
       
  7642                         break;
       
  7643                         }
       
  7644                     }
       
  7645 
       
  7646                 if ( focused != iNode )
       
  7647                     {
       
  7648                     // Report losevisualisation to this node if the node
       
  7649                     // is 'visualisationaware'
       
  7650                     CXnProperty* visaware = GetPropertyL(
       
  7651                         XnPropertyNames::common::KVisualisationAware );
       
  7652                     if ( visaware && visaware->StringValue() ==
       
  7653                          XnPropertyNames::KTrue )
       
  7654                         {
       
  7655                         iNode->ReportXuikonEventL( *loseVisualisation );
       
  7656                         }
       
  7657                     }
       
  7658 
       
  7659                 CleanupStack::PopAndDestroy( loseVisualisation );
       
  7660                 }
       
  7661             else
       
  7662                 {
       
  7663                 if ( !iUiEngine->FocusedNode() )
       
  7664                     {
       
  7665                     CXnNode* node( IsNodeNavigableL( Node() ) );
       
  7666 
       
  7667                     if ( node )
       
  7668                         {
       
  7669                         // This node can be focused
       
  7670                         iUiEngine->AddFocusCandidateL( node );
       
  7671                         }
       
  7672                     }
       
  7673                 }
       
  7674             }
       
  7675 
       
  7676         if ( informChildren && ( iNode->Children().Count() > 0 ) )
       
  7677             {
       
  7678             //we have already done inform for the parent, so EFalse
       
  7679             InformChildrenPropertyChangeL( *iNode, aProperty, EFalse );
       
  7680             }
       
  7681         }
       
  7682     }
       
  7683 
       
  7684 // -----------------------------------------------------------------------------
       
  7685 // CXnNodeImpl::SetPropertyWithoutNotificationL
       
  7686 // Sets a property.
       
  7687 // -----------------------------------------------------------------------------
       
  7688 //
       
  7689 void CXnNodeImpl::SetPropertyWithoutNotificationL( CXnProperty* aProperty )
       
  7690     {
       
  7691     SetPropertyL( aProperty, EFalse );
       
  7692     }
       
  7693 
       
  7694 // -----------------------------------------------------------------------------
       
  7695 // CXnNodeImpl::SetPropertyArrayL
       
  7696 // Sets an array of properties and after all the properties are set informs
       
  7697 // property change.
       
  7698 // -----------------------------------------------------------------------------
       
  7699 //
       
  7700 void CXnNodeImpl::SetPropertyArrayL(
       
  7701     RPointerArray< CXnProperty >& aPropertyArray )
       
  7702     {
       
  7703     TBool informPropertyChange( EFalse );
       
  7704 
       
  7705     TInt count( aPropertyArray.Count() );
       
  7706 
       
  7707     iUiEngine->DisableRenderUiLC();
       
  7708 
       
  7709     for ( TInt i = 0; i < count; i++ )
       
  7710         {
       
  7711         CXnProperty* aProp( aPropertyArray[i] );
       
  7712 
       
  7713         const TDesC8& name( aProp->Property()->Name() );
       
  7714 
       
  7715         if ( name == XnPropertyNames::style::common::KDisplay ||
       
  7716              name == XnPropertyNames::style::common::KVisibility )
       
  7717             {
       
  7718             SetPropertyL( aProp );
       
  7719             }
       
  7720         else
       
  7721             {
       
  7722             SetPropertyL( aProp, EFalse );
       
  7723             informPropertyChange = ETrue;
       
  7724             }
       
  7725         }
       
  7726 
       
  7727     if ( informPropertyChange )
       
  7728         {
       
  7729         InformPropertyChangeL( *iNode, NULL );
       
  7730         }
       
  7731 
       
  7732     CleanupStack::PopAndDestroy();
       
  7733     }
       
  7734 
       
  7735 // -----------------------------------------------------------------------------
       
  7736 // CXnNodeImpl::DoSetPropertyL
       
  7737 // Does the actual property update
       
  7738 // -----------------------------------------------------------------------------
       
  7739 //
       
  7740 TInt CXnNodeImpl::DoSetPropertyL( CXnProperty* aProperty )
       
  7741     {
       
  7742     TInt level( XnDirtyLevel::ENone );
       
  7743 
       
  7744     const TDesC8* refid( CheckRefAttributeL( iRef ) );
       
  7745 
       
  7746     if ( refid && aProperty->Property()->Name() != XnPropertyNames::common::KId )
       
  7747         {
       
  7748         delete aProperty;
       
  7749 
       
  7750         return level;
       
  7751         }
       
  7752 
       
  7753     const TDesC8& name( aProperty->Property()->Name() );
       
  7754 
       
  7755     CXnProperty* prop( GetPropertyL( name ) );
       
  7756 
       
  7757     if ( prop && prop->EqualsL( *aProperty ) )
       
  7758         {
       
  7759         // No change in the property value
       
  7760         delete aProperty;
       
  7761 
       
  7762         return level;
       
  7763         }
       
  7764 
       
  7765     level = DirtyLevelFromPropertyL( *iNode, name );
       
  7766 
       
  7767     // Save the displayed state, before setting the property
       
  7768     TBool isDisplayed( IsNodeDisplayedL( *iNode ) );
       
  7769 
       
  7770     CXnDomProperty::TPseudoClass pseudoClass( aProperty->Property()->PseudoClass() );
       
  7771 
       
  7772     if ( pseudoClass != CXnDomProperty::ENone )
       
  7773         {
       
  7774         InsertPropertyPseudoClassL( pseudoClass, iPropertyPseudoClasses );
       
  7775 
       
  7776         if ( IsStateSet( PseudoClassName( pseudoClass ) ) )
       
  7777             {
       
  7778             SetCachedProperty(
       
  7779                 aProperty,
       
  7780                 iLayoutPropertyCache,
       
  7781                 iRef,
       
  7782                 iName,
       
  7783                 iValue,
       
  7784                 iLabel,
       
  7785                 iInitialFocus,
       
  7786                 iClass,
       
  7787                 iId,
       
  7788                 iPath,
       
  7789                 iMaskPath,
       
  7790                 iGridPropertyCache,
       
  7791                 EFalse,
       
  7792                 EFalse );
       
  7793             }
       
  7794         }
       
  7795     else
       
  7796         {
       
  7797         SetCachedProperty(
       
  7798             aProperty,
       
  7799             iLayoutPropertyCache,
       
  7800             iRef,
       
  7801             iName,
       
  7802             iValue,
       
  7803             iLabel,
       
  7804             iInitialFocus,
       
  7805             iClass,
       
  7806             iId,
       
  7807             iPath,
       
  7808             iMaskPath,
       
  7809             iGridPropertyCache,
       
  7810             EFalse,
       
  7811             EFalse );
       
  7812         }
       
  7813 
       
  7814     iPropertyList->SetPropertyL( aProperty );
       
  7815 
       
  7816     TBool isDisplayedNow( IsNodeDisplayedL( *iNode ) );
       
  7817 
       
  7818     level = ( iAdaptive & XnAdaptive::EIgnoreDirty ) ? XnDirtyLevel::ENone : level;
       
  7819 
       
  7820     // This is from layout calculation point of view
       
  7821     TBool displayed( ETrue );
       
  7822 
       
  7823     if ( isDisplayed && !isDisplayedNow )
       
  7824         {
       
  7825         // Node loses its visualisation (either display: none, or 
       
  7826         // visibility: hidden) Make sure control is hidden
       
  7827         CCoeControl* ctrl( iNode->Control() );
       
  7828 
       
  7829         if ( ctrl )
       
  7830             {
       
  7831             ctrl->MakeVisible( EFalse );
       
  7832             }
       
  7833         }
       
  7834     else if ( !isDisplayed && isDisplayedNow )
       
  7835         {
       
  7836         // Node gains its visualisation (both display: block, and
       
  7837         // visibility: visible)
       
  7838         // Run gainvisualisation trigger, if node is 'visualisationaware'
       
  7839         CXnProperty* visaware(
       
  7840                 GetPropertyL( XnPropertyNames::common::KVisualisationAware ) );
       
  7841 
       
  7842         if ( visaware && visaware->StringValue() == XnPropertyNames::KTrue )
       
  7843             {
       
  7844             CXnNode* gainVisualisation( BuildTriggerNodeL( *iUiEngine,
       
  7845                 XnPropertyNames::action::trigger::name::KGainVisualisation ) );
       
  7846             CleanupStack::PushL( gainVisualisation );
       
  7847             iNode->ReportXuikonEventL( *gainVisualisation );
       
  7848             CleanupStack::PopAndDestroy( gainVisualisation );
       
  7849             }
       
  7850         }
       
  7851     else if ( !isDisplayed && !isDisplayedNow )
       
  7852         {
       
  7853         // No change
       
  7854         displayed = EFalse;
       
  7855         }
       
  7856 
       
  7857     SetDirtyL( level, displayed );
       
  7858 
       
  7859     return level;
       
  7860     }
       
  7861 
       
  7862 // -----------------------------------------------------------------------------
       
  7863 // CXnNodeImpl::InitializePropertyL
       
  7864 // Set a property.
       
  7865 // -----------------------------------------------------------------------------
       
  7866 //
       
  7867 void CXnNodeImpl::InitializePropertyL( CXnProperty* aProperty )
       
  7868     {
       
  7869     const TDesC8* refid( CheckRefAttributeL( iRef ) );
       
  7870 
       
  7871     if ( refid && aProperty->Property()->Name() != XnPropertyNames::common::KId )
       
  7872         {
       
  7873         delete aProperty;
       
  7874 
       
  7875         return;
       
  7876         }
       
  7877 
       
  7878     if ( aProperty->Property()->PseudoClass() != CXnDomProperty::ENone )
       
  7879         {
       
  7880         InsertPropertyPseudoClassL(
       
  7881             aProperty->Property()->PseudoClass(), iPropertyPseudoClasses );
       
  7882 
       
  7883         SetCachedProperty(
       
  7884             aProperty,
       
  7885             iLayoutPropertyCache,
       
  7886             iRef,
       
  7887             iName,
       
  7888             iValue,
       
  7889             iLabel,
       
  7890             iInitialFocus,
       
  7891             iClass,
       
  7892             iId,
       
  7893             iPath,
       
  7894             iMaskPath,
       
  7895             iGridPropertyCache,
       
  7896             ETrue,
       
  7897             ETrue );
       
  7898         }
       
  7899     else
       
  7900         {
       
  7901         SetCachedProperty(
       
  7902             aProperty,
       
  7903             iLayoutPropertyCache,
       
  7904             iRef,
       
  7905             iName,
       
  7906             iValue,
       
  7907             iLabel,
       
  7908             iInitialFocus,
       
  7909             iClass,
       
  7910             iId,
       
  7911             iPath,
       
  7912             iMaskPath,
       
  7913             iGridPropertyCache,
       
  7914             ETrue,
       
  7915             EFalse );
       
  7916         }
       
  7917 
       
  7918     iPropertyList->SetPropertyL( aProperty );
       
  7919     }
       
  7920 
       
  7921 // -----------------------------------------------------------------------------
       
  7922 // CXnNodeImpl::GetPropertyL
       
  7923 // Gets a property.
       
  7924 // -----------------------------------------------------------------------------
       
  7925 //
       
  7926 CXnProperty* CXnNodeImpl::GetPropertyL( const TDesC8& aKey )
       
  7927     {
       
  7928     CXnNode* refNode( RefNodeL( this, iRef, iUiEngine ) ) ;
       
  7929 
       
  7930     if ( refNode && aKey != KRef && aKey != KId )
       
  7931         {
       
  7932         return refNode->GetPropertyL( aKey );
       
  7933         }
       
  7934 
       
  7935     CXnDomProperty* attribute = NULL;
       
  7936     CXnProperty* property = iPropertyList->GetProperty( aKey );
       
  7937 
       
  7938     if ( property )
       
  7939         {
       
  7940         attribute = property->Property();
       
  7941         CXnDomList& list = attribute->PropertyValueList();
       
  7942 
       
  7943         if ( list.Length() == 0 )
       
  7944             {
       
  7945             return NULL;
       
  7946             }
       
  7947 
       
  7948         CXnDomPropertyValue* attributeValue =
       
  7949             static_cast< CXnDomPropertyValue* >( list.Item( 0 ) );
       
  7950 
       
  7951         if ( !attributeValue )
       
  7952             {
       
  7953             return NULL;
       
  7954             }
       
  7955 
       
  7956         if ( attributeValue->IsInheritIdent() && iParent )
       
  7957             {
       
  7958             // inherited values are queried from the parent
       
  7959             property = iParent->GetPropertyL( aKey );
       
  7960             }
       
  7961 
       
  7962         // otherwise just return the value
       
  7963         return property;
       
  7964         }
       
  7965 
       
  7966     // if not found, return NULL
       
  7967     return NULL;
       
  7968     }
       
  7969 
       
  7970 // -----------------------------------------------------------------------------
       
  7971 // CXnNodeImpl::SetStateL
       
  7972 // Set a pseudoclass
       
  7973 // -----------------------------------------------------------------------------
       
  7974 //
       
  7975 void CXnNodeImpl::SetStateL( const TDesC8& aState, TInt aSource )    
       
  7976     {
       
  7977     if ( IsStateSet( aState ) )
       
  7978         {
       
  7979         return;
       
  7980         }
       
  7981 
       
  7982     TBool focusReceived( EFalse );
       
  7983     TBool activated( EFalse );
       
  7984     TBool stateChanged( EFalse );
       
  7985 
       
  7986     if ( aState == XnPropertyNames::action::trigger::name::KFocus )
       
  7987         {
       
  7988         if ( !iUiEngine->AppUiAdapter().FocusShown() )
       
  7989             {
       
  7990             return;
       
  7991             }
       
  7992         
       
  7993         focusReceived = DoReceiveFocusL( *iNode, *iUiEngine );
       
  7994 
       
  7995         if ( focusReceived )
       
  7996             {
       
  7997             // focused
       
  7998             HidePopupsL();
       
  7999             ShowPopupsL( iNode->Rect(), aSource );
       
  8000 
       
  8001             if ( IsStateSet( XnPropertyNames::action::trigger::name::KPassiveFocus ) )
       
  8002                 {
       
  8003                 iUiEngine->RemovePassiveFocusedNodeL( iNode );
       
  8004                 }
       
  8005 
       
  8006             stateChanged = focusReceived = iPropertyList->SetStateL( aState );            
       
  8007             }
       
  8008         }
       
  8009     else if ( aState == XnPropertyNames::style::common::KPressedDown )
       
  8010         {
       
  8011         if ( IsStateSet( XnPropertyNames::action::trigger::name::KFocus ) )
       
  8012             {
       
  8013             iPropertyList->SetStateL( 
       
  8014                 XnPropertyNames::style::common::KPressedDown );
       
  8015             iNode->SetDirtyL( XnDirtyLevel::ERender );            
       
  8016             }
       
  8017         }        
       
  8018     else if ( aState == XnPropertyNames::style::common::KActive )
       
  8019         {
       
  8020         activated = ETrue;
       
  8021         }
       
  8022     else if ( aState == XnPropertyNames::action::trigger::name::KPassiveFocus )
       
  8023         {
       
  8024         // is focusable node
       
  8025         if ( DoReceiveFocusL( *iNode, *iUiEngine ) )
       
  8026             {
       
  8027             // focused
       
  8028             stateChanged = iPropertyList->SetStateL( aState );
       
  8029             }
       
  8030         }
       
  8031     else
       
  8032         {
       
  8033         stateChanged = iPropertyList->SetStateL( aState );
       
  8034         }
       
  8035 
       
  8036     if ( stateChanged )
       
  8037         {
       
  8038         CXnDomProperty::TPseudoClass pseudoClass( PseudoClassFromName( aState ) );
       
  8039 
       
  8040         if ( pseudoClass != CXnDomProperty::ENone )
       
  8041             {
       
  8042             iStates.Append( pseudoClass );
       
  8043             
       
  8044             // Ensure that pseudo class is defined
       
  8045             InsertPropertyPseudoClassL( pseudoClass, iPropertyPseudoClasses );
       
  8046 
       
  8047             if ( IsPropertyPseudoClass( pseudoClass, iPropertyPseudoClasses ) )
       
  8048                 {
       
  8049                 EnableStatePropertiesL( *iNode, pseudoClass, iLayoutPropertyCache );
       
  8050 
       
  8051                 InformPropertyChangeL( *iNode );
       
  8052                 }
       
  8053             }
       
  8054         
       
  8055         if ( aState == XnPropertyNames::style::common::KPressedDown )            
       
  8056             {
       
  8057             iNode->SetDirtyL( XnDirtyLevel::ERender );
       
  8058             }
       
  8059         }
       
  8060 
       
  8061     if ( focusReceived && aState == XnPropertyNames::action::trigger::name::KFocus )
       
  8062         {                
       
  8063         iUiEngine->SetFocusedNodeL( iNode, aSource );
       
  8064         }
       
  8065 
       
  8066     if ( activated )
       
  8067         {
       
  8068         DoSetActiveL( *iNode, *iUiEngine );
       
  8069         }
       
  8070 
       
  8071     if ( stateChanged )
       
  8072         {
       
  8073         iUiEngine->RenderUIL();
       
  8074         }
       
  8075     }
       
  8076 
       
  8077 // -----------------------------------------------------------------------------
       
  8078 // CXnNodeImpl::IsStateSet
       
  8079 // Check whether a state is set or not
       
  8080 // -----------------------------------------------------------------------------
       
  8081 //
       
  8082 TBool CXnNodeImpl::IsStateSet( const TDesC8& aState )
       
  8083     {
       
  8084     return iPropertyList->IsStateSet( aState );
       
  8085     }
       
  8086 
       
  8087 // -----------------------------------------------------------------------------
       
  8088 // CXnNodeImpl::SetStateWithoutNotificationL
       
  8089 // Set a pseudoclass
       
  8090 // -----------------------------------------------------------------------------
       
  8091 //
       
  8092 void CXnNodeImpl::SetStateWithoutNotificationL( const TDesC8& aState )
       
  8093     {
       
  8094     if ( IsStateSet( aState ) )
       
  8095         {
       
  8096         return;
       
  8097         }
       
  8098 
       
  8099     TBool setState( ETrue );
       
  8100 
       
  8101     if ( aState == XnPropertyNames::action::trigger::name::KFocus )
       
  8102         {
       
  8103         if ( !iUiEngine->AppUiAdapter().FocusShown() )
       
  8104             {
       
  8105             return;
       
  8106             }
       
  8107         
       
  8108         setState = DoReceiveFocusL( *iNode, *iUiEngine );
       
  8109         }
       
  8110 
       
  8111     if ( setState && iPropertyList->SetStateL( aState ) )
       
  8112         {
       
  8113         CXnDomProperty::TPseudoClass pseudoClass( PseudoClassFromName( aState ) );
       
  8114 
       
  8115         if ( pseudoClass != CXnDomProperty::ENone )
       
  8116             {
       
  8117             iStates.Append( pseudoClass );
       
  8118 
       
  8119             // Ensure that pseudo class is defined
       
  8120             InsertPropertyPseudoClassL( pseudoClass, iPropertyPseudoClasses );
       
  8121 
       
  8122             if ( IsPropertyPseudoClass( pseudoClass, iPropertyPseudoClasses ) )
       
  8123                 {
       
  8124                 EnableStatePropertiesL( *iNode, pseudoClass, iLayoutPropertyCache );
       
  8125                 }
       
  8126             }
       
  8127 
       
  8128         if ( aState == XnPropertyNames::action::trigger::name::KFocus )
       
  8129             {
       
  8130             iUiEngine->SetFocusedNodeL( iNode );
       
  8131 
       
  8132             HidePopupsL();
       
  8133             }
       
  8134 
       
  8135         iUiEngine->RenderUIL();
       
  8136         }
       
  8137     }
       
  8138 
       
  8139 // -----------------------------------------------------------------------------
       
  8140 // CXnNodeImpl::UnsetStateL
       
  8141 // Unset a pseudoclass
       
  8142 // -----------------------------------------------------------------------------
       
  8143 //
       
  8144 void CXnNodeImpl::UnsetStateL( const TDesC8& aState )
       
  8145     {
       
  8146     if ( !IsStateSet( aState ) )
       
  8147         {
       
  8148         return;
       
  8149         }
       
  8150 
       
  8151     if ( aState == XnPropertyNames::action::trigger::name::KFocus )
       
  8152         {
       
  8153         HidePopupsL();
       
  8154         
       
  8155         iPropertyList->UnsetState( 
       
  8156             XnPropertyNames::style::common::KPressedDown );
       
  8157         
       
  8158         if ( iUiEngine->FocusedNode() == iNode )
       
  8159             {
       
  8160             iUiEngine->SetFocusedNodeL( NULL );
       
  8161             }
       
  8162         }
       
  8163 
       
  8164     TBool stateChanged( iPropertyList->UnsetState( aState ) );
       
  8165 
       
  8166     if ( stateChanged )
       
  8167         {
       
  8168         CXnDomProperty::TPseudoClass pseudoClass( PseudoClassFromName( aState ) );
       
  8169 
       
  8170         if ( IsPropertyPseudoClass( pseudoClass, iPropertyPseudoClasses ) )
       
  8171             {
       
  8172             DisableStatePropertiesL(
       
  8173                 *iNode, pseudoClass, iStates, iLayoutPropertyCache );
       
  8174 
       
  8175             InformPropertyChangeL( *iNode );
       
  8176             }
       
  8177 
       
  8178         for ( TInt i = iStates.Count() - 1; i >= 0; --i )
       
  8179             {
       
  8180             if ( iStates[i] == pseudoClass )
       
  8181                 {
       
  8182                 iStates.Remove( i );
       
  8183                 }
       
  8184             }
       
  8185         
       
  8186         if ( aState == XnPropertyNames::style::common::KPressedDown )
       
  8187             {
       
  8188             iNode->SetDirtyL( XnDirtyLevel::ERender );
       
  8189             }        
       
  8190 
       
  8191         iUiEngine->RenderUIL();
       
  8192         }
       
  8193     }
       
  8194 
       
  8195 // -----------------------------------------------------------------------------
       
  8196 // CXnNodeImpl::SetUiEngine
       
  8197 // -----------------------------------------------------------------------------
       
  8198 //
       
  8199 void CXnNodeImpl::SetUiEngine( CXnUiEngine& aEngine )
       
  8200     {
       
  8201     iUiEngine = &aEngine;
       
  8202     }
       
  8203 
       
  8204 // -----------------------------------------------------------------------------
       
  8205 // CXnNodeImpl::UiEngine
       
  8206 // -----------------------------------------------------------------------------
       
  8207 //
       
  8208 CXnUiEngine* CXnNodeImpl::UiEngine()
       
  8209     {
       
  8210     return iUiEngine;
       
  8211     }
       
  8212 
       
  8213 // -----------------------------------------------------------------------------
       
  8214 // CXnNodeImpl::ReportXuikonEventL
       
  8215 // -----------------------------------------------------------------------------
       
  8216 //
       
  8217 TBool CXnNodeImpl::ReportXuikonEventL( CXnNode& aEventData, TInt aSource )
       
  8218     {
       
  8219     CXnProperty* prop( GetPropertyL( KActionsHandler ) );
       
  8220     
       
  8221     CXnNode* handler( NULL );
       
  8222     
       
  8223     iUiEngine->DisableRenderUiLC();
       
  8224     
       
  8225     if ( prop )
       
  8226         {
       
  8227         const TDesC8& value( prop->StringValue() );
       
  8228         
       
  8229         handler = iUiEngine->FindNodeByIdL( value, Namespace() );       
       
  8230         }
       
  8231     
       
  8232     if ( handler && handler->Type()->Type() == KActionsHandler )
       
  8233         {
       
  8234         // Let <actionshandler> node to handle actions
       
  8235         DoTriggerEventL( this, *iUiEngine, *iNode, 
       
  8236                          *handler, aEventData, aSource );
       
  8237         }    
       
  8238     else
       
  8239         {
       
  8240         // Let this node to handle actions
       
  8241         DoTriggerEventL( this, *iUiEngine, *iNode, 
       
  8242                          *iNode, aEventData, aSource );
       
  8243         }
       
  8244     
       
  8245     CleanupStack::PopAndDestroy(); // DisableRenderUiLC
       
  8246            
       
  8247     return EFalse;
       
  8248     }
       
  8249 
       
  8250 // -----------------------------------------------------------------------------
       
  8251 // CXnNodeImpl::OfferKeyEventL
       
  8252 // -----------------------------------------------------------------------------
       
  8253 //
       
  8254 void CXnNodeImpl::OfferKeyEventL( const TKeyEvent& aKeyEvent, TEventCode aType )
       
  8255     {
       
  8256     DoTriggerKeyEventL( this, *iUiEngine, *iNode, aKeyEvent, aType );
       
  8257     }
       
  8258 
       
  8259 // -----------------------------------------------------------------------------
       
  8260 // CXnNodeImpl::SetDropped
       
  8261 // -----------------------------------------------------------------------------
       
  8262 //
       
  8263 void CXnNodeImpl::SetDropped( const TInt aDropped )
       
  8264     {
       
  8265     if ( Type()->Type() != KToolTip )
       
  8266         {
       
  8267         iDropped = aDropped;
       
  8268 
       
  8269         TInt count( iChildren.Count() );
       
  8270 
       
  8271         for ( TInt i = 0; i < count; i++ )
       
  8272             {
       
  8273             iChildren[i]->SetDropped( aDropped );
       
  8274             }
       
  8275         }
       
  8276     }
       
  8277 
       
  8278 // -----------------------------------------------------------------------------
       
  8279 // CXnNodeImpl::IsDropped
       
  8280 // -----------------------------------------------------------------------------
       
  8281 //
       
  8282 TInt CXnNodeImpl::IsDropped() const
       
  8283     {
       
  8284     return iDropped;
       
  8285     }
       
  8286 
       
  8287 // -----------------------------------------------------------------------------
       
  8288 // CXnNodeImpl::SetLayoutCapable
       
  8289 // -----------------------------------------------------------------------------
       
  8290 //
       
  8291 void CXnNodeImpl::SetLayoutCapable( const TBool aLayoutCapable )
       
  8292     {
       
  8293     iLayoutCapable = aLayoutCapable;
       
  8294     }
       
  8295 
       
  8296 // -----------------------------------------------------------------------------
       
  8297 // CXnNodeImpl::IsLayoutCapable
       
  8298 // -----------------------------------------------------------------------------
       
  8299 //
       
  8300 TBool CXnNodeImpl::IsLayoutCapable() const
       
  8301     {
       
  8302     return iLayoutCapable;
       
  8303     }
       
  8304 
       
  8305 // -----------------------------------------------------------------------------
       
  8306 // CXnNodeImpl::SetRenderedL
       
  8307 // -----------------------------------------------------------------------------
       
  8308 //
       
  8309 void CXnNodeImpl::SetRenderedL()
       
  8310     {
       
  8311     if ( !iLayoutCapable )
       
  8312         {
       
  8313         return;
       
  8314         }
       
  8315 
       
  8316     CXnControlAdapter* control =
       
  8317         static_cast< CXnControlAdapter* >( iNode->Control() );
       
  8318 
       
  8319     if ( control )
       
  8320         {
       
  8321         TBool displayed( IsNodeDisplayedL( *iNode, ETrue, EFalse ) );
       
  8322 
       
  8323         control->SetBlank( EFalse );
       
  8324 
       
  8325         if ( iDropped || !displayed )
       
  8326             {
       
  8327             // Need to check blank here
       
  8328             CXnProperty* prop( VisibilityL() );
       
  8329 
       
  8330             if ( prop && prop->StringValue() ==
       
  8331                  XnPropertyNames::style::common::visibility::KBlank )
       
  8332                 {
       
  8333                 control->SetBlank( ETrue );
       
  8334                 control->MakeVisible( EFalse );
       
  8335                 control->SetComponentsToInheritVisibility( EFalse );
       
  8336                 control->MakeVisible( ETrue );
       
  8337                 control->SetComponentsToInheritVisibility( ETrue );
       
  8338                 }
       
  8339             else
       
  8340                 {
       
  8341                 if ( control->IsVisible() )
       
  8342                     {
       
  8343                     control->MakeVisible( EFalse );
       
  8344                     }
       
  8345                 }
       
  8346             }
       
  8347         else
       
  8348             {
       
  8349             CCoeControl* parent( control->Parent() );
       
  8350 
       
  8351             TBool parentVisible( ETrue );
       
  8352 
       
  8353             if ( parent && !parent->IsVisible() )
       
  8354                 {
       
  8355                 parentVisible = EFalse;
       
  8356                 }
       
  8357 
       
  8358             if ( !control->IsVisible() && parentVisible )
       
  8359                 {
       
  8360                 TBool found( EFalse );
       
  8361 
       
  8362                 for ( CXnNode* node = iNode; !found && node; node = node->Parent() )
       
  8363                     {
       
  8364                     if ( node->Type()->Type() == KToolTip )
       
  8365                         {
       
  8366                         // Tooltip control handles its visibility internally
       
  8367                         found = ETrue;
       
  8368                         }
       
  8369                     }
       
  8370 
       
  8371                 if ( !found )
       
  8372                     {
       
  8373                     control->MakeVisible( ETrue );
       
  8374                     }
       
  8375                 }
       
  8376             }
       
  8377         }
       
  8378 
       
  8379     iRendered = ETrue;
       
  8380 
       
  8381     for ( TInt i = 0; i < iChildren.Count(); i++ )
       
  8382         {
       
  8383         iChildren[i]->SetRenderedL();
       
  8384         }
       
  8385     }
       
  8386 
       
  8387 // -----------------------------------------------------------------------------
       
  8388 // CXnNodeImpl::SetLaidOutL
       
  8389 // -----------------------------------------------------------------------------
       
  8390 //
       
  8391 void CXnNodeImpl::SetLaidOutL()
       
  8392     {
       
  8393     if ( !iLayoutCapable )
       
  8394         {
       
  8395         return;
       
  8396         }
       
  8397 
       
  8398     if ( iDropped || !IsNodeDisplayedL( *iNode ) )
       
  8399         {
       
  8400         return;
       
  8401         }
       
  8402 
       
  8403     iLaidOut = ETrue;
       
  8404 
       
  8405     for ( TInt i = 0; i < iChildren.Count(); i++ )
       
  8406         {
       
  8407         iChildren[i]->SetLaidOutL();
       
  8408         }
       
  8409     }
       
  8410 
       
  8411 // -----------------------------------------------------------------------------
       
  8412 // CXnNodeImpl::IsLaidOut
       
  8413 // -----------------------------------------------------------------------------
       
  8414 //
       
  8415 TBool CXnNodeImpl::IsLaidOut() const
       
  8416     {
       
  8417     return iLaidOut;
       
  8418     }
       
  8419 
       
  8420 // -----------------------------------------------------------------------------
       
  8421 // CXnNodeImpl::ClearRenderedAndLaidOut
       
  8422 // -----------------------------------------------------------------------------
       
  8423 //
       
  8424 void CXnNodeImpl::ClearRenderedAndLaidOut()
       
  8425     {
       
  8426     if ( !iRendered && !iLaidOut )
       
  8427         {
       
  8428         return;
       
  8429         }
       
  8430 
       
  8431     TRect empty;
       
  8432 
       
  8433     SetRect( empty );
       
  8434     SetPaddingRect( empty );
       
  8435     SetBorderRect( empty );
       
  8436     SetNormalFlowBorderRect( empty );
       
  8437     SetMarginRect( empty );
       
  8438 
       
  8439     iRendered = EFalse;
       
  8440     iLaidOut = EFalse;
       
  8441 
       
  8442     if ( iLayoutCapable )
       
  8443         {
       
  8444         for ( TInt i = 0; i < iChildren.Count(); i++ )
       
  8445             {
       
  8446             iChildren[i]->ClearRenderedAndLaidOut();
       
  8447             }
       
  8448         }
       
  8449     }
       
  8450 
       
  8451 // -----------------------------------------------------------------------------
       
  8452 // CXnNodeImpl::MakeInterfaceL
       
  8453 // Create a component interface according to the given type.
       
  8454 // -----------------------------------------------------------------------------
       
  8455 //
       
  8456 XnComponentInterface::MXnComponentInterface* CXnNodeImpl::MakeInterfaceL(
       
  8457     const TDesC8& /*aType*/ )
       
  8458     {
       
  8459     return NULL;
       
  8460     }
       
  8461 
       
  8462 // -----------------------------------------------------------------------------
       
  8463 // PropertyL
       
  8464 // Returns a property.
       
  8465 // -----------------------------------------------------------------------------
       
  8466 //
       
  8467 static CXnProperty* PropertyL( CXnNodeImpl* aThis, CXnProperty* aProperty,
       
  8468     CXnProperty* ( CXnNode::* aFunc )(), CXnUiEngine* aUiEngine,
       
  8469     TAny* aLayoutPropertyCache, CXnNode* aParent, CXnProperty* aRef )
       
  8470     {
       
  8471     CXnNode* refNode( RefNodeL( aThis, aRef, aUiEngine ) ) ;
       
  8472 
       
  8473     if ( refNode )
       
  8474         {
       
  8475         return ( refNode->*aFunc )();
       
  8476         }
       
  8477 
       
  8478     if ( aLayoutPropertyCache && aProperty )
       
  8479         {
       
  8480         CXnDomProperty* attribute = aProperty->Property();
       
  8481         CXnDomList& list = attribute->PropertyValueList();
       
  8482 
       
  8483         if ( list.Length() == 0 )
       
  8484             {
       
  8485             return NULL;
       
  8486             }
       
  8487 
       
  8488         CXnDomPropertyValue* attributeValue =
       
  8489             static_cast< CXnDomPropertyValue* >( list.Item( 0 ) );
       
  8490 
       
  8491         if ( !attributeValue )
       
  8492             {
       
  8493             return NULL;
       
  8494             }
       
  8495 
       
  8496         if ( attributeValue->IsInheritIdent() && aParent )
       
  8497             {
       
  8498             // inherited values are queried from the parent
       
  8499             return ( aParent->*aFunc )();
       
  8500             }
       
  8501 
       
  8502         // otherwise just return the value
       
  8503         return aProperty;
       
  8504         }
       
  8505 
       
  8506     return NULL;
       
  8507     }
       
  8508 
       
  8509 // -----------------------------------------------------------------------------
       
  8510 // ReferredPropertyL
       
  8511 // Returns a referred property.
       
  8512 // -----------------------------------------------------------------------------
       
  8513 //
       
  8514 static CXnProperty* ReferredPropertyL(
       
  8515     RPointerArray< CXnProperty >* aPropertyArray,
       
  8516     RArray< CXnDomProperty::TPseudoClass >& aStates )
       
  8517     {
       
  8518     if ( !aPropertyArray )
       
  8519         {
       
  8520         return NULL;
       
  8521         }
       
  8522     for ( TInt i = aPropertyArray->Count() - 1; i >= 0; --i )
       
  8523         {
       
  8524         CXnProperty* tmp = ( *aPropertyArray )[i];
       
  8525         for ( TInt j = aStates.Count() - 1; j >= 0; --j )
       
  8526             {
       
  8527             if ( aStates[j] == tmp->Property()->PseudoClass() )
       
  8528                 {
       
  8529                 return tmp;
       
  8530                 }
       
  8531             }
       
  8532         for ( TInt j = aStates.Count() - 1; j >= 0; --j )
       
  8533             {
       
  8534             if ( tmp->Property()->PseudoClass() == CXnDomProperty::ENone )
       
  8535                 {
       
  8536                 return tmp;
       
  8537                 }
       
  8538             }
       
  8539         }
       
  8540     for ( TInt i = aPropertyArray->Count() - 1; i >= 0; --i )
       
  8541         {
       
  8542         CXnProperty* tmp = ( *aPropertyArray )[i];
       
  8543         if ( tmp->Property()->PseudoClass() == CXnDomProperty::ENone )
       
  8544             {
       
  8545             return tmp;
       
  8546             }
       
  8547         }
       
  8548     return NULL;
       
  8549     }
       
  8550 
       
  8551 // -----------------------------------------------------------------------------
       
  8552 // RefNodeL
       
  8553 // Returns referred node.
       
  8554 // -----------------------------------------------------------------------------
       
  8555 //
       
  8556 static CXnNode* RefNodeL(
       
  8557     CXnNodeImpl* aThis,
       
  8558     CXnProperty* aRef,
       
  8559     CXnUiEngine* aUiEngine )
       
  8560     {
       
  8561     const TDesC8* refid( CheckRefAttributeL( aRef ) );
       
  8562 
       
  8563     if ( refid )
       
  8564         {
       
  8565         CXnNode* node( aUiEngine->FindNodeByIdL( *refid, aThis->Namespace() ) );
       
  8566 
       
  8567         if ( node )
       
  8568             {
       
  8569             return node;
       
  8570             }
       
  8571         }
       
  8572 
       
  8573     return NULL;
       
  8574     }
       
  8575 
       
  8576 // -----------------------------------------------------------------------------
       
  8577 // CXnNodeImpl::WidthL
       
  8578 // Returns width property.
       
  8579 // -----------------------------------------------------------------------------
       
  8580 //
       
  8581 CXnProperty* CXnNodeImpl::WidthL()
       
  8582     {
       
  8583     CXnNode* refNode = RefNodeL( this, iRef, iUiEngine );
       
  8584     if ( refNode )
       
  8585         {
       
  8586         RPointerArray< CXnProperty >* propertyArray =
       
  8587             refNode->Impl()->iLayoutPropertyCache ?
       
  8588             &( refNode->Impl()->iLayoutPropertyCache->iWidths ) :
       
  8589             NULL;
       
  8590         return ReferredPropertyL( propertyArray, iStates );
       
  8591         }
       
  8592     CXnProperty* property =
       
  8593         iLayoutPropertyCache ? iLayoutPropertyCache->iWidth : NULL;
       
  8594     return PropertyL( this, property, &CXnNode::WidthL,
       
  8595         iUiEngine, iLayoutPropertyCache,
       
  8596         iParent, iRef );
       
  8597     }
       
  8598 
       
  8599 // -----------------------------------------------------------------------------
       
  8600 // CXnNodeImpl::HeightL
       
  8601 // Returns height property.
       
  8602 // -----------------------------------------------------------------------------
       
  8603 //
       
  8604 CXnProperty* CXnNodeImpl::HeightL()
       
  8605     {
       
  8606     CXnNode* refNode = RefNodeL( this, iRef, iUiEngine );
       
  8607     if (refNode)
       
  8608         {
       
  8609         RPointerArray< CXnProperty >* propertyArray =
       
  8610             refNode->Impl()->iLayoutPropertyCache ?
       
  8611             &( refNode->Impl()->iLayoutPropertyCache->iHeights ) :
       
  8612             NULL;
       
  8613         return ReferredPropertyL( propertyArray, iStates );
       
  8614         }
       
  8615     CXnProperty* property =
       
  8616         iLayoutPropertyCache ? iLayoutPropertyCache->iHeight : NULL;
       
  8617     return PropertyL( this, property, &CXnNode::HeightL,
       
  8618         iUiEngine, iLayoutPropertyCache,
       
  8619         iParent, iRef );
       
  8620     }
       
  8621 
       
  8622 // -----------------------------------------------------------------------------
       
  8623 // CXnNodeImpl::MarginLeftL
       
  8624 // Returns margin-left property.
       
  8625 // -----------------------------------------------------------------------------
       
  8626 //
       
  8627 CXnProperty* CXnNodeImpl::MarginLeftL()
       
  8628     {
       
  8629     CXnNode* refNode = RefNodeL( this, iRef, iUiEngine );
       
  8630     if ( refNode )
       
  8631         {
       
  8632         RPointerArray< CXnProperty >* propertyArray =
       
  8633             refNode->Impl()->iLayoutPropertyCache ?
       
  8634             &( refNode->Impl()->iLayoutPropertyCache->iMarginLefts ) :
       
  8635             NULL;
       
  8636         return ReferredPropertyL( propertyArray, iStates );
       
  8637         }
       
  8638     CXnProperty* property =
       
  8639         iLayoutPropertyCache ?
       
  8640         iLayoutPropertyCache->iMarginLeft :
       
  8641         NULL;
       
  8642     return PropertyL( this, property, &CXnNode::MarginLeftL,
       
  8643         iUiEngine, iLayoutPropertyCache,
       
  8644         iParent, iRef );
       
  8645     }
       
  8646 
       
  8647 // -----------------------------------------------------------------------------
       
  8648 // CXnNodeImpl::MarginRightL
       
  8649 // Returns margin-right property.
       
  8650 // -----------------------------------------------------------------------------
       
  8651 //
       
  8652 CXnProperty* CXnNodeImpl::MarginRightL()
       
  8653     {
       
  8654     CXnNode* refNode = RefNodeL( this, iRef, iUiEngine );
       
  8655     if ( refNode )
       
  8656         {
       
  8657         RPointerArray< CXnProperty >* propertyArray =
       
  8658             refNode->Impl()->iLayoutPropertyCache ?
       
  8659             &( refNode->Impl()->iLayoutPropertyCache->iMarginRights ) :
       
  8660             NULL;
       
  8661         return ReferredPropertyL(propertyArray, iStates);
       
  8662         }
       
  8663     CXnProperty* property =
       
  8664         iLayoutPropertyCache ?
       
  8665         iLayoutPropertyCache->iMarginRight :
       
  8666         NULL;
       
  8667     return PropertyL( this, property, &CXnNode::MarginRightL,
       
  8668         iUiEngine, iLayoutPropertyCache,
       
  8669         iParent, iRef );
       
  8670     }
       
  8671 
       
  8672 // -----------------------------------------------------------------------------
       
  8673 // CXnNodeImpl::BorderLeftL
       
  8674 // Returns border-left property.
       
  8675 // -----------------------------------------------------------------------------
       
  8676 //
       
  8677 CXnProperty* CXnNodeImpl::BorderLeftL()
       
  8678     {
       
  8679     CXnNode* refNode = RefNodeL( this, iRef, iUiEngine );
       
  8680     if ( refNode )
       
  8681         {
       
  8682         RPointerArray< CXnProperty >* propertyArray =
       
  8683             refNode->Impl()->iLayoutPropertyCache ?
       
  8684             &( refNode->Impl()->iLayoutPropertyCache->iBorderLefts ) :
       
  8685             NULL;
       
  8686         return ReferredPropertyL( propertyArray, iStates );
       
  8687         }
       
  8688     CXnProperty* property = iLayoutPropertyCache ?
       
  8689         iLayoutPropertyCache->iBorderLeft :
       
  8690         NULL;
       
  8691     return PropertyL( this, property, &CXnNode::BorderLeftL,
       
  8692         iUiEngine, iLayoutPropertyCache,
       
  8693         iParent, iRef );
       
  8694     }
       
  8695 
       
  8696 // -----------------------------------------------------------------------------
       
  8697 // CXnNodeImpl::BorderRightL
       
  8698 // Returns border-right property.
       
  8699 // -----------------------------------------------------------------------------
       
  8700 //
       
  8701 CXnProperty* CXnNodeImpl::BorderRightL()
       
  8702     {
       
  8703     CXnNode* refNode = RefNodeL( this, iRef, iUiEngine );
       
  8704     if ( refNode )
       
  8705         {
       
  8706         RPointerArray< CXnProperty >* propertyArray =
       
  8707             refNode->Impl()->iLayoutPropertyCache ?
       
  8708             &( refNode->Impl()->iLayoutPropertyCache->iBorderRights ) :
       
  8709             NULL;
       
  8710         return ReferredPropertyL( propertyArray, iStates );
       
  8711         }
       
  8712     CXnProperty* property =
       
  8713         iLayoutPropertyCache ?
       
  8714         iLayoutPropertyCache->iBorderRight :
       
  8715         NULL;
       
  8716     return PropertyL( this, property, &CXnNode::BorderRightL,
       
  8717         iUiEngine, iLayoutPropertyCache,
       
  8718         iParent, iRef );
       
  8719     }
       
  8720 
       
  8721 // -----------------------------------------------------------------------------
       
  8722 // CXnNodeImpl::PaddingLeftL
       
  8723 // Returns padding-left property.
       
  8724 // -----------------------------------------------------------------------------
       
  8725 //
       
  8726 CXnProperty* CXnNodeImpl::PaddingLeftL()
       
  8727     {
       
  8728     CXnNode* refNode = RefNodeL( this, iRef, iUiEngine );
       
  8729     if ( refNode )
       
  8730         {
       
  8731         RPointerArray< CXnProperty >* propertyArray =
       
  8732             refNode->Impl()->iLayoutPropertyCache ?
       
  8733             &( refNode->Impl()->iLayoutPropertyCache->iPaddingLefts ) :
       
  8734             NULL;
       
  8735         return ReferredPropertyL( propertyArray, iStates );
       
  8736         }
       
  8737     CXnProperty* property =
       
  8738         iLayoutPropertyCache ?
       
  8739         iLayoutPropertyCache->iPaddingLeft :
       
  8740         NULL;
       
  8741     return PropertyL( this, property, &CXnNode::PaddingLeftL,
       
  8742         iUiEngine, iLayoutPropertyCache,
       
  8743         iParent, iRef );
       
  8744     }
       
  8745 
       
  8746 // -----------------------------------------------------------------------------
       
  8747 // CXnNodeImpl::PaddingRightL
       
  8748 // Returns PaddingRightL property.
       
  8749 // -----------------------------------------------------------------------------
       
  8750 //
       
  8751 CXnProperty* CXnNodeImpl::PaddingRightL()
       
  8752     {
       
  8753     CXnNode* refNode = RefNodeL( this, iRef, iUiEngine );
       
  8754     if ( refNode )
       
  8755         {
       
  8756         RPointerArray< CXnProperty >* propertyArray =
       
  8757             refNode->Impl()->iLayoutPropertyCache ?
       
  8758             &( refNode->Impl()->iLayoutPropertyCache->iPaddingRights ) :
       
  8759             NULL;
       
  8760         return ReferredPropertyL( propertyArray, iStates );
       
  8761         }
       
  8762     CXnProperty* property =
       
  8763         iLayoutPropertyCache ? iLayoutPropertyCache->iPaddingRight : NULL;
       
  8764     return PropertyL( this, property, &CXnNode::PaddingRightL,
       
  8765         iUiEngine, iLayoutPropertyCache,
       
  8766         iParent, iRef );
       
  8767     }
       
  8768 
       
  8769 // -----------------------------------------------------------------------------
       
  8770 // CXnNodeImpl::MarginTopL
       
  8771 // Returns margin-top property.
       
  8772 // -----------------------------------------------------------------------------
       
  8773 //
       
  8774 CXnProperty* CXnNodeImpl::MarginTopL()
       
  8775     {
       
  8776     CXnNode* refNode = RefNodeL( this, iRef, iUiEngine );
       
  8777     if ( refNode )
       
  8778         {
       
  8779         RPointerArray< CXnProperty >* propertyArray =
       
  8780             refNode->Impl()->iLayoutPropertyCache ?
       
  8781             &( refNode->Impl()->iLayoutPropertyCache->iMarginTops ) :
       
  8782             NULL;
       
  8783         return ReferredPropertyL( propertyArray, iStates );
       
  8784         }
       
  8785     CXnProperty* property =
       
  8786         iLayoutPropertyCache ? iLayoutPropertyCache->iMarginTop : NULL;
       
  8787     return PropertyL( this, property, &CXnNode::MarginTopL,
       
  8788         iUiEngine, iLayoutPropertyCache,
       
  8789         iParent, iRef );
       
  8790     }
       
  8791 
       
  8792 // -----------------------------------------------------------------------------
       
  8793 // CXnNodeImpl::MarginBottomL
       
  8794 // Returns margin-bottom property.
       
  8795 // -----------------------------------------------------------------------------
       
  8796 //
       
  8797 CXnProperty* CXnNodeImpl::MarginBottomL()
       
  8798     {
       
  8799     CXnNode* refNode = RefNodeL( this, iRef, iUiEngine );
       
  8800     if ( refNode )
       
  8801         {
       
  8802         RPointerArray< CXnProperty >* propertyArray =
       
  8803             refNode->Impl()->iLayoutPropertyCache ?
       
  8804             &( refNode->Impl()->iLayoutPropertyCache->iMarginBottoms ) :
       
  8805             NULL;
       
  8806         return ReferredPropertyL( propertyArray, iStates );
       
  8807         }
       
  8808     CXnProperty* property =
       
  8809         iLayoutPropertyCache ? iLayoutPropertyCache->iMarginBottom : NULL;
       
  8810     return PropertyL( this, property, &CXnNode::MarginBottomL,
       
  8811         iUiEngine, iLayoutPropertyCache,
       
  8812         iParent, iRef );
       
  8813     }
       
  8814 
       
  8815 // -----------------------------------------------------------------------------
       
  8816 // CXnNodeImpl::BorderTopL
       
  8817 // Returns border-top property.
       
  8818 // -----------------------------------------------------------------------------
       
  8819 //
       
  8820 CXnProperty* CXnNodeImpl::BorderTopL()
       
  8821     {
       
  8822     CXnNode* refNode = RefNodeL( this, iRef, iUiEngine );
       
  8823     if ( refNode )
       
  8824         {
       
  8825         RPointerArray< CXnProperty >* propertyArray =
       
  8826             refNode->Impl()->iLayoutPropertyCache ?
       
  8827             &( refNode->Impl()->iLayoutPropertyCache->iBorderTops ) :
       
  8828             NULL;
       
  8829         return ReferredPropertyL( propertyArray, iStates );
       
  8830         }
       
  8831     CXnProperty* property =
       
  8832         iLayoutPropertyCache ? iLayoutPropertyCache->iBorderTop : NULL;
       
  8833     return PropertyL( this, property, &CXnNode::BorderTopL,
       
  8834         iUiEngine, iLayoutPropertyCache,
       
  8835         iParent, iRef );
       
  8836     }
       
  8837 
       
  8838 // -----------------------------------------------------------------------------
       
  8839 // CXnNodeImpl::BorderBottomL
       
  8840 // Returns border-bottom property.
       
  8841 // -----------------------------------------------------------------------------
       
  8842 //
       
  8843 CXnProperty* CXnNodeImpl::BorderBottomL()
       
  8844     {
       
  8845     CXnNode* refNode = RefNodeL( this, iRef, iUiEngine );
       
  8846     if ( refNode )
       
  8847         {
       
  8848         RPointerArray< CXnProperty >* propertyArray =
       
  8849             refNode->Impl()->iLayoutPropertyCache ?
       
  8850             &( refNode->Impl()->iLayoutPropertyCache->iBorderBottoms ) :
       
  8851             NULL;
       
  8852         return ReferredPropertyL( propertyArray, iStates );
       
  8853         }
       
  8854     CXnProperty* property =
       
  8855         iLayoutPropertyCache ? iLayoutPropertyCache->iBorderBottom : NULL;
       
  8856     return PropertyL( this, property, &CXnNode::BorderBottomL,
       
  8857         iUiEngine, iLayoutPropertyCache,
       
  8858         iParent, iRef );
       
  8859     }
       
  8860 
       
  8861 // -----------------------------------------------------------------------------
       
  8862 // CXnNodeImpl::PaddingTopL
       
  8863 // Returns padding-top property.
       
  8864 // -----------------------------------------------------------------------------
       
  8865 //
       
  8866 CXnProperty* CXnNodeImpl::PaddingTopL()
       
  8867     {
       
  8868     CXnNode* refNode = RefNodeL( this, iRef, iUiEngine );
       
  8869     if ( refNode )
       
  8870         {
       
  8871         RPointerArray< CXnProperty >* propertyArray =
       
  8872             refNode->Impl()->iLayoutPropertyCache ?
       
  8873             &( refNode->Impl()->iLayoutPropertyCache->iPaddingTops ) :
       
  8874             NULL;
       
  8875         return ReferredPropertyL( propertyArray, iStates );
       
  8876         }
       
  8877     CXnProperty* property =
       
  8878         iLayoutPropertyCache ? iLayoutPropertyCache->iPaddingTop : NULL;
       
  8879     return PropertyL( this, property, &CXnNode::PaddingTopL,
       
  8880         iUiEngine, iLayoutPropertyCache,
       
  8881         iParent, iRef );
       
  8882     }
       
  8883 
       
  8884 // -----------------------------------------------------------------------------
       
  8885 // CXnNodeImpl::PaddingBottomL
       
  8886 // Returns padding-bottom property.
       
  8887 // -----------------------------------------------------------------------------
       
  8888 //
       
  8889 CXnProperty* CXnNodeImpl::PaddingBottomL()
       
  8890     {
       
  8891     CXnNode* refNode = RefNodeL( this, iRef, iUiEngine );
       
  8892     if ( refNode )
       
  8893         {
       
  8894         RPointerArray< CXnProperty >* propertyArray =
       
  8895             refNode->Impl()->iLayoutPropertyCache ?
       
  8896             &( refNode->Impl()->iLayoutPropertyCache->iPaddingBottoms ) :
       
  8897             NULL;
       
  8898         return ReferredPropertyL( propertyArray, iStates );
       
  8899         }
       
  8900     CXnProperty* property =
       
  8901         iLayoutPropertyCache ? iLayoutPropertyCache->iPaddingBottom : NULL;
       
  8902     return PropertyL( this, property, &CXnNode::PaddingBottomL,
       
  8903         iUiEngine, iLayoutPropertyCache,
       
  8904         iParent, iRef );
       
  8905     }
       
  8906 
       
  8907 // -----------------------------------------------------------------------------
       
  8908 // CXnNodeImpl::BorderWidthL
       
  8909 // Returns border-width property.
       
  8910 // -----------------------------------------------------------------------------
       
  8911 //
       
  8912 CXnProperty* CXnNodeImpl::BorderWidthL()
       
  8913     {
       
  8914     CXnNode* refNode = RefNodeL( this, iRef, iUiEngine );
       
  8915     if ( refNode )
       
  8916         {
       
  8917         RPointerArray< CXnProperty >* propertyArray =
       
  8918             refNode->Impl()->iLayoutPropertyCache ?
       
  8919             &( refNode->Impl()->iLayoutPropertyCache->iBorderWidths ) :
       
  8920             NULL;
       
  8921         return ReferredPropertyL( propertyArray, iStates );
       
  8922         }
       
  8923     CXnProperty* property =
       
  8924         iLayoutPropertyCache ? iLayoutPropertyCache->iBorderWidth : NULL;
       
  8925     return PropertyL( this, property, &CXnNode::BorderWidthL,
       
  8926         iUiEngine, iLayoutPropertyCache,
       
  8927         iParent, iRef );
       
  8928     }
       
  8929 
       
  8930 // -----------------------------------------------------------------------------
       
  8931 // CXnNodeImpl::BlockProgressionL
       
  8932 // Returns block-progression property.
       
  8933 // -----------------------------------------------------------------------------
       
  8934 //
       
  8935 CXnProperty* CXnNodeImpl::BlockProgressionL()
       
  8936     {
       
  8937     CXnNode* refNode = RefNodeL( this, iRef, iUiEngine );
       
  8938     if ( refNode )
       
  8939         {
       
  8940         RPointerArray< CXnProperty >* propertyArray =
       
  8941             refNode->Impl()->iLayoutPropertyCache ?
       
  8942             &( refNode->Impl()->iLayoutPropertyCache->iBlockProgressions ) :
       
  8943             NULL;
       
  8944         return ReferredPropertyL( propertyArray, iStates );
       
  8945         }
       
  8946     CXnProperty* property =
       
  8947         iLayoutPropertyCache ? iLayoutPropertyCache->iBlockProgression : NULL;
       
  8948     return PropertyL( this, property, &CXnNode::BlockProgressionL,
       
  8949         iUiEngine, iLayoutPropertyCache,
       
  8950         iParent, iRef );
       
  8951     }
       
  8952 
       
  8953 // -----------------------------------------------------------------------------
       
  8954 // CXnNodeImpl::DirectionL
       
  8955 // Returns direction property.
       
  8956 // -----------------------------------------------------------------------------
       
  8957 //
       
  8958 CXnProperty* CXnNodeImpl::DirectionL()
       
  8959     {
       
  8960     CXnNode* refNode = RefNodeL( this, iRef, iUiEngine );
       
  8961     if ( refNode )
       
  8962         {
       
  8963         RPointerArray< CXnProperty >* propertyArray =
       
  8964             refNode->Impl()->iLayoutPropertyCache ?
       
  8965             &( refNode->Impl()->iLayoutPropertyCache->iDirections ) :
       
  8966             NULL;
       
  8967         return ReferredPropertyL( propertyArray, iStates );
       
  8968         }
       
  8969     CXnProperty* property =
       
  8970         iLayoutPropertyCache ? iLayoutPropertyCache->iDirection : NULL;
       
  8971     return PropertyL( this, property, &CXnNode::DirectionL,
       
  8972         iUiEngine, iLayoutPropertyCache,
       
  8973         iParent, iRef );
       
  8974     }
       
  8975 
       
  8976 // -----------------------------------------------------------------------------
       
  8977 // CXnNodeImpl::PositionL
       
  8978 // Returns position property.
       
  8979 // -----------------------------------------------------------------------------
       
  8980 //
       
  8981 CXnProperty* CXnNodeImpl::PositionL()
       
  8982     {
       
  8983     CXnNode* refNode = RefNodeL( this, iRef, iUiEngine );
       
  8984     if ( refNode )
       
  8985         {
       
  8986         RPointerArray< CXnProperty >* propertyArray =
       
  8987             refNode->Impl()->iLayoutPropertyCache ?
       
  8988             &( refNode->Impl()->iLayoutPropertyCache->iPositions ) :
       
  8989             NULL;
       
  8990         return ReferredPropertyL( propertyArray, iStates );
       
  8991         }
       
  8992     CXnProperty* property =
       
  8993         iLayoutPropertyCache ? iLayoutPropertyCache->iPosition : NULL;
       
  8994     return PropertyL( this, property, &CXnNode::PositionL,
       
  8995         iUiEngine, iLayoutPropertyCache,
       
  8996         iParent, iRef );
       
  8997     }
       
  8998 
       
  8999 // -----------------------------------------------------------------------------
       
  9000 // CXnNodeImpl::MaxHeightL
       
  9001 // Returns max-height property.
       
  9002 // -----------------------------------------------------------------------------
       
  9003 //
       
  9004 CXnProperty* CXnNodeImpl::MaxHeightL()
       
  9005     {
       
  9006     CXnNode* refNode = RefNodeL( this, iRef, iUiEngine );
       
  9007     if ( refNode )
       
  9008         {
       
  9009         RPointerArray< CXnProperty >* propertyArray =
       
  9010             refNode->Impl()->iLayoutPropertyCache ?
       
  9011             &( refNode->Impl()->iLayoutPropertyCache->iMaxHeights ) :
       
  9012             NULL;
       
  9013         return ReferredPropertyL( propertyArray, iStates );
       
  9014         }
       
  9015     CXnProperty* property =
       
  9016         iLayoutPropertyCache ? iLayoutPropertyCache->iMaxHeight : NULL;
       
  9017     return PropertyL( this, property, &CXnNode::MaxHeightL,
       
  9018         iUiEngine, iLayoutPropertyCache,
       
  9019         iParent, iRef );
       
  9020     }
       
  9021 
       
  9022 // -----------------------------------------------------------------------------
       
  9023 // CXnNodeImpl::MinHeightL
       
  9024 // Returns min-height property.
       
  9025 // -----------------------------------------------------------------------------
       
  9026 //
       
  9027 CXnProperty* CXnNodeImpl::MinHeightL()
       
  9028     {
       
  9029     CXnNode* refNode = RefNodeL( this, iRef, iUiEngine );
       
  9030     if ( refNode )
       
  9031         {
       
  9032         RPointerArray< CXnProperty >* propertyArray =
       
  9033             refNode->Impl()->iLayoutPropertyCache ?
       
  9034             &( refNode->Impl()->iLayoutPropertyCache->iMinHeights ) :
       
  9035             NULL;
       
  9036         return ReferredPropertyL( propertyArray, iStates );
       
  9037         }
       
  9038     CXnProperty* property =
       
  9039         iLayoutPropertyCache ? iLayoutPropertyCache->iMinHeight : NULL;
       
  9040     return PropertyL( this, property, &CXnNode::MinHeightL,
       
  9041         iUiEngine, iLayoutPropertyCache,
       
  9042         iParent, iRef );
       
  9043     }
       
  9044 
       
  9045 // -----------------------------------------------------------------------------
       
  9046 // CXnNodeImpl::MaxWidthL
       
  9047 // Returns max-width property.
       
  9048 // -----------------------------------------------------------------------------
       
  9049 //
       
  9050 CXnProperty* CXnNodeImpl::MaxWidthL()
       
  9051     {
       
  9052     CXnNode* refNode = RefNodeL( this, iRef, iUiEngine );
       
  9053     if ( refNode )
       
  9054         {
       
  9055         RPointerArray< CXnProperty >* propertyArray =
       
  9056             refNode->Impl()->iLayoutPropertyCache ?
       
  9057             &( refNode->Impl()->iLayoutPropertyCache->iMaxWidths ) :
       
  9058             NULL;
       
  9059         return ReferredPropertyL( propertyArray, iStates );
       
  9060         }
       
  9061     CXnProperty* property =
       
  9062         iLayoutPropertyCache ? iLayoutPropertyCache->iMaxWidth : NULL;
       
  9063     return PropertyL( this, property, &CXnNode::MaxWidthL,
       
  9064         iUiEngine, iLayoutPropertyCache,
       
  9065         iParent, iRef );
       
  9066     }
       
  9067 
       
  9068 // -----------------------------------------------------------------------------
       
  9069 // CXnNodeImpl::MinWidthL
       
  9070 // Returns min-width property.
       
  9071 // -----------------------------------------------------------------------------
       
  9072 //
       
  9073 CXnProperty* CXnNodeImpl::MinWidthL()
       
  9074     {
       
  9075     CXnNode* refNode = RefNodeL( this, iRef, iUiEngine );
       
  9076     if ( refNode )
       
  9077         {
       
  9078         RPointerArray< CXnProperty >* propertyArray =
       
  9079             refNode->Impl()->iLayoutPropertyCache ?
       
  9080             &( refNode->Impl()->iLayoutPropertyCache->iMinWidths ) :
       
  9081             NULL;
       
  9082         return ReferredPropertyL( propertyArray, iStates );
       
  9083         }
       
  9084     CXnProperty* property =
       
  9085         iLayoutPropertyCache ? iLayoutPropertyCache->iMinWidth : NULL;
       
  9086     return PropertyL( this, property, &CXnNode::MinWidthL,
       
  9087         iUiEngine, iLayoutPropertyCache,
       
  9088         iParent, iRef );
       
  9089     }
       
  9090 
       
  9091 // -----------------------------------------------------------------------------
       
  9092 // CXnNodeImpl::DisplayL
       
  9093 // Returns display property.
       
  9094 // -----------------------------------------------------------------------------
       
  9095 //
       
  9096 CXnProperty* CXnNodeImpl::DisplayL()
       
  9097     {
       
  9098     CXnNode* refNode = RefNodeL( this, iRef, iUiEngine );
       
  9099     if ( refNode )
       
  9100         {
       
  9101         RPointerArray< CXnProperty >* propertyArray =
       
  9102             refNode->Impl()->iLayoutPropertyCache ?
       
  9103             &( refNode->Impl()->iLayoutPropertyCache->iDisplays ) :
       
  9104             NULL;
       
  9105         return ReferredPropertyL( propertyArray, iStates );
       
  9106         }
       
  9107     CXnProperty* property =
       
  9108         iLayoutPropertyCache ? iLayoutPropertyCache->iDisplay : NULL;
       
  9109     return PropertyL( this, property, &CXnNode::DisplayL,
       
  9110         iUiEngine, iLayoutPropertyCache,
       
  9111         iParent, iRef );
       
  9112     }
       
  9113 
       
  9114 // -----------------------------------------------------------------------------
       
  9115 // CXnNodeImpl::LeftL
       
  9116 // Returns left property.
       
  9117 // -----------------------------------------------------------------------------
       
  9118 //
       
  9119 CXnProperty* CXnNodeImpl::LeftL()
       
  9120     {
       
  9121     CXnNode* refNode = RefNodeL( this, iRef, iUiEngine );
       
  9122     if ( refNode )
       
  9123         {
       
  9124         RPointerArray< CXnProperty >* propertyArray =
       
  9125             refNode->Impl()->iLayoutPropertyCache ?
       
  9126             &( refNode->Impl()->iLayoutPropertyCache->iLefts ) :
       
  9127             NULL;
       
  9128         return ReferredPropertyL( propertyArray, iStates );
       
  9129         }
       
  9130     CXnProperty* property =
       
  9131         iLayoutPropertyCache ? iLayoutPropertyCache->iLeft : NULL;
       
  9132     return PropertyL( this, property, &CXnNode::LeftL,
       
  9133         iUiEngine, iLayoutPropertyCache,
       
  9134         iParent, iRef );
       
  9135     }
       
  9136 
       
  9137 // -----------------------------------------------------------------------------
       
  9138 // CXnNodeImpl::RightL
       
  9139 // Returns right property.
       
  9140 // -----------------------------------------------------------------------------
       
  9141 //
       
  9142 CXnProperty* CXnNodeImpl::RightL()
       
  9143     {
       
  9144     CXnNode* refNode = RefNodeL( this, iRef, iUiEngine );
       
  9145     if ( refNode )
       
  9146         {
       
  9147         RPointerArray< CXnProperty >* propertyArray =
       
  9148             refNode->Impl()->iLayoutPropertyCache ?
       
  9149             &( refNode->Impl()->iLayoutPropertyCache->iRights ) :
       
  9150             NULL;
       
  9151         return ReferredPropertyL( propertyArray, iStates );
       
  9152         }
       
  9153     CXnProperty* property =
       
  9154         iLayoutPropertyCache ? iLayoutPropertyCache->iRight : NULL;
       
  9155     return PropertyL( this, property, &CXnNode::RightL,
       
  9156         iUiEngine, iLayoutPropertyCache,
       
  9157         iParent, iRef );
       
  9158     }
       
  9159 
       
  9160 // -----------------------------------------------------------------------------
       
  9161 // CXnNodeImpl::TopL
       
  9162 // Returns top property.
       
  9163 // -----------------------------------------------------------------------------
       
  9164 //
       
  9165 CXnProperty* CXnNodeImpl::TopL()
       
  9166     {
       
  9167     CXnNode* refNode = RefNodeL( this, iRef, iUiEngine );
       
  9168     if ( refNode )
       
  9169         {
       
  9170         RPointerArray< CXnProperty >* propertyArray =
       
  9171             refNode->Impl()->iLayoutPropertyCache ?
       
  9172             &( refNode->Impl()->iLayoutPropertyCache->iTops ) :
       
  9173             NULL;
       
  9174         return ReferredPropertyL( propertyArray, iStates );
       
  9175         }
       
  9176     CXnProperty* property =
       
  9177         iLayoutPropertyCache ? iLayoutPropertyCache->iTop : NULL;
       
  9178     return PropertyL( this, property, &CXnNode::TopL,
       
  9179         iUiEngine, iLayoutPropertyCache,
       
  9180         iParent, iRef );
       
  9181     }
       
  9182 
       
  9183 // -----------------------------------------------------------------------------
       
  9184 // CXnNodeImpl::BottomL
       
  9185 // Returns bottom property.
       
  9186 // -----------------------------------------------------------------------------
       
  9187 //
       
  9188 CXnProperty* CXnNodeImpl::BottomL()
       
  9189     {
       
  9190     CXnNode* refNode = RefNodeL( this, iRef, iUiEngine );
       
  9191     if ( refNode )
       
  9192         {
       
  9193         RPointerArray< CXnProperty >* propertyArray =
       
  9194             refNode->Impl()->iLayoutPropertyCache ?
       
  9195             &( refNode->Impl()->iLayoutPropertyCache->iBottoms ) :
       
  9196             NULL;
       
  9197         return ReferredPropertyL( propertyArray, iStates );
       
  9198         }
       
  9199     CXnProperty* property =
       
  9200         iLayoutPropertyCache ? iLayoutPropertyCache->iBottom : NULL;
       
  9201     return PropertyL( this, property, &CXnNode::BottomL,
       
  9202         iUiEngine, iLayoutPropertyCache,
       
  9203         iParent, iRef );
       
  9204     }
       
  9205 
       
  9206 // -----------------------------------------------------------------------------
       
  9207 // CXnNodeImpl::BorderLeftStyleL
       
  9208 // Returns border-left-style property.
       
  9209 // -----------------------------------------------------------------------------
       
  9210 //
       
  9211 CXnProperty* CXnNodeImpl::BorderLeftStyleL()
       
  9212     {
       
  9213     CXnNode* refNode = RefNodeL( this, iRef, iUiEngine );
       
  9214     if ( refNode )
       
  9215         {
       
  9216         RPointerArray< CXnProperty >* propertyArray =
       
  9217             refNode->Impl()->iLayoutPropertyCache ?
       
  9218             &( refNode->Impl()->iLayoutPropertyCache->iBorderLeftStyles ) :
       
  9219             NULL;
       
  9220         return ReferredPropertyL( propertyArray, iStates );
       
  9221         }
       
  9222     CXnProperty* property =
       
  9223         iLayoutPropertyCache ? iLayoutPropertyCache->iBorderLeftStyle : NULL;
       
  9224     return PropertyL( this, property, &CXnNode::BorderLeftStyleL,
       
  9225         iUiEngine, iLayoutPropertyCache,
       
  9226         iParent, iRef );
       
  9227     }
       
  9228 
       
  9229 // -----------------------------------------------------------------------------
       
  9230 // CXnNodeImpl::BorderRightStyleL
       
  9231 // Returns border-right-style property.
       
  9232 // -----------------------------------------------------------------------------
       
  9233 //
       
  9234 CXnProperty* CXnNodeImpl::BorderRightStyleL()
       
  9235     {
       
  9236     CXnNode* refNode = RefNodeL( this, iRef, iUiEngine );
       
  9237     if ( refNode )
       
  9238         {
       
  9239         RPointerArray< CXnProperty >* propertyArray =
       
  9240             refNode->Impl()->iLayoutPropertyCache ?
       
  9241             &( refNode->Impl()->iLayoutPropertyCache->iBorderRightStyles ) :
       
  9242             NULL;
       
  9243         return ReferredPropertyL( propertyArray, iStates );
       
  9244         }
       
  9245     CXnProperty* property =
       
  9246         iLayoutPropertyCache ? iLayoutPropertyCache->iBorderRightStyle : NULL;
       
  9247     return PropertyL( this, property, &CXnNode::BorderRightStyleL,
       
  9248         iUiEngine, iLayoutPropertyCache,
       
  9249         iParent, iRef );
       
  9250     }
       
  9251 
       
  9252 // -----------------------------------------------------------------------------
       
  9253 // CXnNodeImpl::BorderTopStyleL
       
  9254 // Returns border-top-style property.
       
  9255 // -----------------------------------------------------------------------------
       
  9256 //
       
  9257 CXnProperty* CXnNodeImpl::BorderTopStyleL()
       
  9258     {
       
  9259     CXnNode* refNode = RefNodeL( this, iRef, iUiEngine );
       
  9260     if ( refNode )
       
  9261         {
       
  9262         RPointerArray< CXnProperty >* propertyArray =
       
  9263             refNode->Impl()->iLayoutPropertyCache ?
       
  9264             &( refNode->Impl()->iLayoutPropertyCache->iBorderTopStyles ) :
       
  9265             NULL;
       
  9266         return ReferredPropertyL( propertyArray, iStates );
       
  9267         }
       
  9268     CXnProperty* property =
       
  9269         iLayoutPropertyCache ? iLayoutPropertyCache->iBorderTopStyle : NULL;
       
  9270     return PropertyL( this, property, &CXnNode::BorderTopStyleL,
       
  9271         iUiEngine, iLayoutPropertyCache,
       
  9272         iParent, iRef );
       
  9273     }
       
  9274 
       
  9275 // -----------------------------------------------------------------------------
       
  9276 // CXnNodeImpl::BorderBottomStyleL
       
  9277 // Returns border-bottom-style property.
       
  9278 // -----------------------------------------------------------------------------
       
  9279 //
       
  9280 CXnProperty* CXnNodeImpl::BorderBottomStyleL()
       
  9281     {
       
  9282     CXnNode* refNode = RefNodeL( this, iRef, iUiEngine );
       
  9283     if ( refNode )
       
  9284         {
       
  9285         RPointerArray< CXnProperty >* propertyArray =
       
  9286             refNode->Impl()->iLayoutPropertyCache ?
       
  9287             &( refNode->Impl()->iLayoutPropertyCache->iBorderBottomStyles ) :
       
  9288             NULL;
       
  9289         return ReferredPropertyL( propertyArray, iStates );
       
  9290         }
       
  9291     CXnProperty* property =
       
  9292         iLayoutPropertyCache ? iLayoutPropertyCache->iBorderBottomStyle : NULL;
       
  9293     return PropertyL( this, property, &CXnNode::BorderBottomStyleL,
       
  9294         iUiEngine, iLayoutPropertyCache,
       
  9295         iParent, iRef );
       
  9296     }
       
  9297 
       
  9298 // -----------------------------------------------------------------------------
       
  9299 // CXnNodeImpl::BorderStyleL
       
  9300 // Returns border-style property.
       
  9301 // -----------------------------------------------------------------------------
       
  9302 //
       
  9303 CXnProperty* CXnNodeImpl::BorderStyleL()
       
  9304     {
       
  9305     CXnNode* refNode = RefNodeL( this, iRef, iUiEngine );
       
  9306     if ( refNode )
       
  9307         {
       
  9308         RPointerArray< CXnProperty >* propertyArray =
       
  9309             refNode->Impl()->iLayoutPropertyCache ?
       
  9310             &( refNode->Impl()->iLayoutPropertyCache->iBorderStyles ) :
       
  9311             NULL;
       
  9312         return ReferredPropertyL( propertyArray, iStates );
       
  9313         }
       
  9314     CXnProperty* property =
       
  9315         iLayoutPropertyCache ? iLayoutPropertyCache->iBorderStyle : NULL;
       
  9316     return PropertyL( this, property, &CXnNode::BorderStyleL,
       
  9317         iUiEngine, iLayoutPropertyCache,
       
  9318         iParent, iRef );
       
  9319     }
       
  9320 
       
  9321 // -----------------------------------------------------------------------------
       
  9322 // CXnNodeImpl::BorderImageL
       
  9323 // Returns border-image property.
       
  9324 // -----------------------------------------------------------------------------
       
  9325 //
       
  9326 CXnProperty* CXnNodeImpl::BorderImageL()
       
  9327     {
       
  9328     CXnProperty* property =
       
  9329         iLayoutPropertyCache ? iLayoutPropertyCache->iBorderImage : NULL;
       
  9330     return PropertyL( this, property, &CXnNode::BorderImageL,
       
  9331         iUiEngine, iLayoutPropertyCache,
       
  9332         iParent, iRef );
       
  9333     }
       
  9334 
       
  9335 // -----------------------------------------------------------------------------
       
  9336 // CXnNodeImpl::DisplayPriorityL
       
  9337 // Returns display-priority property.
       
  9338 // -----------------------------------------------------------------------------
       
  9339 //
       
  9340 CXnProperty* CXnNodeImpl::DisplayPriorityL()
       
  9341     {
       
  9342     CXnNode* refNode = RefNodeL( this, iRef, iUiEngine );
       
  9343     if ( refNode )
       
  9344         {
       
  9345         RPointerArray< CXnProperty >* propertyArray =
       
  9346             refNode->Impl()->iLayoutPropertyCache ?
       
  9347             &( refNode->Impl()->iLayoutPropertyCache->iDisplayPriorities ) :
       
  9348             NULL;
       
  9349         return ReferredPropertyL( propertyArray, iStates );
       
  9350         }
       
  9351     CXnProperty* property =
       
  9352         iLayoutPropertyCache ? iLayoutPropertyCache->iDisplayPriority : NULL;
       
  9353     return PropertyL( this, property, &CXnNode::DisplayPriorityL,
       
  9354         iUiEngine, iLayoutPropertyCache,
       
  9355         iParent, iRef );
       
  9356     }
       
  9357 
       
  9358 // -----------------------------------------------------------------------------
       
  9359 // CXnNodeImpl::NameL
       
  9360 // Returns name property.
       
  9361 // -----------------------------------------------------------------------------
       
  9362 //
       
  9363 CXnProperty* CXnNodeImpl::NameL()
       
  9364     {
       
  9365     return PropertyL( this, iName, &CXnNode::NameL,
       
  9366         iUiEngine, this,
       
  9367         iParent, iRef );
       
  9368     }
       
  9369 
       
  9370 // -----------------------------------------------------------------------------
       
  9371 // CXnNodeImpl::ValueL
       
  9372 // Returns value property.
       
  9373 // -----------------------------------------------------------------------------
       
  9374 //
       
  9375 CXnProperty* CXnNodeImpl::ValueL()
       
  9376     {
       
  9377     return PropertyL( this, iValue, &CXnNode::ValueL,
       
  9378         iUiEngine, this,
       
  9379         iParent, iRef );
       
  9380     }
       
  9381 
       
  9382 // -----------------------------------------------------------------------------
       
  9383 // CXnNodeImpl::VisibilityL
       
  9384 // Returns visibility property.
       
  9385 // -----------------------------------------------------------------------------
       
  9386 //
       
  9387 CXnProperty* CXnNodeImpl::VisibilityL()
       
  9388     {
       
  9389     CXnNode* refNode = RefNodeL( this, iRef, iUiEngine );
       
  9390     if ( refNode )
       
  9391         {
       
  9392         RPointerArray< CXnProperty >* propertyArray =
       
  9393             refNode->Impl()->iLayoutPropertyCache ?
       
  9394             &( refNode->Impl()->iLayoutPropertyCache->iVisibilities ) :
       
  9395             NULL;
       
  9396         return ReferredPropertyL( propertyArray, iStates );
       
  9397         }
       
  9398     CXnProperty* property =
       
  9399         iLayoutPropertyCache ? iLayoutPropertyCache->iVisibility : NULL;
       
  9400     return PropertyL( this, property, &CXnNode::VisibilityL,
       
  9401         iUiEngine, iLayoutPropertyCache,
       
  9402         iParent, iRef );
       
  9403     }
       
  9404 
       
  9405 // -----------------------------------------------------------------------------
       
  9406 // CXnNodeImpl::LabelL
       
  9407 // Returns label property.
       
  9408 // -----------------------------------------------------------------------------
       
  9409 //
       
  9410 CXnProperty* CXnNodeImpl::LabelL()
       
  9411     {
       
  9412     return PropertyL( this, iLabel, &CXnNode::LabelL,
       
  9413         iUiEngine, this,
       
  9414         iParent, iRef );
       
  9415     }
       
  9416 
       
  9417 // -----------------------------------------------------------------------------
       
  9418 // CXnNodeImpl::InitialFocusL
       
  9419 // Returns initial-focus property.
       
  9420 // -----------------------------------------------------------------------------
       
  9421 //
       
  9422 CXnProperty* CXnNodeImpl::InitialFocusL()
       
  9423     {
       
  9424     return PropertyL( this, iInitialFocus, &CXnNode::InitialFocusL,
       
  9425         iUiEngine, this,
       
  9426         iParent, iRef );
       
  9427     }
       
  9428 
       
  9429 // -----------------------------------------------------------------------------
       
  9430 // CXnNodeImpl::ClassL
       
  9431 // Returns class property.
       
  9432 // -----------------------------------------------------------------------------
       
  9433 //
       
  9434 CXnProperty* CXnNodeImpl::ClassL()
       
  9435     {
       
  9436     return PropertyL( this, iClass, &CXnNode::ClassL,
       
  9437         iUiEngine, this,
       
  9438         iParent, iRef );
       
  9439     }
       
  9440 
       
  9441 // -----------------------------------------------------------------------------
       
  9442 // CXnNodeImpl::IdL
       
  9443 // Returns id property.
       
  9444 // -----------------------------------------------------------------------------
       
  9445 //
       
  9446 CXnProperty* CXnNodeImpl::IdL()
       
  9447     {
       
  9448     if ( iId )
       
  9449         {
       
  9450         CXnDomProperty* attribute = iId->Property();
       
  9451         CXnDomList& list = attribute->PropertyValueList();
       
  9452         if ( list.Length() == 0 )
       
  9453             {
       
  9454             return NULL;
       
  9455             }
       
  9456         CXnDomPropertyValue* attributeValue =
       
  9457             static_cast< CXnDomPropertyValue* >( list.Item( 0 ) );
       
  9458         if ( !attributeValue )
       
  9459             {
       
  9460             return NULL;
       
  9461             }
       
  9462         if ( attributeValue->IsInheritIdent()
       
  9463             && iParent )
       
  9464             {
       
  9465             // inherited values are queried from the parent
       
  9466             return iParent->IdL();
       
  9467             }
       
  9468         // otherwise just return the value
       
  9469         return iId;
       
  9470         }
       
  9471     // if not found, return NULL
       
  9472     return NULL;
       
  9473     }
       
  9474 
       
  9475 // -----------------------------------------------------------------------------
       
  9476 // CXnNodeImpl::PathL
       
  9477 // Returns path property.
       
  9478 // -----------------------------------------------------------------------------
       
  9479 //
       
  9480 CXnProperty* CXnNodeImpl::PathL()
       
  9481     {
       
  9482     return PropertyL( this, iPath, &CXnNode::PathL,
       
  9483         iUiEngine, this,
       
  9484         iParent, iRef );
       
  9485     }
       
  9486 
       
  9487 // -----------------------------------------------------------------------------
       
  9488 // CXnNodeImpl::MaskPathL
       
  9489 // Returns maskpath property.
       
  9490 // -----------------------------------------------------------------------------
       
  9491 //
       
  9492 CXnProperty* CXnNodeImpl::MaskPathL()
       
  9493     {
       
  9494     return PropertyL( this, iMaskPath, &CXnNode::MaskPathL,
       
  9495         iUiEngine, this,
       
  9496         iParent, iRef );
       
  9497     }
       
  9498 
       
  9499 // -----------------------------------------------------------------------------
       
  9500 // CXnNodeImpl::NavIndexL
       
  9501 // Returns nav-index property.
       
  9502 // -----------------------------------------------------------------------------
       
  9503 //
       
  9504 CXnProperty* CXnNodeImpl::NavIndexL()
       
  9505     {
       
  9506     CXnNode* refNode = RefNodeL( this, iRef, iUiEngine );
       
  9507     if ( refNode )
       
  9508         {
       
  9509         RPointerArray< CXnProperty >* propertyArray =
       
  9510             refNode->Impl()->iLayoutPropertyCache ?
       
  9511             &( refNode->Impl()->iLayoutPropertyCache->iNavIndexes ) :
       
  9512             NULL;
       
  9513         return ReferredPropertyL( propertyArray, iStates );
       
  9514         }
       
  9515     CXnProperty* property =
       
  9516         iLayoutPropertyCache ? iLayoutPropertyCache->iNavIndex : NULL;
       
  9517     return PropertyL( this, property, &CXnNode::NavIndexL,
       
  9518         iUiEngine, iLayoutPropertyCache,
       
  9519         iParent, iRef );
       
  9520     }
       
  9521 
       
  9522 // -----------------------------------------------------------------------------
       
  9523 // CXnNodeImpl::VisibleRowsL
       
  9524 // Returns visible-rows property.
       
  9525 // -----------------------------------------------------------------------------
       
  9526 //
       
  9527 CXnProperty* CXnNodeImpl::VisibleRowsL()
       
  9528     {
       
  9529     CXnProperty* property =
       
  9530         iGridPropertyCache ? iGridPropertyCache->iVisibleRows : NULL;
       
  9531     return PropertyL( this, property, &CXnNode::VisibleRowsL,
       
  9532         iUiEngine, iGridPropertyCache,
       
  9533         iParent, iRef );
       
  9534     }
       
  9535 
       
  9536 // -----------------------------------------------------------------------------
       
  9537 // CXnNodeImpl::GridColumnsL
       
  9538 // Returns grid-columns property.
       
  9539 // -----------------------------------------------------------------------------
       
  9540 //
       
  9541 CXnProperty* CXnNodeImpl::GridColumnsL()
       
  9542     {
       
  9543     CXnProperty* property =
       
  9544         iGridPropertyCache ? iGridPropertyCache->iGridColumns : NULL;
       
  9545     return PropertyL( this, property, &CXnNode::GridColumnsL,
       
  9546         iUiEngine, iGridPropertyCache,
       
  9547         iParent, iRef );
       
  9548     }
       
  9549 
       
  9550 // -----------------------------------------------------------------------------
       
  9551 // CXnNodeImpl::GridOrientationL
       
  9552 // Returns grid-orientation property.
       
  9553 // -----------------------------------------------------------------------------
       
  9554 //
       
  9555 CXnProperty* CXnNodeImpl::GridOrientationL()
       
  9556     {
       
  9557     CXnProperty* property =
       
  9558         iGridPropertyCache ? iGridPropertyCache->iGridOrientation : NULL;
       
  9559     return PropertyL( this, property, &CXnNode::GridOrientationL,
       
  9560         iUiEngine, iGridPropertyCache,
       
  9561         iParent, iRef );
       
  9562     }
       
  9563 
       
  9564 // -----------------------------------------------------------------------------
       
  9565 // CXnNodeImpl::GridVerDirectionL
       
  9566 // Returns grid-ver-direction property.
       
  9567 // -----------------------------------------------------------------------------
       
  9568 //
       
  9569 CXnProperty* CXnNodeImpl::GridVerDirectionL()
       
  9570     {
       
  9571     CXnProperty* property =
       
  9572         iGridPropertyCache ? iGridPropertyCache->iGridVerDirection : NULL;
       
  9573     return PropertyL( this, property, &CXnNode::GridVerDirectionL,
       
  9574         iUiEngine, iGridPropertyCache,
       
  9575         iParent, iRef );
       
  9576     }
       
  9577 
       
  9578 // -----------------------------------------------------------------------------
       
  9579 // CXnNodeImpl::GridHorDirectionL
       
  9580 // Returns grid-hor-direction property.
       
  9581 // -----------------------------------------------------------------------------
       
  9582 //
       
  9583 CXnProperty* CXnNodeImpl::GridHorDirectionL()
       
  9584     {
       
  9585     CXnProperty* property =
       
  9586         iGridPropertyCache ? iGridPropertyCache->iGridHorDirection : NULL;
       
  9587     return PropertyL( this, property, &CXnNode::GridHorDirectionL,
       
  9588         iUiEngine, iGridPropertyCache,
       
  9589         iParent, iRef );
       
  9590     }
       
  9591 
       
  9592 // -----------------------------------------------------------------------------
       
  9593 // CXnNodeImpl::FocusHorLoopingL
       
  9594 // Returns focus-hor-looping property.
       
  9595 // -----------------------------------------------------------------------------
       
  9596 //
       
  9597 CXnProperty* CXnNodeImpl::FocusHorLoopingL()
       
  9598     {
       
  9599     CXnProperty* property =
       
  9600         iGridPropertyCache ? iGridPropertyCache->iFocusHorLooping : NULL;
       
  9601     return PropertyL( this, property, &CXnNode::FocusHorLoopingL,
       
  9602         iUiEngine, iGridPropertyCache,
       
  9603         iParent, iRef );
       
  9604     }
       
  9605 
       
  9606 // -----------------------------------------------------------------------------
       
  9607 // CXnNodeImpl::FocusVerLoopingL
       
  9608 // Returns focus-ver-looping property.
       
  9609 // -----------------------------------------------------------------------------
       
  9610 //
       
  9611 CXnProperty* CXnNodeImpl::FocusVerLoopingL()
       
  9612     {
       
  9613     CXnProperty* property =
       
  9614         iGridPropertyCache ? iGridPropertyCache->iFocusVerLooping : NULL;
       
  9615     return PropertyL( this, property, &CXnNode::FocusVerLoopingL,
       
  9616         iUiEngine, iGridPropertyCache,
       
  9617         iParent, iRef );
       
  9618     }
       
  9619 
       
  9620 // -----------------------------------------------------------------------------
       
  9621 // CXnNodeImpl::ZIndexL
       
  9622 // Returns z-index property.
       
  9623 // -----------------------------------------------------------------------------
       
  9624 //
       
  9625 CXnProperty* CXnNodeImpl::ZIndexL()
       
  9626     {
       
  9627     CXnNode* refNode = RefNodeL( this, iRef, iUiEngine );
       
  9628     if ( refNode )
       
  9629         {
       
  9630         RPointerArray< CXnProperty >* propertyArray =
       
  9631             refNode->Impl()->iLayoutPropertyCache ?
       
  9632             &( refNode->Impl()->iLayoutPropertyCache->iZIndexes ) :
       
  9633             NULL;
       
  9634         return ReferredPropertyL( propertyArray, iStates );
       
  9635         }
       
  9636     CXnProperty* property =
       
  9637         iLayoutPropertyCache ? iLayoutPropertyCache->iZIndex : NULL;
       
  9638     return PropertyL( this, property, &CXnNode::ZIndexL,
       
  9639         iUiEngine, iLayoutPropertyCache,
       
  9640         iParent, iRef );
       
  9641     }
       
  9642 
       
  9643 // -----------------------------------------------------------------------------
       
  9644 // CXnNodeImpl::BackgroundColorL
       
  9645 // Returns background-color property.
       
  9646 // -----------------------------------------------------------------------------
       
  9647 //
       
  9648 CXnProperty* CXnNodeImpl::BackgroundColorL()
       
  9649     {
       
  9650     CXnNode* refNode = RefNodeL( this, iRef, iUiEngine );
       
  9651     if ( refNode )
       
  9652         {
       
  9653         RPointerArray< CXnProperty >* propertyArray =
       
  9654             refNode->Impl()->iLayoutPropertyCache ?
       
  9655             &( refNode->Impl()->iLayoutPropertyCache->iBackgroundColors ) :
       
  9656             NULL;
       
  9657         return ReferredPropertyL( propertyArray, iStates );
       
  9658         }
       
  9659     CXnProperty* property =
       
  9660         iLayoutPropertyCache ? iLayoutPropertyCache->iBackgroundColor : NULL;
       
  9661     return PropertyL( this, property, &CXnNode::BackgroundColorL,
       
  9662         iUiEngine, iLayoutPropertyCache,
       
  9663         iParent, iRef );
       
  9664     }
       
  9665 
       
  9666 // -----------------------------------------------------------------------------
       
  9667 // CXnNodeImpl::BackgroundImageL
       
  9668 // Returns background-image property.
       
  9669 // -----------------------------------------------------------------------------
       
  9670 //
       
  9671 CXnProperty* CXnNodeImpl::BackgroundImageL()
       
  9672     {
       
  9673     CXnNode* refNode = RefNodeL( this, iRef, iUiEngine );
       
  9674     if ( refNode )
       
  9675         {
       
  9676         RPointerArray< CXnProperty >* propertyArray =
       
  9677             refNode->Impl()->iLayoutPropertyCache ?
       
  9678              &( refNode->Impl()->iLayoutPropertyCache->iBackgroundImages ) :
       
  9679              NULL;
       
  9680         return ReferredPropertyL( propertyArray, iStates );
       
  9681         }
       
  9682     CXnProperty* property =
       
  9683         iLayoutPropertyCache ? iLayoutPropertyCache->iBackgroundImage : NULL;
       
  9684     return PropertyL( this, property, &CXnNode::BackgroundImageL,
       
  9685         iUiEngine, iLayoutPropertyCache,
       
  9686         iParent, iRef );
       
  9687     }
       
  9688 
       
  9689 // -----------------------------------------------------------------------------
       
  9690 // CXnNodeImpl::FocusBackgroundL
       
  9691 // Returns focus-background property.
       
  9692 // -----------------------------------------------------------------------------
       
  9693 //
       
  9694 CXnProperty* CXnNodeImpl::FocusBackgroundL()
       
  9695     {
       
  9696     CXnNode* refNode = RefNodeL( this, iRef, iUiEngine );
       
  9697 
       
  9698     if ( refNode )
       
  9699         {
       
  9700         RPointerArray< CXnProperty >* propertyArray =
       
  9701             refNode->Impl()->iLayoutPropertyCache ?
       
  9702             &( refNode->Impl()->iLayoutPropertyCache->iFocusBackgrounds ) :
       
  9703             NULL;
       
  9704         return ReferredPropertyL( propertyArray, iStates );
       
  9705         }
       
  9706 
       
  9707     CXnProperty* property =
       
  9708         iLayoutPropertyCache ? iLayoutPropertyCache->iFocusBackground : NULL;
       
  9709 
       
  9710     return PropertyL( this, property, &CXnNode::FocusBackgroundL,
       
  9711         iUiEngine, iLayoutPropertyCache,
       
  9712         iParent, iRef );
       
  9713     }
       
  9714 
       
  9715 // -----------------------------------------------------------------------------
       
  9716 // CXnNodeImpl::RefL
       
  9717 // Returns ref property.
       
  9718 // -----------------------------------------------------------------------------
       
  9719 //
       
  9720 CXnProperty* CXnNodeImpl::RefL()
       
  9721     {
       
  9722     return iRef;
       
  9723     }
       
  9724 
       
  9725 // -----------------------------------------------------------------------------
       
  9726 // CXnNodeImpl::GridScrollBarWidthL
       
  9727 // Returns grid-scrollbar-width property.
       
  9728 // -----------------------------------------------------------------------------
       
  9729 //
       
  9730 CXnProperty* CXnNodeImpl::GridScrollBarWidthL()
       
  9731     {
       
  9732     CXnProperty* property = NULL;
       
  9733 
       
  9734     if ( iGridPropertyCache && iGridPropertyCache->iGridScrollBarWidth)
       
  9735         {
       
  9736         property = PropertyL(
       
  9737             this,
       
  9738             iGridPropertyCache->iGridScrollBarWidth,
       
  9739             &CXnNode::GridScrollBarWidthL,
       
  9740             iUiEngine, iGridPropertyCache,
       
  9741             iParent,
       
  9742             iRef );
       
  9743         }
       
  9744 
       
  9745     if ( !property && iRef )
       
  9746         {
       
  9747         CXnNode* refNode = RefNodeL( this, iRef, iUiEngine );
       
  9748 
       
  9749         if ( refNode )
       
  9750             {
       
  9751             property = refNode->GridScrollBarWidthL();
       
  9752             }
       
  9753         }
       
  9754 
       
  9755     if ( !property )
       
  9756         {
       
  9757         TReal sbWidth( KS60ScrollbarDefaultWidth );
       
  9758         // Set default value
       
  9759         CXnDomDocument& doc = iUiEngine->ODT()->DomDocument();
       
  9760         CXnDomProperty* domProperty = CXnDomProperty::NewL(
       
  9761             XnPropertyNames::grid::KS60GridScrollbarWidth, doc.StringPool() );
       
  9762         CleanupStack::PushL( domProperty );
       
  9763         CXnDomPropertyValue* propertyValue = CXnDomPropertyValue::NewL(
       
  9764             doc.StringPool() );
       
  9765         CleanupStack::PushL( propertyValue );
       
  9766         if ( AknLayoutUtils::PenEnabled() )
       
  9767             {
       
  9768             sbWidth = KS60ScrollbarDefaultWidthPenEnabled;
       
  9769             }
       
  9770         propertyValue->SetFloatValueL( CXnDomPropertyValue::EUnitValue, sbWidth );
       
  9771         domProperty->PropertyValueList().AddItemL( propertyValue );
       
  9772         CleanupStack::Pop( propertyValue );
       
  9773 
       
  9774         property = CXnProperty::NewL( domProperty );
       
  9775         CleanupStack::Pop( domProperty );
       
  9776         CleanupStack::PushL( property );
       
  9777 
       
  9778         // If this is a reference node, set property to the referred node, not this.
       
  9779         CXnNode* node = RefNodeL( this, iRef, iUiEngine );
       
  9780         if ( node )
       
  9781             {
       
  9782             node->SetPropertyL( property );
       
  9783             }
       
  9784         else
       
  9785             {
       
  9786             this->SetPropertyL( property ); // deletes existing one
       
  9787             }
       
  9788 
       
  9789         CleanupStack::Pop( property );
       
  9790         }
       
  9791 
       
  9792     return property;
       
  9793     }
       
  9794 
       
  9795 // -----------------------------------------------------------------------------
       
  9796 // CXnNodeImpl::GridScrollBarMarginL
       
  9797 // Returns grid-scrollbar-margin property.
       
  9798 // -----------------------------------------------------------------------------
       
  9799 //
       
  9800 CXnProperty* CXnNodeImpl::GridScrollBarMarginL()
       
  9801     {
       
  9802     CXnProperty* property = NULL;
       
  9803     if ( iGridPropertyCache && iGridPropertyCache->iGridScrollBarMargin )
       
  9804         {
       
  9805         property = PropertyL(
       
  9806             this,
       
  9807             iGridPropertyCache->iGridScrollBarMargin,
       
  9808             &CXnNode::GridScrollBarMarginL,
       
  9809             iUiEngine, iGridPropertyCache,
       
  9810             iParent,
       
  9811             iRef );
       
  9812         }
       
  9813 
       
  9814     if ( !property && iRef )
       
  9815         {
       
  9816         CXnNode* refNode = RefNodeL( this, iRef, iUiEngine );
       
  9817 
       
  9818         if ( refNode )
       
  9819             {
       
  9820             property = refNode->GridScrollBarMarginL();
       
  9821             }
       
  9822         }
       
  9823 
       
  9824     if ( !property )
       
  9825         {
       
  9826         TReal sbMarginWidth( KS60ScrollbarDefaultMargin );
       
  9827         // Set default value
       
  9828         CXnDomDocument& doc = iUiEngine->ODT()->DomDocument();
       
  9829         CXnDomProperty* domProperty =
       
  9830             CXnDomProperty::NewL(
       
  9831                 XnPropertyNames::grid::KS60GridScrollbarMargin,
       
  9832                 doc.StringPool() );
       
  9833         CleanupStack::PushL( domProperty );
       
  9834         CXnDomPropertyValue* propertyValue = CXnDomPropertyValue::NewL(
       
  9835             doc.StringPool() );
       
  9836         CleanupStack::PushL( propertyValue );
       
  9837         if ( AknLayoutUtils::PenEnabled() )
       
  9838             {
       
  9839             sbMarginWidth = KS60ScrollbarDefaultMarginPenEnabled;
       
  9840             }
       
  9841         propertyValue->SetFloatValueL(
       
  9842             CXnDomPropertyValue::EUnitValue, sbMarginWidth );
       
  9843         domProperty->PropertyValueList().AddItemL( propertyValue );
       
  9844         CleanupStack::Pop( propertyValue );
       
  9845 
       
  9846         property = CXnProperty::NewL( domProperty );
       
  9847         CleanupStack::Pop( domProperty );
       
  9848         CleanupStack::PushL( property );
       
  9849 
       
  9850         // If this is a reference node, set property to the referred node, not this.
       
  9851         CXnNode* node = RefNodeL( this, iRef, iUiEngine );
       
  9852         if ( node )
       
  9853             {
       
  9854             node->SetPropertyL( property );
       
  9855             }
       
  9856         else
       
  9857             {
       
  9858             this->SetPropertyL( property ); // deletes existing one
       
  9859             }
       
  9860 
       
  9861         CleanupStack::Pop(property);
       
  9862         }
       
  9863     return property;
       
  9864     }
       
  9865 
       
  9866 // ----------------------------------------------------------------------------
       
  9867 // CXnNodeImpl::SetDomNode
       
  9868 // Sets DOM node
       
  9869 // ----------------------------------------------------------------------------
       
  9870 //
       
  9871 void CXnNodeImpl::SetDomNode( CXnDomNode* aDomNode )
       
  9872     {
       
  9873     iDomNode = aDomNode;
       
  9874     }
       
  9875 
       
  9876 // ----------------------------------------------------------------------------
       
  9877 // CXnNodeImpl::DomNode
       
  9878 // Returns the DOM node pointer
       
  9879 // ----------------------------------------------------------------------------
       
  9880 //
       
  9881 CXnDomNode* CXnNodeImpl::DomNode()
       
  9882     {
       
  9883     return iDomNode;
       
  9884     }
       
  9885 
       
  9886 // ----------------------------------------------------------------------------
       
  9887 // CXnNodeImpl::MeasureAdaptiveContentL
       
  9888 // Measures the adaptive content dimensions.
       
  9889 // ----------------------------------------------------------------------------
       
  9890 //
       
  9891 TSize CXnNodeImpl::MeasureAdaptiveContentL( const TSize& aAvailableSize )
       
  9892     {
       
  9893     TSize empty;
       
  9894 
       
  9895     TInt adaptive( IsAdaptive() );
       
  9896 
       
  9897     if ( aAvailableSize.iWidth <= 0 && ( adaptive & XnAdaptive::EWidth ) ||
       
  9898          aAvailableSize.iHeight <= 0 && ( adaptive & XnAdaptive::EHeight ) )
       
  9899         {
       
  9900         // No available size, don't even try to measure
       
  9901         return empty;
       
  9902         }
       
  9903 
       
  9904     // node is displayed as default
       
  9905     TBool displayed( ETrue );
       
  9906 
       
  9907     CXnProperty* displayProp( DisplayL() );
       
  9908 
       
  9909     if ( displayProp )
       
  9910         {
       
  9911         const TDesC8& value( displayProp->StringValue() );
       
  9912 
       
  9913         if ( value != XnPropertyNames::style::common::display::KBlock )
       
  9914             {
       
  9915             // Not displayed
       
  9916             displayed = EFalse;
       
  9917             }
       
  9918         }
       
  9919 
       
  9920     if ( adaptive && iLayoutCapable && !iDropped && displayed )
       
  9921         {
       
  9922         CXnControlAdapter* adapter( iNode->Control() );
       
  9923 
       
  9924         // What is my size?
       
  9925         if ( adapter )
       
  9926             {
       
  9927             TInt width( 0 );
       
  9928             TInt height( 0 );
       
  9929 
       
  9930             TSize size = adapter->MeasureAdaptiveContentL( aAvailableSize );
       
  9931 
       
  9932             if ( adaptive & XnAdaptive::EWidth )
       
  9933                 {
       
  9934                 width = size.iWidth;
       
  9935                 }
       
  9936 
       
  9937             if ( adaptive & XnAdaptive::EHeight )
       
  9938                 {
       
  9939                 height = size.iHeight;
       
  9940                 }
       
  9941 
       
  9942             return TSize( width, height );
       
  9943             }
       
  9944         }
       
  9945 
       
  9946     return empty;
       
  9947     }
       
  9948 
       
  9949 // ----------------------------------------------------------------------------
       
  9950 // CXnNodeImpl::IsAdaptive
       
  9951 // Checks if the node have adaptive content
       
  9952 // ----------------------------------------------------------------------------
       
  9953 //
       
  9954 TInt CXnNodeImpl::IsAdaptive( TBool aIgnoreSizeFixed ) const
       
  9955     {
       
  9956     if ( !iAdaptive )
       
  9957         {
       
  9958         return XnAdaptive::ENone;
       
  9959         }
       
  9960 
       
  9961     TInt adaptive( iAdaptive );
       
  9962 
       
  9963     if ( ( adaptive & XnAdaptive::ESizeFixed ) && !aIgnoreSizeFixed )
       
  9964         {
       
  9965         // When size is fixed, pretend non-adaptive
       
  9966         return XnAdaptive::ENone;
       
  9967         }
       
  9968 
       
  9969     // Remove measure control  flags
       
  9970     adaptive &= ~XnAdaptive::EMeasure;
       
  9971     adaptive &= ~XnAdaptive::ESizeFixed;
       
  9972 
       
  9973     return adaptive;
       
  9974     }
       
  9975 
       
  9976 // ----------------------------------------------------------------------------
       
  9977 // CXnNodeImpl::SetAdaptiveL
       
  9978 // Marks the node to have adaptive content
       
  9979 // ----------------------------------------------------------------------------
       
  9980 //
       
  9981 void CXnNodeImpl::SetAdaptiveL( const TInt aAdaptive )
       
  9982     {
       
  9983     TInt adaptive( aAdaptive );
       
  9984 
       
  9985     // Force adaptive nodes to be auto
       
  9986     if ( adaptive & XnAdaptive::EMeasure )
       
  9987         {
       
  9988         if ( iAdaptive & XnAdaptive::EMeasure )
       
  9989             {
       
  9990             // Measure already pending
       
  9991             return;
       
  9992             }
       
  9993 
       
  9994         if ( iAdaptive & XnAdaptive::EWidth )
       
  9995             {
       
  9996             adaptive |= XnAdaptive::EWidth;
       
  9997             }
       
  9998 
       
  9999         if ( iAdaptive & XnAdaptive::EHeight )
       
 10000             {
       
 10001             adaptive |= XnAdaptive::EHeight;
       
 10002             }
       
 10003 
       
 10004         // Reset
       
 10005         iAdaptive = XnAdaptive::ENone;
       
 10006         }
       
 10007 
       
 10008     if ( ( adaptive & XnAdaptive::EWidth ) &&
       
 10009            !( iAdaptive & XnAdaptive::EWidth ) )
       
 10010         {
       
 10011         iAdaptive |= XnAdaptive::EIgnoreDirty;
       
 10012 
       
 10013         SetStringPropertyToNodeL(
       
 10014             DomNode()->StringPool(), *Node(),
       
 10015             XnPropertyNames::style::common::KWidth,
       
 10016             XnPropertyNames::style::common::KAuto );
       
 10017 
       
 10018         // Width is adaptive
       
 10019         iAdaptive |= XnAdaptive::EWidth;
       
 10020 
       
 10021         iAdaptive &= ~XnAdaptive::EIgnoreDirty;
       
 10022         }
       
 10023 
       
 10024     if ( ( adaptive & XnAdaptive::EHeight ) &&
       
 10025          !( iAdaptive & XnAdaptive::EHeight ) )
       
 10026         {
       
 10027         iAdaptive |= XnAdaptive::EIgnoreDirty;
       
 10028 
       
 10029         SetStringPropertyToNodeL(
       
 10030             DomNode()->StringPool(), *Node(),
       
 10031             XnPropertyNames::style::common::KHeight,
       
 10032             XnPropertyNames::style::common::KAuto );
       
 10033 
       
 10034         // Height is adaptive
       
 10035         iAdaptive |= XnAdaptive::EHeight;
       
 10036 
       
 10037         iAdaptive &= ~XnAdaptive::EIgnoreDirty;
       
 10038         }
       
 10039 
       
 10040     // Size is no more fixed
       
 10041     iAdaptive &= ~XnAdaptive::ESizeFixed;
       
 10042 
       
 10043     // and it needs to be measured
       
 10044     iAdaptive |= XnAdaptive::EMeasure;
       
 10045     }
       
 10046 
       
 10047 // ----------------------------------------------------------------------------
       
 10048 // CXnNodeImpl::FixAdaptiveSize
       
 10049 // Fixes the adaptive node's size
       
 10050 // ----------------------------------------------------------------------------
       
 10051 //
       
 10052 void CXnNodeImpl::FixAdaptiveSizeL( const TSize& aFixedSize )
       
 10053     {
       
 10054     // Is there measure pending
       
 10055     if ( iAdaptive & XnAdaptive::EMeasure )
       
 10056         {
       
 10057         if ( iAdaptive & XnAdaptive::EWidth )
       
 10058             {
       
 10059             iAdaptive |= XnAdaptive::EIgnoreDirty;
       
 10060 
       
 10061             SetFloatPropertyToNodeL(
       
 10062                 DomNode()->StringPool(), *Node(),
       
 10063                 XnPropertyNames::style::common::KWidth,
       
 10064                 aFixedSize.iWidth, CXnDomPropertyValue::EPx );
       
 10065 
       
 10066             iAdaptive &= ~XnAdaptive::EIgnoreDirty;
       
 10067             }
       
 10068 
       
 10069         if ( iAdaptive & XnAdaptive::EHeight )
       
 10070             {
       
 10071             iAdaptive |= XnAdaptive::EIgnoreDirty;
       
 10072 
       
 10073             SetFloatPropertyToNodeL(
       
 10074                 DomNode()->StringPool(), *Node(),
       
 10075                 XnPropertyNames::style::common::KHeight,
       
 10076                 aFixedSize.iHeight, CXnDomPropertyValue::EPx );
       
 10077 
       
 10078             iAdaptive &= ~XnAdaptive::EIgnoreDirty;
       
 10079             }
       
 10080 
       
 10081         // Measure done
       
 10082         iAdaptive &= ~XnAdaptive::EMeasure;
       
 10083         // Size is now fixed
       
 10084         iAdaptive |= XnAdaptive::ESizeFixed;
       
 10085         }
       
 10086     }
       
 10087 
       
 10088 // ----------------------------------------------------------------------------
       
 10089 // CXnNodeImpl::PeriodicEventL
       
 10090 // ----------------------------------------------------------------------------
       
 10091 //
       
 10092 TInt CXnNodeImpl::PeriodicEventL( TAny* aPtr )
       
 10093     {
       
 10094     TXnTimedTrigger* params = static_cast< TXnTimedTrigger* >( aPtr );
       
 10095     CXnNodeImpl* impl = params->iNodeImpl;
       
 10096     CXnUiEngine* engine = params->iEngine;
       
 10097     CXnNode* node = params->iNode;
       
 10098     CXnNode* eventData = params->iEventData;
       
 10099     CXnDomNode* actionNode = params->iActionNode;
       
 10100     CXnDomNode* triggerNode = params->iTriggerNode;
       
 10101     RunEventsL( impl, *engine, *node, *actionNode, *triggerNode, *eventData );
       
 10102     delete params;
       
 10103     impl->DeletePeriodic();
       
 10104     return EFalse;
       
 10105     }
       
 10106 
       
 10107 // ----------------------------------------------------------------------------
       
 10108 // CXnNodeImpl::PeriodicTimer
       
 10109 // ----------------------------------------------------------------------------
       
 10110 //
       
 10111 CPeriodic* CXnNodeImpl::PeriodicTimer()
       
 10112     {
       
 10113     return iPeriodicTimer;
       
 10114     }
       
 10115 
       
 10116 // ----------------------------------------------------------------------------
       
 10117 // CXnNodeImpl::CreatePeriodicL
       
 10118 // ----------------------------------------------------------------------------
       
 10119 //
       
 10120 void CXnNodeImpl::CreatePeriodicL()
       
 10121     {
       
 10122     iPeriodicTimer = CPeriodic::NewL( CActive::EPriorityIdle );
       
 10123     }
       
 10124 
       
 10125 // ---------------------------------------------------------
       
 10126 // CXnNodeImpl::DeletePeriodic
       
 10127 // ---------------------------------------------------------
       
 10128 //
       
 10129 void CXnNodeImpl::DeletePeriodic()
       
 10130     {
       
 10131     if ( iPeriodicTimer )
       
 10132         {
       
 10133         iPeriodicTimer->Cancel();
       
 10134         delete iPeriodicTimer;
       
 10135         iPeriodicTimer = NULL;
       
 10136         }
       
 10137     }
       
 10138 
       
 10139 // -----------------------------------------------------------------------------
       
 10140 // CXnNodeImpl::SetDirtyL
       
 10141 // -----------------------------------------------------------------------------
       
 10142 //
       
 10143 void CXnNodeImpl::SetDirtyL( TInt aLevel, TBool aDisplayedState )
       
 10144     {
       
 10145     if( !aDisplayedState )
       
 10146         {
       
 10147         // check if node isn't displayed indeed (def. param. = EFalse)
       
 10148         aDisplayedState = IsNodeDisplayedL( *iNode );
       
 10149         }
       
 10150     if ( iLayoutCapable )
       
 10151         {
       
 10152         if ( aLevel == XnDirtyLevel::ENone  )
       
 10153             {
       
 10154             // nothing to do
       
 10155             return;
       
 10156             }
       
 10157 
       
 10158         if ( aLevel == XnDirtyLevel::ELayoutAndRenderSiblings )
       
 10159             {
       
 10160             if ( iParent )
       
 10161                 {
       
 10162                 // Siblings needs to be laid out also
       
 10163                 RPointerArray< CXnNode >& siblings( iParent->Children() );
       
 10164 
       
 10165                 for ( TInt i = 0; i < siblings.Count(); i++ )
       
 10166                     {
       
 10167                     CXnNode* sibling( siblings[i] );
       
 10168 
       
 10169                     if ( sibling == iNode )
       
 10170                         {
       
 10171                         sibling->SetDirtyL( XnDirtyLevel::ELayoutAndRender,
       
 10172                             aDisplayedState );
       
 10173                         }
       
 10174                     else
       
 10175                         {
       
 10176                         sibling->SetDirtyL( XnDirtyLevel::ELayoutAndRender );
       
 10177                         }
       
 10178                     }
       
 10179                 }
       
 10180             }
       
 10181         else
       
 10182             {
       
 10183             if ( ( iParent || iNode == iUiEngine->RootNode() ) &&
       
 10184                  iNode != iUiEngine->ActiveView() )
       
 10185                 {
       
 10186                 // Full redraw (without layout) can be done by setting rootnode
       
 10187                 // level to ERender
       
 10188                 if ( aLevel == XnDirtyLevel::ERender && !iLaidOut &&
       
 10189                      iNode != iUiEngine->RootNode() )
       
 10190                     {
       
 10191                     aLevel = XnDirtyLevel::ELayoutAndRender;
       
 10192                     }
       
 10193 
       
 10194                 if ( aDisplayedState )
       
 10195                     {
       
 10196                     iUiEngine->AddDirtyNodeL( iNode, aLevel );
       
 10197                     }
       
 10198                 else
       
 10199                     {
       
 10200                     ClearRenderedAndLaidOut();
       
 10201                     }
       
 10202                 }
       
 10203             }
       
 10204         }
       
 10205     else if ( iParent && iParent->Type()->Type() == KMenuBar )
       
 10206         {
       
 10207         // Mark menu to be refreshed
       
 10208         iUiEngine->AddDirtyNodeL( iParent, XnDirtyLevel::ERender );
       
 10209         }
       
 10210     }
       
 10211 
       
 10212 // -----------------------------------------------------------------------------
       
 10213 // CXnNodeImpl::RunFocusChangeL
       
 10214 // -----------------------------------------------------------------------------
       
 10215 //
       
 10216 TBool CXnNodeImpl::RunFocusChangeL( RPointerArray< CXnNode >& aFocusCandidates )
       
 10217     {
       
 10218     for ( TInt i = 0; i < aFocusCandidates.Count(); i++ )
       
 10219         {
       
 10220         CXnNode* node( aFocusCandidates[i] );
       
 10221 
       
 10222         if ( IsNodeNavigableL( *node ) )
       
 10223             {                       
       
 10224             if( node->ScrollableControl() )
       
 10225                 {
       
 10226                 node->ScrollableControl()->ShowItem( *node );
       
 10227                 }
       
 10228             
       
 10229             node->SetStateWithoutNotificationL(
       
 10230                 XnPropertyNames::style::common::KFocus );
       
 10231             
       
 10232             // All done
       
 10233             return ETrue;
       
 10234             }
       
 10235         }
       
 10236 
       
 10237     // Focus change failed
       
 10238     CXnNode* focused( iUiEngine->FocusedNode() );
       
 10239 
       
 10240     if ( focused )
       
 10241         {
       
 10242         // Is the currently focused node still navigable
       
 10243         if ( !IsNodeNavigableL( *focused ) )
       
 10244             {
       
 10245             // No, remove focus
       
 10246             focused->UnsetStateL( XnPropertyNames::style::common::KFocus );            
       
 10247             }
       
 10248         }
       
 10249 
       
 10250     return EFalse;
       
 10251     }
       
 10252 
       
 10253 // -----------------------------------------------------------------------------
       
 10254 // CXnNodeImpl::ReorderNodesL
       
 10255 // -----------------------------------------------------------------------------
       
 10256 //
       
 10257 void CXnNodeImpl::ReorderNodesL( CXnNode* aSource, CXnNode* aTarget )
       
 10258     {
       
 10259     TInt target = -1;
       
 10260     TInt source = -1;
       
 10261     TInt childCount = iChildren.Count();
       
 10262     RPointerArray< CXnNode > lockedNodes;
       
 10263     CleanupClosePushL( lockedNodes );
       
 10264     RArray< TInt > lockedNodeIndex;
       
 10265     CleanupClosePushL( lockedNodeIndex );
       
 10266 
       
 10267     for ( TInt i = 0; i < childCount; i++ )
       
 10268         {
       
 10269         CXnNode* tmpNode = iChildren[i];
       
 10270         CXnProperty* editable = tmpNode->GetPropertyL(
       
 10271             XnPropertyNames::style::common::edit::KEditable );
       
 10272         if ( editable && editable->StringValue() == XnPropertyNames::KFalse )
       
 10273             {
       
 10274             lockedNodes.AppendL( tmpNode );
       
 10275             lockedNodeIndex.AppendL( i );
       
 10276             continue;
       
 10277             }
       
 10278 
       
 10279         if ( tmpNode == aSource )
       
 10280             {
       
 10281             source = i;
       
 10282             }
       
 10283         if ( tmpNode == aTarget )
       
 10284             {
       
 10285             target = i;
       
 10286             }
       
 10287         }
       
 10288     if ( source != -1 && target != -1 )
       
 10289         {
       
 10290         if ( target < source )
       
 10291             {
       
 10292             iChildren.InsertL( aSource, target );
       
 10293             iChildren.Remove( source + 1 );
       
 10294             }
       
 10295         else if ( source < target )
       
 10296             {
       
 10297             iChildren.Remove( source );
       
 10298             iChildren.InsertL( aSource, target );
       
 10299             }
       
 10300 
       
 10301         // put the locked nodes to the original places
       
 10302         TInt lockedNodeCount = lockedNodes.Count();
       
 10303         TInt lockedIndexCount = lockedNodeIndex.Count();
       
 10304         if ( lockedNodeCount != lockedIndexCount )
       
 10305             {
       
 10306             return;
       
 10307             }
       
 10308         // First remove all the locked nodes
       
 10309         for ( TInt j = 0; j < lockedNodeCount; j++ )
       
 10310             {
       
 10311             CXnNode* tmpLockedNode = lockedNodes[j];
       
 10312             TInt ind = iChildren.FindL( tmpLockedNode );
       
 10313             if ( KErrNotFound != ind )
       
 10314                 {
       
 10315                 iChildren.Remove( ind );
       
 10316                 }
       
 10317             }
       
 10318 
       
 10319         //And then put them again to the original places
       
 10320         for ( TInt j = 0; j < lockedNodeCount; j++ )
       
 10321             {
       
 10322             CXnNode* tmpLockedNode = lockedNodes[j];
       
 10323             iChildren.InsertL( tmpLockedNode, lockedNodeIndex[j] );
       
 10324             }
       
 10325         }
       
 10326 
       
 10327     lockedNodes.Reset();
       
 10328     lockedNodeIndex.Reset();
       
 10329     CleanupStack::PopAndDestroy( 2 ); // lockedNodes, lockedNodeIndex
       
 10330     }
       
 10331 
       
 10332 // -----------------------------------------------------------------------------
       
 10333 // CXnNodeImpl::FindNextNodeL
       
 10334 // -----------------------------------------------------------------------------
       
 10335 //
       
 10336 CXnNode* CXnNodeImpl::FindNextNodeL(
       
 10337     RPointerArray< CXnNode >& aArray,
       
 10338     CXnNode& aNode,
       
 10339     TInt aDirection )
       
 10340     {
       
 10341     CXnNode* node = NULL;
       
 10342     if ( aDirection == EStdKeyRightArrow )
       
 10343         {
       
 10344         node = FindNextNodeFromRightL( aArray, aNode );
       
 10345         }
       
 10346     else if ( aDirection == EStdKeyLeftArrow )
       
 10347         {
       
 10348         node = FindNextNodeFromLeftL( aArray, aNode );
       
 10349         }
       
 10350     else if ( aDirection == EStdKeyUpArrow )
       
 10351         {
       
 10352         node = FindNextNodeFromAboveL( aArray, aNode );
       
 10353         }
       
 10354     else if ( aDirection == EStdKeyDownArrow )
       
 10355         {
       
 10356         node = FindNextNodeFromBelowL( aArray, aNode );
       
 10357         }
       
 10358     return node;
       
 10359     }
       
 10360 
       
 10361 // -----------------------------------------------------------------------------
       
 10362 // CXnNodeImpl::Namespace
       
 10363 // -----------------------------------------------------------------------------
       
 10364 //
       
 10365 const TDesC8& CXnNodeImpl::Namespace()
       
 10366     {
       
 10367     return DomNode()->Namespace();
       
 10368     }
       
 10369 
       
 10370 // -----------------------------------------------------------------------------
       
 10371 // CXnNodeImpl::SetScrollableControl()
       
 10372 // -----------------------------------------------------------------------------
       
 10373 //      
       
 10374 void CXnNodeImpl::SetScrollableControl( CXnScrollableControlAdapter* aScrollableControl )
       
 10375     {
       
 10376     iScrollableControl = aScrollableControl;
       
 10377     }
       
 10378 
       
 10379 // -----------------------------------------------------------------------------
       
 10380 // CXnNodeImpl::ScrollableControl()
       
 10381 // -----------------------------------------------------------------------------
       
 10382 //      
       
 10383 CXnScrollableControlAdapter* CXnNodeImpl::ScrollableControl()
       
 10384     {
       
 10385     return iScrollableControl;
       
 10386     }
       
 10387 
       
 10388 // -----------------------------------------------------------------------------
       
 10389 // CXnNodeImpl::AdjustRectIfNeeded
       
 10390 // -----------------------------------------------------------------------------
       
 10391 //      
       
 10392 TRect CXnNodeImpl::AdjustRectIfNeeded( TRect aRect )
       
 10393     {
       
 10394     if(iScrollableControl) 
       
 10395         {
       
 10396         aRect.Move( iScrollableControl->DeltaPosition() );
       
 10397         }
       
 10398     return aRect;
       
 10399     }
       
 10400