idlehomescreen/xmluirendering/uiengine/src/xnnodepluginif.cpp
changeset 0 f72a12da539e
child 2 08c6ee43b396
equal deleted inserted replaced
-1:000000000000 0:f72a12da539e
       
     1 /*
       
     2 * Copyright (c) 2002-2004 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:  Node of the layout tree
       
    15 *
       
    16 */
       
    17 
       
    18 
       
    19 // User includes
       
    20 #include "xnnodepluginif.h"
       
    21 #include "xnnode.h"
       
    22 #include "xnuiengine.h"
       
    23 #include "xncomponentnodeimpl.h"
       
    24 #include "xnproperty.h"
       
    25 #include "xntype.h"
       
    26 #include "xndomdocument.h"
       
    27 #include "xnodt.h"
       
    28 
       
    29 // ============================ MEMBER FUNCTIONS ===============================
       
    30 
       
    31 // -----------------------------------------------------------------------------
       
    32 // CXnNodePluginIf::CXnNodePluginIf()
       
    33 // C++ default constructor can NOT contain any code, that
       
    34 // might leave.
       
    35 // -----------------------------------------------------------------------------
       
    36 //
       
    37 CXnNodePluginIf::CXnNodePluginIf( CXnNode& aNode )
       
    38     {
       
    39     iNode = &aNode;
       
    40     }
       
    41 
       
    42 // -----------------------------------------------------------------------------
       
    43 // CXnNodePluginIf::ViewNodeImpl
       
    44 // -----------------------------------------------------------------------------
       
    45 //
       
    46 EXPORT_C CXnViewNodeImpl* CXnNodePluginIf::ViewNodeImpl()
       
    47     {
       
    48     return iNode->ViewNodeImpl();
       
    49     }
       
    50 
       
    51 // -----------------------------------------------------------------------------
       
    52 // CXnNodePluginIf::ComponentNodeImpl
       
    53 // -----------------------------------------------------------------------------
       
    54 //
       
    55 EXPORT_C CXnComponentNodeImpl* CXnNodePluginIf::ComponentNodeImpl()
       
    56     {
       
    57     return iNode->ComponentNodeImpl();
       
    58     }
       
    59 
       
    60 // -----------------------------------------------------------------------------
       
    61 // CXnNodePluginIf::IsDrawingAllowed
       
    62 // -----------------------------------------------------------------------------
       
    63 //
       
    64 TBool CXnNodePluginIf::IsDrawingAllowed() const
       
    65     {
       
    66     return EFalse;
       
    67     }
       
    68 
       
    69 // -----------------------------------------------------------------------------
       
    70 // CXnNodePluginIf::Type()
       
    71 // Returns control type.
       
    72 // -----------------------------------------------------------------------------
       
    73 //
       
    74 EXPORT_C CXnType* CXnNodePluginIf::Type()
       
    75     {
       
    76     return iNode->Type();
       
    77     }
       
    78 
       
    79 // -----------------------------------------------------------------------------
       
    80 // CXnNodePluginIf::Parent
       
    81 // Get component parent
       
    82 // -----------------------------------------------------------------------------
       
    83 //
       
    84 EXPORT_C CXnNodePluginIf* CXnNodePluginIf::ParentL() const
       
    85     {
       
    86     CXnNode* node = iNode->Parent();
       
    87     if ( !node )
       
    88         {
       
    89         return NULL;
       
    90         }
       
    91     return &( node->PluginIfL() );
       
    92     }
       
    93 
       
    94 // -----------------------------------------------------------------------------
       
    95 // CXnNodePluginIf::AddChildL
       
    96 // Adds a child to this container.
       
    97 // -----------------------------------------------------------------------------
       
    98 //
       
    99 EXPORT_C void CXnNodePluginIf::AddChildL( CXnNodePluginIf* aChild )
       
   100     {
       
   101     iNode->AddChildL( &( aChild->Node() ) );
       
   102     }
       
   103 
       
   104 // -----------------------------------------------------------------------------
       
   105 // CXnNodePluginIf::Children
       
   106 // -----------------------------------------------------------------------------
       
   107 //
       
   108 EXPORT_C RPointerArray< CXnNodePluginIf > CXnNodePluginIf::ChildrenL()
       
   109     {
       
   110     RPointerArray< CXnNode >& nodes = iNode->Children();
       
   111     RPointerArray< CXnNodePluginIf > pluginNodes;
       
   112     CleanupClosePushL( pluginNodes );
       
   113 
       
   114     TInt count = nodes.Count();
       
   115     for ( TInt i = 0; i < count; ++i )
       
   116         {
       
   117         pluginNodes.AppendL( &nodes[i]->PluginIfL() );
       
   118         }
       
   119     CleanupStack::Pop( &pluginNodes );
       
   120     // Compiler will generate bitwise copy ctor, thus
       
   121     // caller of this function must call reset or close for copied RPointerArrays,
       
   122     // which is very nasty thing to do...
       
   123     return pluginNodes;
       
   124     }
       
   125 
       
   126 // -----------------------------------------------------------------------------
       
   127 // CXnNodePluginIf::SetPCDataL
       
   128 // -----------------------------------------------------------------------------
       
   129 //
       
   130 EXPORT_C void CXnNodePluginIf::SetPCDataL( const TDesC8& aData )
       
   131     {
       
   132     iNode->SetPCDataL( aData );
       
   133     }
       
   134 
       
   135 // -----------------------------------------------------------------------------
       
   136 // CXnNodePluginIf::GetPCData
       
   137 // -----------------------------------------------------------------------------
       
   138 //
       
   139 EXPORT_C const TDesC8& CXnNodePluginIf::GetPCData() const
       
   140     {
       
   141     return iNode->GetPCData();
       
   142     }
       
   143 
       
   144 // -----------------------------------------------------------------------------
       
   145 // CXnNodePluginIf::SetPropertyL
       
   146 // Set a property.
       
   147 // -----------------------------------------------------------------------------
       
   148 //
       
   149 EXPORT_C void CXnNodePluginIf::SetPropertyL( CXnProperty* aProperty )
       
   150     {
       
   151     iNode->SetPropertyL( aProperty );
       
   152     }
       
   153 
       
   154 // -----------------------------------------------------------------------------
       
   155 // CXnNodePluginIf::SetPropertyL
       
   156 // Set a property.
       
   157 // -----------------------------------------------------------------------------
       
   158 //
       
   159 EXPORT_C void CXnNodePluginIf::SetPropertyWithoutNotificationL( CXnProperty* aProperty )
       
   160     {
       
   161     iNode->SetPropertyWithoutNotificationL( aProperty );
       
   162     }
       
   163 
       
   164 // -----------------------------------------------------------------------------
       
   165 // CXnNodePluginIf::GetProperty
       
   166 // Gets a property.
       
   167 // -----------------------------------------------------------------------------
       
   168 //
       
   169 EXPORT_C CXnProperty* CXnNodePluginIf::GetPropertyL( CXnProperty& /*aProperty*/ ) const
       
   170     {
       
   171     return NULL; // iNode->GetPropertyL( aProperty );
       
   172     }
       
   173 
       
   174 // -----------------------------------------------------------------------------
       
   175 // CXnNodePluginIf::GetProperty
       
   176 // Gets a property.
       
   177 // -----------------------------------------------------------------------------
       
   178 //
       
   179 EXPORT_C CXnProperty* CXnNodePluginIf::GetPropertyL( const TDesC8& aKey ) const
       
   180     {
       
   181     return iNode->GetPropertyL( aKey );
       
   182     }
       
   183 
       
   184 // -----------------------------------------------------------------------------
       
   185 // CXnNodePluginIf::SetStateL
       
   186 // Set a state
       
   187 // -----------------------------------------------------------------------------
       
   188 //
       
   189 EXPORT_C void CXnNodePluginIf::SetStateL( const TDesC8& aState )
       
   190     {
       
   191     iNode->SetStateL( aState );
       
   192     }
       
   193 
       
   194 // -----------------------------------------------------------------------------
       
   195 // CXnNodePluginIf::UnsetState
       
   196 // Unset a pseudoclass
       
   197 // -----------------------------------------------------------------------------
       
   198 //
       
   199 EXPORT_C void CXnNodePluginIf::UnsetStateL( const TDesC8& aState )
       
   200     {
       
   201     iNode->UnsetStateL( aState );
       
   202     }
       
   203 
       
   204 // -----------------------------------------------------------------------------
       
   205 // CXnNodePluginIf::IsFocusedState
       
   206 // -----------------------------------------------------------------------------
       
   207 //
       
   208 EXPORT_C TBool CXnNodePluginIf::IsFocusedState()
       
   209     {
       
   210     return iNode->IsStateSet( _L8( "focus" ) );
       
   211     }
       
   212 
       
   213 // -----------------------------------------------------------------------------
       
   214 // CXnNodePluginIf::SetRect
       
   215 // -----------------------------------------------------------------------------
       
   216 //
       
   217 EXPORT_C void CXnNodePluginIf::SetRect( const TRect& aRect )
       
   218     {
       
   219     iNode->SetRect( aRect );
       
   220     }
       
   221 
       
   222 // -----------------------------------------------------------------------------
       
   223 // CXnNodePluginIf::Rect
       
   224 // -----------------------------------------------------------------------------
       
   225 //
       
   226 EXPORT_C TRect CXnNodePluginIf::Rect()
       
   227     {
       
   228     return iNode->Rect();
       
   229     }
       
   230 
       
   231 // -----------------------------------------------------------------------------
       
   232 // CXnNodePluginIf::SetBorderRect
       
   233 // -----------------------------------------------------------------------------
       
   234 //
       
   235 EXPORT_C void CXnNodePluginIf::SetBorderRect( const TRect& aRect )
       
   236     {
       
   237     iNode->SetBorderRect( aRect );
       
   238     }
       
   239 
       
   240 // -----------------------------------------------------------------------------
       
   241 // CXnNodePluginIf::BorderRect
       
   242 // -----------------------------------------------------------------------------
       
   243 //
       
   244 EXPORT_C TRect CXnNodePluginIf::BorderRect()
       
   245     {
       
   246     return iNode->BorderRect();
       
   247     }
       
   248 
       
   249 // -----------------------------------------------------------------------------
       
   250 // CXnNodePluginIf::SetMarginRect
       
   251 // -----------------------------------------------------------------------------
       
   252 //
       
   253 EXPORT_C void CXnNodePluginIf::SetMarginRect( const TRect& aRect )
       
   254     {
       
   255     iNode->SetMarginRect( aRect );
       
   256     }
       
   257 
       
   258 // -----------------------------------------------------------------------------
       
   259 // CXnNodePluginIf::MarginRect
       
   260 // -----------------------------------------------------------------------------
       
   261 //
       
   262 EXPORT_C TRect CXnNodePluginIf::MarginRect()
       
   263     {
       
   264     return iNode->MarginRect();
       
   265     }
       
   266 
       
   267 // -----------------------------------------------------------------------------
       
   268 // CXnNodePluginIf::SetPaddingRect
       
   269 // -----------------------------------------------------------------------------
       
   270 //
       
   271 EXPORT_C void CXnNodePluginIf::SetPaddingRect( const TRect& aRect )
       
   272     {
       
   273     iNode->SetPaddingRect( aRect );
       
   274     }
       
   275 
       
   276 // -----------------------------------------------------------------------------
       
   277 // CXnNodePluginIf::PaddingRect
       
   278 // -----------------------------------------------------------------------------
       
   279 //
       
   280 EXPORT_C TRect CXnNodePluginIf::PaddingRect()
       
   281     {
       
   282     return iNode->PaddingRect();
       
   283     }
       
   284 
       
   285 // -----------------------------------------------------------------------------
       
   286 // CXnNodePluginIf::UiEngine
       
   287 // -----------------------------------------------------------------------------
       
   288 //
       
   289 EXPORT_C TXnUiEnginePluginIf* CXnNodePluginIf::UiEngineL()
       
   290     {
       
   291     return &( iNode->UiEngine()->PluginIfL() );
       
   292     }
       
   293 
       
   294 // -----------------------------------------------------------------------------
       
   295 // CXnNodePluginIf::SetLayoutCapable
       
   296 // -----------------------------------------------------------------------------
       
   297 //
       
   298 EXPORT_C void CXnNodePluginIf::SetLayoutCapable( const TBool aLayoutCapable )
       
   299     {
       
   300     iNode->SetLayoutCapable( aLayoutCapable );
       
   301     }
       
   302 
       
   303 // -----------------------------------------------------------------------------
       
   304 // Get internal node
       
   305 // -----------------------------------------------------------------------------
       
   306 //
       
   307 CXnNode& CXnNodePluginIf::Node()
       
   308     {
       
   309     return *iNode;
       
   310     }
       
   311 
       
   312 // -----------------------------------------------------------------------------
       
   313 // Get app interface
       
   314 // -----------------------------------------------------------------------------
       
   315 //
       
   316 EXPORT_C CXnNodeAppIf& CXnNodePluginIf::AppIfL()
       
   317     {
       
   318     return iNode->AppIfL();
       
   319     }
       
   320 
       
   321 // -----------------------------------------------------------------------------
       
   322 // CXnNodePluginIf::MakeInterfaceL
       
   323 // Create a component interface according to the given type.
       
   324 // -----------------------------------------------------------------------------
       
   325 //
       
   326 EXPORT_C XnComponentInterface::MXnComponentInterface* CXnNodePluginIf::MakeInterfaceL(
       
   327     const TDesC8& aType )
       
   328     {
       
   329     return iNode->MakeInterfaceL( aType );
       
   330     }
       
   331 
       
   332 // -----------------------------------------------------------------------------
       
   333 // CXnNodePluginIf::DisplayL
       
   334 // -----------------------------------------------------------------------------
       
   335 //
       
   336 EXPORT_C CXnProperty* CXnNodePluginIf::DisplayL()
       
   337     {
       
   338     return iNode->DisplayL();
       
   339     }
       
   340 
       
   341 // -----------------------------------------------------------------------------
       
   342 // CXnNodePluginIf::VisibilityL
       
   343 // -----------------------------------------------------------------------------
       
   344 //
       
   345 EXPORT_C CXnProperty* CXnNodePluginIf::VisibilityL()
       
   346     {
       
   347     return iNode->VisibilityL();
       
   348     }
       
   349 
       
   350 // -----------------------------------------------------------------------------
       
   351 // CXnNodePluginIf::LabelL
       
   352 // -----------------------------------------------------------------------------
       
   353 //
       
   354 EXPORT_C CXnProperty* CXnNodePluginIf::LabelL()
       
   355     {
       
   356     return iNode->LabelL();
       
   357     }
       
   358 
       
   359 // -----------------------------------------------------------------------------
       
   360 // CXnNodePluginIf::IdL
       
   361 // -----------------------------------------------------------------------------
       
   362 //
       
   363 EXPORT_C CXnProperty* CXnNodePluginIf::IdL()
       
   364     {
       
   365     return iNode->IdL();
       
   366     }
       
   367 
       
   368 // -----------------------------------------------------------------------------
       
   369 // CXnNodePluginIf::VisibleRowsL
       
   370 // -----------------------------------------------------------------------------
       
   371 //
       
   372 EXPORT_C CXnProperty* CXnNodePluginIf::VisibleRowsL()
       
   373     {
       
   374     return iNode->VisibleRowsL();
       
   375     }
       
   376 
       
   377 // -----------------------------------------------------------------------------
       
   378 // CXnNodePluginIf::GridColumnsL
       
   379 // -----------------------------------------------------------------------------
       
   380 //
       
   381 EXPORT_C CXnProperty* CXnNodePluginIf::GridColumnsL()
       
   382     {
       
   383     return iNode->GridColumnsL();
       
   384     }
       
   385 
       
   386 // -----------------------------------------------------------------------------
       
   387 // CXnNodePluginIf::GridOrientationL
       
   388 // -----------------------------------------------------------------------------
       
   389 //
       
   390 EXPORT_C CXnProperty* CXnNodePluginIf::GridOrientationL()
       
   391     {
       
   392     return iNode->GridOrientationL();
       
   393     }
       
   394 
       
   395 // -----------------------------------------------------------------------------
       
   396 // CXnNodePluginIf::GridVerDirectionL
       
   397 // -----------------------------------------------------------------------------
       
   398 //
       
   399 EXPORT_C CXnProperty* CXnNodePluginIf::GridVerDirectionL()
       
   400     {
       
   401     return iNode->GridVerDirectionL();
       
   402     }
       
   403 
       
   404 // -----------------------------------------------------------------------------
       
   405 // CXnNodePluginIf::GridHorDirectionL
       
   406 // -----------------------------------------------------------------------------
       
   407 //
       
   408 EXPORT_C CXnProperty* CXnNodePluginIf::GridHorDirectionL()
       
   409     {
       
   410     return iNode->GridHorDirectionL();
       
   411     }
       
   412 
       
   413 // -----------------------------------------------------------------------------
       
   414 // CXnNodePluginIf::FocusHorLoopingL
       
   415 // -----------------------------------------------------------------------------
       
   416 //
       
   417 EXPORT_C CXnProperty* CXnNodePluginIf::FocusHorLoopingL()
       
   418     {
       
   419     return iNode->FocusHorLoopingL();
       
   420     }
       
   421 
       
   422 // -----------------------------------------------------------------------------
       
   423 // CXnNodePluginIf::FocusVerLoopingL
       
   424 // -----------------------------------------------------------------------------
       
   425 //
       
   426 EXPORT_C CXnProperty* CXnNodePluginIf::FocusVerLoopingL()
       
   427     {
       
   428     return iNode->FocusVerLoopingL();
       
   429     }
       
   430 
       
   431 // -----------------------------------------------------------------------------
       
   432 // CXnNodePluginIf::RefL
       
   433 // -----------------------------------------------------------------------------
       
   434 //
       
   435 EXPORT_C CXnProperty* CXnNodePluginIf::RefL()
       
   436     {
       
   437     return iNode->RefL();
       
   438     }
       
   439 
       
   440 // -----------------------------------------------------------------------------
       
   441 // CXnNodePluginIf::GridScrollBarWidthL
       
   442 // -----------------------------------------------------------------------------
       
   443 //
       
   444 EXPORT_C  CXnProperty* CXnNodePluginIf::GridScrollBarWidthL()
       
   445     {
       
   446     return iNode->GridScrollBarWidthL();
       
   447     }
       
   448 
       
   449 // -----------------------------------------------------------------------------
       
   450 // CXnNodePluginIf::GridScrollBarMarginL
       
   451 // -----------------------------------------------------------------------------
       
   452 //
       
   453 EXPORT_C  CXnProperty* CXnNodePluginIf::GridScrollBarMarginL()
       
   454     {
       
   455     return iNode->GridScrollBarMarginL();
       
   456     }
       
   457 
       
   458 // -----------------------------------------------------------------------------
       
   459 // CXnNodePluginIf::SetHandleTooltip
       
   460 // -----------------------------------------------------------------------------
       
   461 //
       
   462 EXPORT_C void CXnNodePluginIf::SetHandleTooltip( TBool aFlag )
       
   463     {
       
   464     iNode->SetHandleTooltip( aFlag );
       
   465     }
       
   466 
       
   467 // -----------------------------------------------------------------------------
       
   468 // -----------------------------------------------------------------------------
       
   469 //
       
   470 EXPORT_C void CXnNodePluginIf::ReportTriggerEventL(
       
   471     const TDesC8& aTriggerName,
       
   472     const TDesC8& aValueName,
       
   473     const TDesC8& aValue )
       
   474     {
       
   475     CXnNode* trigger = CXnNode::NewL();
       
   476     CleanupStack::PushL( trigger );
       
   477     CXnType* type = CXnType::NewL( XnPropertyNames::action::KTrigger );
       
   478     CleanupStack::PushL( type );
       
   479     CXnNodeImpl* impl = CXnNodeImpl::NewL( type );
       
   480     CleanupStack::Pop( type );
       
   481     trigger->SetImpl( impl );
       
   482     trigger->SetUiEngine( *iNode->UiEngine() );
       
   483 
       
   484     CXnDomPropertyValue* nameValue = CXnDomPropertyValue::NewL(
       
   485         iNode->UiEngine()->ODT()->DomDocument().StringPool() );
       
   486     CleanupStack::PushL( nameValue );
       
   487     nameValue->SetStringValueL( CXnDomPropertyValue::EString, aTriggerName );
       
   488 
       
   489     CXnProperty* name = CXnProperty::NewL(
       
   490         XnPropertyNames::action::trigger::KName,
       
   491         nameValue,
       
   492         iNode->UiEngine()->ODT()->DomDocument().StringPool() );
       
   493 
       
   494     CleanupStack::Pop( nameValue );
       
   495     CleanupStack::PushL( name );
       
   496     trigger->SetPropertyL( name );
       
   497     CleanupStack::Pop( name );
       
   498 
       
   499     CXnDomPropertyValue* indexValue = CXnDomPropertyValue::NewL(
       
   500         iNode->UiEngine()->ODT()->DomDocument().StringPool() );
       
   501     CleanupStack::PushL( indexValue );
       
   502     indexValue->SetStringValueL( CXnDomPropertyValue::EString, aValue );
       
   503 
       
   504     CXnProperty* index = CXnProperty::NewL(
       
   505         aValueName,
       
   506         indexValue,
       
   507         iNode->UiEngine()->ODT()->DomDocument().StringPool() );
       
   508 
       
   509     CleanupStack::Pop( indexValue );
       
   510     CleanupStack::PushL( index );
       
   511     trigger->SetPropertyL( index );
       
   512     CleanupStack::Pop( index );
       
   513 
       
   514     iNode->ReportXuikonEventL( *trigger, 0 );
       
   515 
       
   516     CleanupStack::PopAndDestroy( trigger );
       
   517     }
       
   518 
       
   519 // -----------------------------------------------------------------------------
       
   520 // CXnNodePluginIf::PathL
       
   521 // -----------------------------------------------------------------------------
       
   522 //
       
   523 EXPORT_C CXnProperty* CXnNodePluginIf::PathL()
       
   524     {
       
   525     return iNode->PathL();
       
   526     }
       
   527 
       
   528 // -----------------------------------------------------------------------------
       
   529 // CXnNodePluginIf::MaskPathL
       
   530 // -----------------------------------------------------------------------------
       
   531 //
       
   532 EXPORT_C CXnProperty* CXnNodePluginIf::MaskPathL()
       
   533     {
       
   534     return iNode->MaskPathL();
       
   535     }
       
   536 
       
   537 // -----------------------------------------------------------------------------
       
   538 // CXnNodePluginIf::SetDirtyL
       
   539 // -----------------------------------------------------------------------------
       
   540 //
       
   541 EXPORT_C void CXnNodePluginIf::SetDirtyL()
       
   542     {
       
   543     const TDesC8& type( iNode->Type()->Type() );
       
   544 
       
   545     if ( iNode->IsAdaptive( ETrue ) ||
       
   546          type == _L8( "grid" ) ||
       
   547          type == _L8( "list" ) )
       
   548         {
       
   549         iNode->SetDirtyL( XnDirtyLevel::ELayoutAndRender );
       
   550         }
       
   551     else
       
   552         {
       
   553         iNode->SetDirtyL( XnDirtyLevel::ERender );
       
   554         }
       
   555 
       
   556     // If node's parent is tooltip, it must be relayouted because it will
       
   557     // grow based on childs
       
   558     CXnNode* parent( iNode->Parent() );
       
   559 
       
   560     if ( parent && parent->Type()->Type() == _L8( "tooltip" ) )
       
   561         {
       
   562         parent->SetDirtyL( XnDirtyLevel::ELayoutAndRender );
       
   563         }
       
   564     }
       
   565 
       
   566 // -----------------------------------------------------------------------------
       
   567 // CXnNodePluginIf::Namespace
       
   568 // -----------------------------------------------------------------------------
       
   569 //
       
   570 EXPORT_C const TDesC8& CXnNodePluginIf::Namespace()
       
   571     {
       
   572     return iNode->Namespace();
       
   573     }
       
   574 
       
   575 // -----------------------------------------------------------------------------
       
   576 // CXnNodePluginIf::ControlL
       
   577 // Gets the control associated to this node
       
   578 // -----------------------------------------------------------------------------
       
   579 //
       
   580 EXPORT_C CXnControlAdapter* CXnNodePluginIf::Control() const
       
   581     {
       
   582     return iNode->Control();
       
   583     }