idlehomescreen/xmluirendering/uiengine/src/xnuienginepluginif.cpp
branchRCL_3
changeset 34 5456b4e8b3a8
child 35 3321d3e205b6
equal deleted inserted replaced
33:5f0182e07bfb 34:5456b4e8b3a8
       
     1 /*
       
     2 * Copyright (c) 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:  Xuikon layout engine plugin interface
       
    15 *
       
    16 */
       
    17 
       
    18 // User includes
       
    19 #include "xnuienginepluginif.h"
       
    20 #include "xnuiengine.h"
       
    21 #include "xnnode.h"
       
    22 #include "xnnodepluginif.h"
       
    23 #include "xnproperty.h"
       
    24 #include "xnpointerarray.h"
       
    25 #include "xnodt.h"
       
    26 #include "xndomdocument.h"
       
    27 #include "xneditmode.h"
       
    28 #include "xneditor.h"
       
    29 #include "xnviewdata.h"
       
    30 #include "xndomnode.h"
       
    31 #include "xnpanic.h"
       
    32 
       
    33 // ============================ MEMBER FUNCTIONS ===============================
       
    34 
       
    35 // -----------------------------------------------------------------------------
       
    36 // TXnUiEnginePluginIf::TXnUiEnginePluginIf
       
    37 // C++ default constructor can NOT contain any code, that
       
    38 // might leave.
       
    39 // -----------------------------------------------------------------------------
       
    40 //
       
    41 TXnUiEnginePluginIf::TXnUiEnginePluginIf( CXnUiEngine& aUiEngine )
       
    42     {
       
    43     iUiEngine = &aUiEngine;
       
    44     }
       
    45 
       
    46 // -----------------------------------------------------------------------------
       
    47 // TXnUiEnginePluginIf::RootNode
       
    48 // Forwards the call to the ui engine implementation
       
    49 // -----------------------------------------------------------------------------
       
    50 //
       
    51 EXPORT_C CXnNodePluginIf& TXnUiEnginePluginIf::RootNodeL()
       
    52     {
       
    53     CXnNode* node = iUiEngine->RootNode();
       
    54     return node->PluginIfL();
       
    55     }
       
    56 
       
    57 // -----------------------------------------------------------------------------
       
    58 // TXnUiEnginePluginIf::FindNodeByIdL
       
    59 // Forwards the call to the ui engine implementation
       
    60 // -----------------------------------------------------------------------------
       
    61 //
       
    62 EXPORT_C CXnNodePluginIf* TXnUiEnginePluginIf::FindNodeByIdL(
       
    63     const TDesC& aNodeId,
       
    64     const TDesC& aNamespace )
       
    65     {
       
    66     CXnNode* node = iUiEngine->FindNodeByIdL( aNodeId, aNamespace );
       
    67     if ( !node )
       
    68         {
       
    69         return NULL;
       
    70         }
       
    71     return &( node->PluginIfL() );
       
    72     }
       
    73 
       
    74 // -----------------------------------------------------------------------------
       
    75 // TXnUiEnginePluginIf::FindNodeByIdL
       
    76 // Forwards the call to the ui engine implementation
       
    77 // -----------------------------------------------------------------------------
       
    78 //
       
    79 EXPORT_C CXnNodePluginIf* TXnUiEnginePluginIf::FindNodeByIdL(
       
    80     const TDesC8& aNodeId,
       
    81     const TDesC8& aNamespace )
       
    82     {
       
    83     CXnNode* node = iUiEngine->FindNodeByIdL( aNodeId, aNamespace );
       
    84     if ( !node )
       
    85         {
       
    86         return NULL;
       
    87         }
       
    88     return &( node->PluginIfL() );
       
    89     }
       
    90 
       
    91 // -----------------------------------------------------------------------------
       
    92 // TXnUiEnginePluginIf::FindNodeByClassL
       
    93 // Forwards the call to the ui engine implementation
       
    94 // -----------------------------------------------------------------------------
       
    95 //
       
    96 EXPORT_C RPointerArray< CXnNodePluginIf > TXnUiEnginePluginIf::FindNodeByClassL(
       
    97     const TDesC& aClassId )
       
    98     {
       
    99     CXnPointerArray* array = iUiEngine->FindNodeByClassL( aClassId );
       
   100     CleanupStack::PushL( array );
       
   101     RPointerArray< CXnNodePluginIf > interfaceArray;
       
   102     // Push interfaceArray.Close() on cleanup stack to free the array buffer in
       
   103     // case of a leave
       
   104     CleanupClosePushL( interfaceArray );
       
   105     const TInt count = array->Container().Count();
       
   106     // Reserve the needed array buffer in one allocation to increase
       
   107     // excution speed and decrease heap fragmentation
       
   108     interfaceArray.ReserveL( count );
       
   109     for ( TInt i = 0; i < count; ++i )
       
   110         {
       
   111         CXnNode* node = static_cast< CXnNode* >( array->Container()[i] );
       
   112         // Append cannot fail because ReserveL call before this loop has
       
   113         // allocated the array buffer
       
   114         interfaceArray.Append( &( node->PluginIfL() ) );
       
   115         }
       
   116     CleanupStack::Pop( &interfaceArray );
       
   117     CleanupStack::PopAndDestroy( array );
       
   118     return interfaceArray;
       
   119     }
       
   120 
       
   121 // -----------------------------------------------------------------------------
       
   122 // TXnUiEnginePluginIf::RenderUIL
       
   123 // Forwards the call to the ui engine implementation
       
   124 // -----------------------------------------------------------------------------
       
   125 //
       
   126 EXPORT_C void TXnUiEnginePluginIf::RenderUIL( CXnNodePluginIf* aNode )
       
   127     {
       
   128     CXnNode* node = NULL;
       
   129     if ( aNode )
       
   130         {
       
   131         node = &( aNode->Node() );
       
   132         }
       
   133     iUiEngine->RenderUIL( node );
       
   134     }
       
   135 
       
   136 // -----------------------------------------------------------------------------
       
   137 // TXnUiEnginePluginIf::Resources
       
   138 // Forwards the call to the ui engine implementation
       
   139 // -----------------------------------------------------------------------------
       
   140 //
       
   141 EXPORT_C CArrayPtrSeg< CXnResource >& TXnUiEnginePluginIf::Resources()
       
   142     {
       
   143     return iUiEngine->Resources();
       
   144     }
       
   145 
       
   146 // -----------------------------------------------------------------------------
       
   147 // TXnUiEnginePluginIf::FocusedNode
       
   148 // Forwards the call to the ui engine implementation
       
   149 // -----------------------------------------------------------------------------
       
   150 //
       
   151 EXPORT_C CXnNodePluginIf* TXnUiEnginePluginIf::FocusedNodeL()
       
   152     {
       
   153     CXnNodePluginIf* ret = NULL;
       
   154     if ( iUiEngine->FocusedNode() )
       
   155         {
       
   156         ret = &( iUiEngine->FocusedNode()->PluginIfL() );
       
   157         }
       
   158     return ret;
       
   159     }
       
   160 
       
   161 // -----------------------------------------------------------------------------
       
   162 // TXnUiEnginePluginIf::SetFocusedNode
       
   163 // Forwards the call to the ui engine implementation
       
   164 // -----------------------------------------------------------------------------
       
   165 //
       
   166 EXPORT_C void TXnUiEnginePluginIf::SetFocusedNode(
       
   167     CXnNodePluginIf* aFocusedNode )
       
   168     {
       
   169     CXnNode* node( NULL );
       
   170 
       
   171     if ( aFocusedNode )
       
   172         {
       
   173         node = &( aFocusedNode->Node() );
       
   174         }
       
   175 
       
   176     TRAP_IGNORE
       
   177         (               
       
   178         node->SetStateWithoutNotificationL(
       
   179             XnPropertyNames::style::common::KFocus );        
       
   180         );
       
   181     }
       
   182 
       
   183 // -----------------------------------------------------------------------------
       
   184 // TXnUiEnginePluginIf::StringPool
       
   185 // Forwards the call to the ui engine implementation
       
   186 // -----------------------------------------------------------------------------
       
   187 //
       
   188 EXPORT_C CXnDomStringPool& TXnUiEnginePluginIf::StringPool()
       
   189     {
       
   190     return *iUiEngine->ODT()->DomDocument().StringPool();
       
   191     }
       
   192 
       
   193 // -----------------------------------------------------------------------------
       
   194 // TXnUiEnginePluginIf::VerticalPixelValueL
       
   195 // Forwards the call to the ui engine implementation
       
   196 // -----------------------------------------------------------------------------
       
   197 //
       
   198 EXPORT_C TInt TXnUiEnginePluginIf::VerticalPixelValueL(
       
   199     CXnProperty* aValue, TInt aReferenceValue )
       
   200     {
       
   201     return iUiEngine->VerticalPixelValueL( aValue, aReferenceValue );
       
   202     }
       
   203 
       
   204 // -----------------------------------------------------------------------------
       
   205 // TXnUiEnginePluginIf::HorizontalPixelValueL
       
   206 // Forwards the call to the ui engine implementation
       
   207 // -----------------------------------------------------------------------------
       
   208 //
       
   209 EXPORT_C TInt TXnUiEnginePluginIf::HorizontalPixelValueL(
       
   210     CXnProperty* aValue, TInt aReferenceValue )
       
   211     {
       
   212     return iUiEngine->HorizontalPixelValueL( aValue, aReferenceValue );
       
   213     }
       
   214 
       
   215 // -----------------------------------------------------------------------------
       
   216 // TXnUiEnginePluginIf::VerticalTwipValueL
       
   217 // Forwards the call to the ui engine implementation
       
   218 // -----------------------------------------------------------------------------
       
   219 //
       
   220 EXPORT_C TInt TXnUiEnginePluginIf::VerticalTwipValueL(
       
   221     CXnProperty* aValue, TInt aReferenceValue )
       
   222     {
       
   223     return iUiEngine->VerticalTwipValueL( aValue, aReferenceValue );
       
   224     }
       
   225 
       
   226 // -----------------------------------------------------------------------------
       
   227 // TXnUiEnginePluginIf::HorizontalTwipValueL
       
   228 // Forwards the call to the ui engine implementation
       
   229 // -----------------------------------------------------------------------------
       
   230 //
       
   231 EXPORT_C TInt TXnUiEnginePluginIf::HorizontalTwipValueL(
       
   232     CXnProperty* aValue, TInt aReferenceValue )
       
   233     {
       
   234     return iUiEngine->HorizontalTwipValueL( aValue, aReferenceValue );
       
   235     }
       
   236 
       
   237 // -----------------------------------------------------------------------------
       
   238 // TXnUiEnginePluginIf::ScreenDeviceSize
       
   239 // Get the size of the current screen device
       
   240 // -----------------------------------------------------------------------------
       
   241 //
       
   242 EXPORT_C TSize TXnUiEnginePluginIf::ScreenDeviceSize()
       
   243     {
       
   244     return iUiEngine->ScreenDeviceSize();
       
   245     }
       
   246 
       
   247 // -----------------------------------------------------------------------------
       
   248 // TXnUiEnginePluginIf::IsDialogDisplaying
       
   249 // Checks whether the dialog is displaying or not.
       
   250 // -----------------------------------------------------------------------------
       
   251 //
       
   252 EXPORT_C TBool TXnUiEnginePluginIf::IsDialogDisplaying()
       
   253     {
       
   254     return iUiEngine->IsDialogDisplaying();
       
   255     }
       
   256 
       
   257 // -----------------------------------------------------------------------------
       
   258 // TXnUiEnginePluginIf::AddDirtyNodeL
       
   259 // Sets the given node dirty.
       
   260 // -----------------------------------------------------------------------------
       
   261 //
       
   262 EXPORT_C void TXnUiEnginePluginIf::AddDirtyNodeL( CXnNodePluginIf& aNode )
       
   263     {
       
   264     aNode.SetDirtyL();
       
   265     }
       
   266 
       
   267 // -----------------------------------------------------------------------------
       
   268 // TXnUiEnginePluginIf::IsMenuDisplaying
       
   269 // Checks whether the menu is displaying or not.
       
   270 // -----------------------------------------------------------------------------
       
   271 //
       
   272 EXPORT_C TBool TXnUiEnginePluginIf::IsMenuDisplaying()
       
   273     {
       
   274     return iUiEngine->IsMenuDisplaying();
       
   275     }
       
   276 
       
   277 // -----------------------------------------------------------------------------
       
   278 // TXnUiEnginePluginIf::LayoutUIL
       
   279 // Forwards the call to the ui engine implementation
       
   280 // -----------------------------------------------------------------------------
       
   281 //
       
   282 EXPORT_C void TXnUiEnginePluginIf::LayoutUIL( CXnNodePluginIf* aNode )
       
   283     {
       
   284     CXnNode* node = NULL;
       
   285     if ( aNode )
       
   286         {
       
   287         node = &( aNode->Node() );
       
   288         }
       
   289     iUiEngine->LayoutUIL( node );
       
   290     }
       
   291 
       
   292 // -----------------------------------------------------------------------------
       
   293 // TXnUiEnginePluginIf::EditState
       
   294 // Checks wheter editmode is active or not
       
   295 // -----------------------------------------------------------------------------
       
   296 //
       
   297 EXPORT_C TInt TXnUiEnginePluginIf::EditMode()
       
   298     {
       
   299     return iUiEngine->EditMode()->EditState();
       
   300     }
       
   301 
       
   302 // -----------------------------------------------------------------------------
       
   303 // TXnUiEnginePluginIf::WidgetsVisible
       
   304 // Checks widgets' visibility state
       
   305 // -----------------------------------------------------------------------------
       
   306 //
       
   307 EXPORT_C TBool TXnUiEnginePluginIf::WidgetsVisible() const
       
   308     {
       
   309     return iUiEngine->Editor()->WidgetsVisible();
       
   310     }
       
   311 
       
   312 // -----------------------------------------------------------------------------
       
   313 // TXnUiEnginePluginIf::PluginNodeL
       
   314 //
       
   315 // -----------------------------------------------------------------------------
       
   316 //
       
   317 EXPORT_C CXnNodePluginIf& TXnUiEnginePluginIf::PluginNodeL(
       
   318     CXnNodePluginIf* aNode )
       
   319     {
       
   320     CXnViewManager* manager( iUiEngine->ViewManager() );
       
   321     
       
   322     CXnNode* node( NULL );
       
   323     
       
   324     if ( manager )
       
   325         {
       
   326         CXnPluginData* pluginData( 
       
   327             manager->ActiveViewData().Plugin( &aNode->Node() ) );
       
   328         
       
   329         if ( pluginData )
       
   330             {
       
   331             CXnDomNode* domNode( pluginData->Owner() );
       
   332             
       
   333             if ( domNode )
       
   334                 {
       
   335                 node = domNode->LayoutNode();
       
   336                 }        
       
   337             }
       
   338         }
       
   339     
       
   340     if( !node )
       
   341         {
       
   342         User::Leave( KErrNotFound );
       
   343         }
       
   344      
       
   345     return node->PluginIfL();
       
   346     }
       
   347 
       
   348 // -----------------------------------------------------------------------------
       
   349 // TXnUiEnginePluginIf::DisableRenderUiLC
       
   350 // 
       
   351 // -----------------------------------------------------------------------------
       
   352 //               
       
   353 EXPORT_C void TXnUiEnginePluginIf::DisableRenderUiLC()
       
   354     {
       
   355     iUiEngine->DisableRenderUiLC();
       
   356     }
       
   357 
       
   358 // -----------------------------------------------------------------------------
       
   359 // TXnUiEnginePluginIf::EnablePartialTouchInput
       
   360 // 
       
   361 // -----------------------------------------------------------------------------
       
   362 //               
       
   363 EXPORT_C void TXnUiEnginePluginIf::EnablePartialTouchInput( 
       
   364     CXnNodePluginIf& aNode, TBool aEnable )
       
   365     {
       
   366     iUiEngine->EnablePartialTouchInput(aNode.Node(), aEnable);
       
   367     }
       
   368 
       
   369 // -----------------------------------------------------------------------------
       
   370 // TXnUiEnginePluginIf::IsTextEditorActive
       
   371 // 
       
   372 // -----------------------------------------------------------------------------
       
   373 //
       
   374 EXPORT_C TBool TXnUiEnginePluginIf::IsTextEditorActive()
       
   375     {
       
   376     return iUiEngine->IsTextEditorActive();
       
   377     }
       
   378 
       
   379 // End of file
       
   380