idlehomescreen/inc/xnuiengine.h
changeset 0 f72a12da539e
child 9 f966699dea19
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:
       
    15 * Xuikon UI engine.
       
    16 *
       
    17 */
       
    18 
       
    19 #ifndef XNUIENGINE_H
       
    20 #define XNUIENGINE_H
       
    21 
       
    22 // System includes
       
    23 #include <e32base.h>
       
    24 #include <w32std.h>
       
    25 
       
    26 // Forward declarations
       
    27 class CXnAppUiAdapter;
       
    28 class CXnViewManager;
       
    29 class CXnUiEngineImpl;
       
    30 class TXnUiEngineAppIf;
       
    31 class TXnUiEnginePluginIf;
       
    32 class CCoeControl;
       
    33 class CXnProperty;
       
    34 class CXnNode;
       
    35 class CXnResource;
       
    36 class CXnODT;
       
    37 class CXnPointerArray;
       
    38 class CXnEditor;
       
    39 class CXnEditMode;
       
    40 class CXnHitTest;
       
    41 class CXnKeyEventDispatcher;
       
    42 
       
    43 // Class declaration
       
    44 /**
       
    45  * Xuikon UI engine.
       
    46  *
       
    47  * @ingroup group_xnlayoutengine
       
    48  * @lib xnlayoutengine.lib
       
    49  * @since Series 60 3.1
       
    50  */
       
    51 NONSHARABLE_CLASS( CXnUiEngine ) : public CBase
       
    52     {
       
    53 public:
       
    54 
       
    55     /**
       
    56      * Two-phased constructor.
       
    57      */
       
    58     static CXnUiEngine* NewL( CXnAppUiAdapter& aAdapter );
       
    59 
       
    60     /**
       
    61      * Destructor.
       
    62      */
       
    63     virtual ~CXnUiEngine();
       
    64 
       
    65 public:
       
    66     // New functions
       
    67 
       
    68     /**
       
    69      * Gets AppUi
       
    70      *
       
    71      * @since S60 5.0     
       
    72      * @return AppUi
       
    73      */    
       
    74     CXnAppUiAdapter& AppUiAdapter() const;
       
    75     
       
    76     /**
       
    77      * Calculates the layout of the UI and renders it.
       
    78      *
       
    79      * @since Series 60 3.1
       
    80      * @param aNode Starting point for the layout
       
    81      * @exception KXnErrLoadLayoutFileFailed Loading the layout file failed.
       
    82      */
       
    83     void RenderUIL( CXnNode* aNode = NULL );
       
    84 
       
    85     /**
       
    86      * Calculates the layout of the UI.
       
    87      *
       
    88      * @since Series 60 3.1
       
    89      * @param aNode Starting point for the layout
       
    90      */
       
    91     void LayoutUIL( CXnNode* aNode = NULL );
       
    92 
       
    93     /**
       
    94      * Gets the root node of the UI. Ownership is not transferred.
       
    95      *
       
    96      * @since Series 60 3.1
       
    97      * @return Node
       
    98      */
       
    99     CXnNode* RootNode();
       
   100 
       
   101     /**
       
   102      * Find a node by its id. Ownership is not transferred.
       
   103      *
       
   104      * @since Series 60 3.1
       
   105      * @param aAreaId Area id
       
   106      * @param aNamespace Namespace
       
   107      * @return Node with the given id
       
   108      */
       
   109     CXnNode* FindNodeByIdL(
       
   110         const TDesC& aAreaId,
       
   111         const TDesC& aNamespace = KNullDesC );
       
   112 
       
   113     /**
       
   114      * 8-bit version of Find a node by its id. Ownership is not transferred.
       
   115      *
       
   116      * @since Series 60 3.1
       
   117      * @param aAreaId Area id
       
   118      * @param aNamespace Namespace
       
   119      * @return Node with the given id
       
   120      */
       
   121     CXnNode* FindNodeByIdL(
       
   122         const TDesC8& aAreaId,
       
   123         const TDesC8& aNamespace = KNullDesC8 );
       
   124 
       
   125     /**
       
   126      * Find nodes by class. Ownership is not transferred.
       
   127      *
       
   128      * @since Series 60 3.1
       
   129      * @param aClassId Class id
       
   130      * @return Nodes belonging to the class
       
   131      */
       
   132     CXnPointerArray* FindNodeByClassL(
       
   133         const TDesC& aClassId,
       
   134         const TDesC& aNamespace = KNullDesC );
       
   135 
       
   136     /**
       
   137      * Find nodes by class. Ownership is not transferred.
       
   138      *
       
   139      * @since Series 60 3.1
       
   140      * @param aClassId Class id
       
   141      * @return Nodes belonging to the class
       
   142      */
       
   143     CXnPointerArray* FindNodeByClassL(
       
   144         const TDesC8& aClassId,
       
   145         const TDesC8& aNamespace = KNullDesC8 );
       
   146 
       
   147     /**
       
   148      * Find resources (images etc.) of the UI. Ownership is not transferred.
       
   149      *
       
   150      * @since Series 60 3.1
       
   151      * @return Resources of the UI
       
   152      */
       
   153     CArrayPtrSeg< CXnResource >& Resources();
       
   154 
       
   155     /**
       
   156      * Set currently focused node
       
   157      *
       
   158      * @since Series 60 3.1
       
   159      * @param aFocusedNode Focused node
       
   160      * @param aSource A source of event that triggered focus change.
       
   161      */
       
   162     void SetFocusedNodeL( CXnNode* aFocusedNode, TInt aSource = 0 );
       
   163 
       
   164     /**
       
   165      * Get currently focused node
       
   166      *
       
   167      * @since Series 60 3.2
       
   168      * @return Focused node.
       
   169      */
       
   170     CXnNode* FocusedNode();
       
   171 
       
   172     /**
       
   173      * Checks if the UI is in Edit mode.
       
   174      *
       
   175      * @since Series 60 5.0
       
   176      * @return ETrue if the current mode is edit, otherwise EFalse.
       
   177      */
       
   178     TBool IsEditMode();
       
   179 
       
   180     /**
       
   181      * Get the raw ODT
       
   182      *
       
   183      * @since Series 60 3.1
       
   184      * @return ODT
       
   185      */
       
   186     CXnODT* ODT();
       
   187 
       
   188     /**
       
   189      * Get a numeric value of a property in vertical pixels
       
   190      *
       
   191      * @since Series 60 3.1
       
   192      * @param aValue Property
       
   193      * @param aReferenceValue Value used for percentage calculation
       
   194      * @return Value in vertical pixels
       
   195      */
       
   196     TInt VerticalPixelValueL( CXnProperty* aValue, TInt aReferenceValue );
       
   197 
       
   198     /**
       
   199      * Get a numeric value of a property in horizontal pixels
       
   200      *
       
   201      * @since Series 60 3.1
       
   202      * @param aValue Property
       
   203      * @param aReferenceValue Value used for percentage calculation
       
   204      * @return Value in horizontal pixels
       
   205      */
       
   206     TInt HorizontalPixelValueL( CXnProperty* aValue, TInt aReferenceValue );
       
   207 
       
   208     /**
       
   209      * Get a numeric value of a property in vertical twips
       
   210      *
       
   211      * @since Series 60 3.1
       
   212      * @param aValue Property
       
   213      * @param aReferenceValue Value used for percentage calculation
       
   214      * @return Value in vertical twips
       
   215      */
       
   216     TInt VerticalTwipValueL( CXnProperty* aValue, TInt aReferenceValue );
       
   217 
       
   218     /**
       
   219      * Get a numeric value of a property in horizontal twips
       
   220      *
       
   221      * @since Series 60 3.1
       
   222      * @param aValue Property
       
   223      * @param aReferenceValue Value used for percentage calculation
       
   224      * @return Value in horizontal pixels
       
   225      */
       
   226     TInt HorizontalTwipValueL( CXnProperty* aValue, TInt aReferenceValue );
       
   227 
       
   228     /**
       
   229      * Refresh current menu
       
   230      *
       
   231      * @since Series 60 3.1
       
   232      */
       
   233     void RefreshMenuL();
       
   234 
       
   235     /**
       
   236      * Activate a view
       
   237      *
       
   238      * @since Series 60 3.1
       
   239      * @param aViewNode View node
       
   240      */
       
   241     void ActivateViewL( CXnNode& aViewNode );
       
   242 
       
   243     /**
       
   244      * Returns view manager
       
   245      *
       
   246      * @since S60 5.0
       
   247      * @return view manager
       
   248      */
       
   249     CXnViewManager* ViewManager();
       
   250 
       
   251     /**
       
   252      * Return the active view
       
   253      *
       
   254      * @since Series 60 3.1
       
   255      * @return The active view node
       
   256      */
       
   257     CXnNode* ActiveView();
       
   258 
       
   259     /**
       
   260      * Add a dirty node.
       
   261      *
       
   262      * LayoutUiL and RenderUiL will only perform operations on the set of dirty
       
   263      * nodes.
       
   264      *
       
   265      * @since Series 60 3.1
       
   266      * @param aNode Dirty node.
       
   267      */
       
   268     void AddDirtyNodeL( CXnNode* aNode, TInt aLevel );
       
   269 
       
   270     /**
       
   271      * Get application interface.
       
   272      *
       
   273      * @since Series 60 3.1
       
   274      * @return application interface
       
   275      */
       
   276     TXnUiEngineAppIf& AppIfL();
       
   277 
       
   278     /**
       
   279      * Get plugin interface.
       
   280      *
       
   281      * @since Series 60 3.1
       
   282      * @return plugin interface
       
   283      */
       
   284     TXnUiEnginePluginIf& PluginIfL();
       
   285 
       
   286     /**
       
   287      * Get the size of the current screen device
       
   288      *
       
   289      * @since Series 60 3.1
       
   290      * @return Size of the current screen device
       
   291      */
       
   292     TSize ScreenDeviceSize() const;
       
   293 
       
   294     /**
       
   295      * Checks whether the dialog is displaying.
       
   296      *
       
   297      * @since Series 60 3.1
       
   298      * @return ETrue if dialog is displaying.
       
   299      */
       
   300     TBool IsDialogDisplaying();
       
   301 
       
   302     /**
       
   303      * Checks whether the menu is displaying.
       
   304      *
       
   305      * @since Series 60 3.1
       
   306      * @return ETrue if menu is displaying.
       
   307      */
       
   308     TBool IsMenuDisplaying();
       
   309        
       
   310     /**
       
   311      * Returns menubar node.
       
   312      *
       
   313      * @since Series 60 3.2
       
   314      */
       
   315     CXnNode* MenuBarNode() const;
       
   316 
       
   317     /**
       
   318      * Returns stylus popup node.
       
   319      *
       
   320      * @since S60 5.0
       
   321      */    
       
   322     CXnNode* StylusPopupNode() const;
       
   323     
       
   324     /**
       
   325      * Set node as passive, and add it to the passive focused node array.
       
   326      *
       
   327      * @since Series 60 3.2
       
   328      * @param aNode Node to use.
       
   329      */
       
   330     void AddPassiveFocusedNodeL( CXnNode* aNode );
       
   331 
       
   332     /**
       
   333      * Unset the passive focus from the node, and remove it from the passive
       
   334      * focused node array.
       
   335      * @since Series 60 3.2
       
   336      * @param aNode Node to use.
       
   337      */
       
   338     void RemovePassiveFocusedNodeL( CXnNode* aNode );
       
   339 
       
   340     /**
       
   341      * Clear the passive focused node array, and unset the passive focus states.
       
   342      *
       
   343      * @since Series 60 3.2
       
   344      */
       
   345     void ClearPassiveFocusedNodesL();
       
   346 
       
   347     /**
       
   348      * Sets the main pane rect
       
   349      *
       
   350      * @since Series 60 5.0
       
   351      */
       
   352     void SetClientRectL( TRect aRect, TBool aDrawNow = ETrue );
       
   353 
       
   354     /**
       
   355      * Gets the main pane rect
       
   356      *
       
   357      * @since Series 60 5.0
       
   358      */
       
   359     TRect ClientRect() const;
       
   360 
       
   361     /**
       
   362      * Sets nodes dropped state
       
   363      *
       
   364      * @since S60 3.2
       
   365      */
       
   366     void SetNodeDroppedL( CXnNode& aNode, TInt aDropped ) const;
       
   367 
       
   368     /**
       
   369      * Checks if node is adaptive, but doesn't have any content
       
   370      *
       
   371      * @since Series 60 3.2
       
   372      */
       
   373     void CheckAdaptiveContentL(
       
   374         CXnNode& aNode,
       
   375         TSize aAvailableSize = TSize::EUninitialized ) const;
       
   376 
       
   377     /**
       
   378      * Adds a node which can be focused.
       
   379      *
       
   380      * @since Series 60 3.2
       
   381      */
       
   382     void AddFocusCandidateL( CXnNode *aNode );
       
   383 
       
   384     /**
       
   385      * Fetch editor to operate on AI3 widgets.
       
   386      *
       
   387      * @since Series 60 5.0
       
   388      * @return Pointer to Editor
       
   389      */
       
   390     CXnEditor* Editor()const;
       
   391 
       
   392     /**
       
   393      * Gets pointer to edit mode storage.
       
   394      *
       
   395      * @since Series 60 5.0
       
   396      */
       
   397     CXnEditMode* EditMode();
       
   398 
       
   399     /**
       
   400      * Gets the array that contains plugin nodes for current view.
       
   401      *
       
   402      * @since Series 60 5.0
       
   403      */
       
   404     RPointerArray< CXnNode >* Plugins();
       
   405 
       
   406     /**
       
   407      * Gets hit test
       
   408      *
       
   409      * @since S60 5.1
       
   410      * @return the hittest
       
   411      */
       
   412     CXnHitTest& HitTest() const;
       
   413 
       
   414     /**
       
   415      * Positions stylus popup according given position
       
   416      *
       
   417      * @since S60 5.1
       
   418      * @param aNode stylus popup node
       
   419      * @param aReference a reference node where popup should fit
       
   420      * @param aPosition stylus popup position to set.
       
   421      */
       
   422     void PositionStylusPopupL(
       
   423         CXnNode& aNode,
       
   424         CXnNode& aReference,
       
   425         const TPoint& aPosition );
       
   426 
       
   427     /**
       
   428      * Gets theme resource file
       
   429      *
       
   430      * @since S60 5.1
       
   431      * @param aPath path from which file is found
       
   432      * @param aFile file to which resource is set
       
   433      * @return errorcode
       
   434      */
       
   435     TInt GetThemeResource( const TDesC& aPath, RFile& aFile );
       
   436 
       
   437     /**
       
   438      * Analyse added widget
       
   439      *
       
   440      * @since S60 5.1
       
   441      */
       
   442     TBool AnalyseAddedWidgetL( CXnNode& aNode );                
       
   443 
       
   444     /**
       
   445      * Disables layoyt and redraw, places cleanup item to cleanup stack
       
   446      * for enabling layot and redraw
       
   447      * 
       
   448      * @since Series 60 5.0     
       
   449      */                    
       
   450     void DisableRenderUiLC();
       
   451 
       
   452     /**
       
   453      * Set event dispatcher
       
   454      * 
       
   455      * @since Series 60 5.0
       
   456      * @param aDispather Event dispatcher     
       
   457      */                    
       
   458     void SetEventDispatcher( CXnKeyEventDispatcher* aDispatcher );
       
   459     
       
   460 private:
       
   461     /**
       
   462      * C++ default constructor.
       
   463      */
       
   464     CXnUiEngine();
       
   465 
       
   466     /**
       
   467      * 2nd phase constructor.
       
   468      */
       
   469     void ConstructL( CXnAppUiAdapter& aAdapter );
       
   470 
       
   471 private:
       
   472     // Data
       
   473 
       
   474     /**
       
   475      * The layout calculation and ui rendering implementation.
       
   476      * Own.
       
   477      */
       
   478     CXnUiEngineImpl* iUiEngineImpl;
       
   479 
       
   480     /**
       
   481      * Application proxy.
       
   482      * Own.
       
   483      */
       
   484     TXnUiEngineAppIf* iAppIf;
       
   485 
       
   486     /**
       
   487      * Plugin proxy.
       
   488      * Own.
       
   489      */
       
   490     TXnUiEnginePluginIf* iPluginIf;
       
   491     };
       
   492 
       
   493 #endif