idlehomescreen/xmluirendering/uiengine/src/xnuiengineappif.cpp
branchRCL_3
changeset 83 5456b4e8b3a8
equal deleted inserted replaced
82:5f0182e07bfb 83:5456b4e8b3a8
       
     1 /*
       
     2 * Copyright (c) 2002-2005 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:  Layout calculation and UI rendering mechanism implementations.
       
    15 *
       
    16 */
       
    17 
       
    18 // User includes
       
    19 #include "xnuiengineappif.h"
       
    20 #include "xnuiengine.h"
       
    21 #include "xnnode.h"
       
    22 #include "xnodt.h"
       
    23 #include "xndomdocument.h"
       
    24 #include "xnpointerarray.h"
       
    25 #include "xneditor.h"
       
    26 #include "xnnodeappif.h"
       
    27 #include "xnviewdata.h"
       
    28 
       
    29 // ============================ MEMBER FUNCTIONS ===============================
       
    30 
       
    31 // -----------------------------------------------------------------------------
       
    32 // TXnUiEngineAppIf::TXnUiEngineAppIf
       
    33 // C++ default constructor can NOT contain any code, that
       
    34 // might leave.
       
    35 // -----------------------------------------------------------------------------
       
    36 //
       
    37 TXnUiEngineAppIf::TXnUiEngineAppIf( CXnUiEngine& aUiEngine )
       
    38     {
       
    39     iUiEngine = &aUiEngine;
       
    40     }
       
    41 
       
    42 // -----------------------------------------------------------------------------
       
    43 // TXnUiEngineAppIf::RootNode
       
    44 // Forwards the call to the ui engine implementation
       
    45 // -----------------------------------------------------------------------------
       
    46 //
       
    47 EXPORT_C CXnNodeAppIf& TXnUiEngineAppIf::RootNodeL()
       
    48     {
       
    49     return iUiEngine->RootNode()->AppIfL();
       
    50     }
       
    51 
       
    52 // -----------------------------------------------------------------------------
       
    53 // TXnUiEngineAppIf::FindNodeByIdL
       
    54 // Forwards the call to the ui engine implementation
       
    55 // -----------------------------------------------------------------------------
       
    56 //
       
    57 EXPORT_C CXnNodeAppIf* TXnUiEngineAppIf::FindNodeByIdL(
       
    58     const TDesC& aNodeId,
       
    59     const TDesC& aNamespace )
       
    60     {
       
    61     CXnNode* node( iUiEngine->FindNodeByIdL( aNodeId, aNamespace ) );
       
    62 
       
    63     if ( node )
       
    64         {
       
    65         return &( node->AppIfL() );
       
    66         }
       
    67 
       
    68     return NULL;
       
    69     }
       
    70 
       
    71 // -----------------------------------------------------------------------------
       
    72 // TXnUiEngineAppIf::FindNodeByIdL
       
    73 // Forwards the call to the ui engine implementation
       
    74 // -----------------------------------------------------------------------------
       
    75 //
       
    76 EXPORT_C CXnNodeAppIf* TXnUiEngineAppIf::FindNodeByIdL(
       
    77     const TDesC8& aNodeId,
       
    78     const TDesC8& aNamespace )
       
    79     {
       
    80     CXnNode* node( iUiEngine->FindNodeByIdL( aNodeId, aNamespace ) );
       
    81 
       
    82     if ( node )
       
    83         {
       
    84         return &( node->AppIfL() );
       
    85         }
       
    86 
       
    87     return NULL;
       
    88     }
       
    89 
       
    90 // -----------------------------------------------------------------------------
       
    91 // TXnUiEngineAppIf::FindNodeByClassL
       
    92 // Forwards the call to the ui engine implementation
       
    93 // -----------------------------------------------------------------------------
       
    94 //
       
    95 EXPORT_C RPointerArray< CXnNodeAppIf > TXnUiEngineAppIf::FindNodeByClassL(
       
    96     const TDesC& aClassId, const TDesC& aNamespace )
       
    97     {
       
    98     CXnPointerArray* array = iUiEngine->FindNodeByClassL(
       
    99         aClassId, aNamespace );
       
   100     CleanupStack::PushL( array );
       
   101     RPointerArray< CXnNodeAppIf > interfaceArray;
       
   102     CleanupClosePushL( interfaceArray );
       
   103     const TInt count = array->Container().Count();
       
   104     interfaceArray.ReserveL( count );
       
   105     for ( TInt i = 0; i < count; ++i )
       
   106         {
       
   107         CXnNode* node = static_cast< CXnNode* >( array->Container()[i] );
       
   108         // Append cannot fail because ReserveL call before this loop has
       
   109         // allocated the array buffer
       
   110         interfaceArray.Append( &( node->AppIfL() ) );
       
   111         }
       
   112     CleanupStack::Pop( &interfaceArray );
       
   113     CleanupStack::PopAndDestroy( array );
       
   114     return interfaceArray;
       
   115     }
       
   116 
       
   117 // -----------------------------------------------------------------------------
       
   118 // CXnUiEngine::FindNodeByClassL
       
   119 // Forwards the call to the ui engine implementation
       
   120 // -----------------------------------------------------------------------------
       
   121 //
       
   122 EXPORT_C RPointerArray< CXnNodeAppIf > TXnUiEngineAppIf::FindNodeByClassL(
       
   123     const TDesC8& aClassId, const TDesC8& aNamespace )
       
   124     {
       
   125     CXnPointerArray* array = iUiEngine->FindNodeByClassL(
       
   126         aClassId, aNamespace );
       
   127     CleanupStack::PushL( array );
       
   128     RPointerArray< CXnNodeAppIf > interfaceArray;
       
   129     CleanupClosePushL( interfaceArray );
       
   130     const TInt count = array->Container().Count();
       
   131     interfaceArray.ReserveL( count );
       
   132     for ( TInt i = 0; i < count; ++i )
       
   133         {
       
   134         CXnNode* node = static_cast< CXnNode* >( array->Container()[i] );
       
   135         // Append cannot fail because ReserveL call before this loop has
       
   136         // allocated the array buffer
       
   137         interfaceArray.Append( &( node->AppIfL() ) );
       
   138         }
       
   139     CleanupStack::Pop( &interfaceArray );
       
   140     CleanupStack::PopAndDestroy( array );
       
   141     return interfaceArray;
       
   142     }
       
   143 
       
   144 // -----------------------------------------------------------------------------
       
   145 // CXnUiEngine::FindContentSourceNodesL
       
   146 // Forwards the call to the ui engine implementation
       
   147 // -----------------------------------------------------------------------------
       
   148 //
       
   149 EXPORT_C RPointerArray< CXnNodeAppIf > TXnUiEngineAppIf::FindContentSourceNodesL(
       
   150     const TDesC8& aNamespace )
       
   151     {   
       
   152     CXnPointerArray* array = iUiEngine->FindContentSourceNodesL( aNamespace );
       
   153     CleanupStack::PushL( array );
       
   154     
       
   155     RPointerArray< CXnNodeAppIf > interfaceArray;
       
   156     CleanupClosePushL( interfaceArray );
       
   157     
       
   158     const TInt count = array->Container().Count();
       
   159     interfaceArray.ReserveL( count );
       
   160     
       
   161     for ( TInt i = 0; i < count; i++ )
       
   162         {
       
   163         CXnNode* node = static_cast< CXnNode* >( array->Container()[i] );
       
   164         // Append cannot fail because ReserveL call before this loop has
       
   165         // allocated the array buffer
       
   166         interfaceArray.Append( &( node->AppIfL() ) );    
       
   167         }
       
   168     
       
   169     CleanupStack::Pop( &interfaceArray );
       
   170     CleanupStack::PopAndDestroy( array );
       
   171     return interfaceArray;    
       
   172     }
       
   173 
       
   174 // -----------------------------------------------------------------------------
       
   175 // TXnUiEngineAppIf::RenderUIL
       
   176 // Forwards the call to the ui engine implementation
       
   177 // -----------------------------------------------------------------------------
       
   178 //
       
   179 EXPORT_C void TXnUiEngineAppIf::RenderUIL( CXnNodeAppIf* aNode )
       
   180     {
       
   181     CXnNode* node = NULL;
       
   182     if ( aNode != NULL )
       
   183         {
       
   184         node = &( aNode->Node() );
       
   185         }
       
   186     iUiEngine->RenderUIL( node );
       
   187     }
       
   188 
       
   189 // -----------------------------------------------------------------------------
       
   190 // TXnUiEngineAppIf::StringPool
       
   191 // Forwards the call to the ui engine implementation
       
   192 // -----------------------------------------------------------------------------
       
   193 //
       
   194 EXPORT_C CXnDomStringPool& TXnUiEngineAppIf::StringPool()
       
   195     {
       
   196     return *iUiEngine->ODT()->DomDocument().StringPool();
       
   197     }
       
   198 
       
   199 // -----------------------------------------------------------------------------
       
   200 // TXnUiEngineAppIf::ActiveView
       
   201 // Return the active view
       
   202 // -----------------------------------------------------------------------------
       
   203 //
       
   204 EXPORT_C CXnNodeAppIf* TXnUiEngineAppIf::ActiveView()
       
   205     {
       
   206     CXnNodeAppIf* ret( NULL );
       
   207     TRAP_IGNORE( ret = &( iUiEngine->ActiveView()->AppIfL() ) );
       
   208     return ret;
       
   209     }
       
   210 
       
   211 // -----------------------------------------------------------------------------
       
   212 // TXnUiEngineAppIf::RefreshMenuL
       
   213 // Refresh current menu
       
   214 // -----------------------------------------------------------------------------
       
   215 //
       
   216 EXPORT_C void TXnUiEngineAppIf::RefreshMenuL()
       
   217     {
       
   218     iUiEngine->RefreshMenuL();
       
   219     }
       
   220 
       
   221 // -----------------------------------------------------------------------------
       
   222 // TXnUiEngineAppIf::IsMenuDisplaying
       
   223 // Checks whether the menu is displaying or not.
       
   224 // -----------------------------------------------------------------------------
       
   225 //
       
   226 EXPORT_C TBool TXnUiEngineAppIf::IsMenuDisplaying()
       
   227     {
       
   228     return iUiEngine->IsMenuDisplaying();
       
   229     }
       
   230 
       
   231 // -----------------------------------------------------------------------------
       
   232 // -----------------------------------------------------------------------------
       
   233 //
       
   234 EXPORT_C TInt TXnUiEngineAppIf::GetPluginNodeArrayL(
       
   235     RPointerArray< CXnNodeAppIf >& aArray )
       
   236     {
       
   237     aArray.Reset();
       
   238     RPointerArray< CXnNode >* plugins = iUiEngine->Plugins();
       
   239     if ( !plugins )
       
   240         {
       
   241         return 0;
       
   242         }
       
   243     TInt count( plugins->Count() );
       
   244     for ( TInt i = 0; i < count; ++i )
       
   245         {
       
   246         CXnNode* tmp = ( *plugins )[i];
       
   247         aArray.AppendL( &( tmp->AppIfL() ) );
       
   248         }
       
   249     return count;
       
   250     }
       
   251 
       
   252 // -----------------------------------------------------------------------------
       
   253 // TXnUiEngineAppIf::FocusedNode
       
   254 // Gets the currently focused node
       
   255 // -----------------------------------------------------------------------------
       
   256 //
       
   257 EXPORT_C CXnNodeAppIf* TXnUiEngineAppIf::FocusedNode()
       
   258     {
       
   259     CXnNode* focused( iUiEngine->FocusedNode() );
       
   260     CXnNodeAppIf* ret( NULL );
       
   261 
       
   262     if ( focused )
       
   263         {
       
   264         TRAP_IGNORE( ret = &( focused->AppIfL() ) );
       
   265         }
       
   266 
       
   267     return ret;
       
   268     }
       
   269 
       
   270 // -----------------------------------------------------------------------------
       
   271 // TXnUiEngineAppIf::IsEditMode
       
   272 // Returns ETrue if the current mode is edit, otherwise EFalse.
       
   273 // -----------------------------------------------------------------------------
       
   274 //
       
   275 EXPORT_C TBool TXnUiEngineAppIf::IsEditMode()
       
   276     {
       
   277     return ( iUiEngine->IsEditMode() );
       
   278     }
       
   279 
       
   280 // -----------------------------------------------------------------------------
       
   281 // -----------------------------------------------------------------------------
       
   282 //
       
   283 EXPORT_C void TXnUiEngineAppIf::SetUiEngine( CXnUiEngine* aUiEngine )
       
   284     {
       
   285     iUiEngine = aUiEngine;
       
   286     }
       
   287 
       
   288 // -----------------------------------------------------------------------------
       
   289 // -----------------------------------------------------------------------------
       
   290 //
       
   291 EXPORT_C TInt TXnUiEngineAppIf::GetThemeResource(
       
   292     const TDesC& aPath, RFile& aFile )
       
   293     {
       
   294     return iUiEngine->GetThemeResource( aPath, aFile );
       
   295     }
       
   296 
       
   297 // -----------------------------------------------------------------------------
       
   298 // -----------------------------------------------------------------------------
       
   299 //
       
   300 EXPORT_C TBool TXnUiEngineAppIf::WidgetsVisible() const
       
   301     {
       
   302     return iUiEngine->Editor()->WidgetsVisible();
       
   303     }