uiacceltk/hitchcock/Client/src/alfvisualfactory.cpp
changeset 0 15bf7259bb7c
equal deleted inserted replaced
-1:000000000000 0:15bf7259bb7c
       
     1 /*
       
     2 * Copyright (c) 2006 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:   Factory for visuals and layouts.
       
    15 *
       
    16 */
       
    17 
       
    18 
       
    19 
       
    20 
       
    21 #include "alf/alfvisualfactory.h"  // Class definition
       
    22 #include "alf/alftextvisual.h"
       
    23 #include "alf/alflcttextvisual.h"
       
    24 #include "alf/alfanchorlayout.h"
       
    25 #include "alf/alfviewportlayout.h"
       
    26 #include "alf/alfdecklayout.h"
       
    27 #include "alf/alfflowlayout.h"
       
    28 #include "alf/alfimagevisual.h"
       
    29 #include "alf/alfgridlayout.h"
       
    30 #include "alf/alflctgridlayout.h"
       
    31 #include "alf/alfcurvepathlayout.h"
       
    32 #include "alf/alfconstants.h"
       
    33 #include "alf/alflinevisual.h"
       
    34 #include "alf/alflctanchorlayout.h"
       
    35 #include "alf/alfmeshvisual.h"
       
    36 #include "alf/alfcanvasvisual.h"
       
    37 #include "alfuids.h"
       
    38 #include "alf/alfcontrol.h"
       
    39 
       
    40 // ---------------------------------------------------------------------------
       
    41 // Creates new visual
       
    42 // ---------------------------------------------------------------------------
       
    43 //
       
    44 EXPORT_C CAlfVisual* AlfVisualFactory::NewVisualL(
       
    45         TAlfVisualType aVisualType,
       
    46 	    CAlfLayout* aParentLayout,
       
    47 	    CAlfControl& aOwner,
       
    48 	    CAlfEnv& aEnv,
       
    49 	    TInt aImplementationUid)
       
    50     {
       
    51     CAlfVisual* visual = NewVisualLC(aVisualType, aParentLayout, aOwner, aEnv, aImplementationUid);
       
    52     CleanupStack::Pop(visual);
       
    53     return visual;
       
    54     }
       
    55     
       
    56 // ---------------------------------------------------------------------------
       
    57 // Creates new visual
       
    58 // ---------------------------------------------------------------------------
       
    59 //   
       
    60 EXPORT_C CAlfVisual* AlfVisualFactory::NewVisualLC(
       
    61         TAlfVisualType aVisualType,
       
    62 	    CAlfLayout* aParentLayout,
       
    63 	    CAlfControl& aOwner,
       
    64 	    CAlfEnv& /*aEnv*/,
       
    65 	    TInt aImplementationUid)
       
    66 	{
       
    67     CAlfVisual* visual = NULL;
       
    68     TInt mappedType = KErrNotFound;
       
    69     
       
    70     switch(aVisualType)
       
    71         {
       
    72         case EAlfVisualTypeVisual:
       
    73             {
       
    74             if (aImplementationUid == 0)
       
    75                 mappedType = EAlfVisualCreate;
       
    76             visual = new (ELeave) CAlfVisual();
       
    77             break;
       
    78             }
       
    79             
       
    80         case EAlfVisualTypeLine:
       
    81             if (aImplementationUid == 0)
       
    82                 mappedType = EAlfLineVisualCreate;
       
    83 
       
    84             visual = new (ELeave) CAlfLineVisual();
       
    85             break;
       
    86 
       
    87         /*case EAlfVisualTypeGradient:
       
    88             visual = new (ELeave) CAlfGradientVisual();
       
    89             break;*/
       
    90 
       
    91         case EAlfVisualTypeText:
       
    92             {
       
    93             if (aImplementationUid == 0)
       
    94                 mappedType = EAlfTextVisualCreate;
       
    95 
       
    96             visual = new (ELeave) CAlfTextVisual();
       
    97             break;    
       
    98             }
       
    99 
       
   100 #ifdef RD_ALF_IN_PLATFORM            
       
   101         case EAlfVisualTypeLCTText:
       
   102             {
       
   103             if (aImplementationUid == 0)
       
   104                 mappedType = EAlfLCTTextVisualCreate;
       
   105 
       
   106             visual = new (ELeave) CAlfLCTTextVisual();
       
   107             break;    
       
   108             }
       
   109 #endif // RD_ALF_IN_PLATFORM
       
   110             
       
   111         case EAlfVisualTypeImage:
       
   112             {
       
   113             if (aImplementationUid == 0)
       
   114                 mappedType = EAlfImageVisualCreate;
       
   115             
       
   116             visual = new (ELeave) CAlfImageVisual();
       
   117             break;
       
   118             }
       
   119             
       
   120         case EAlfVisualTypeMesh:
       
   121             if (aImplementationUid == 0)
       
   122                 mappedType = EAlfMeshVisualCreate;
       
   123             
       
   124             visual = new (ELeave) CAlfMeshVisual();
       
   125             break;
       
   126         
       
   127         case EAlfVisualTypeCanvas:
       
   128             if (aImplementationUid == 0)
       
   129                 mappedType = EAlfCanvasVisualCreate;
       
   130             
       
   131             visual = new (ELeave) CAlfCanvasVisual();
       
   132             break;
       
   133             
       
   134         
       
   135         default: // todo: should we leave or should extensions to be created via here?
       
   136             User::Leave(KErrNotFound);
       
   137         }
       
   138 
       
   139     CleanupStack::PushL(visual);
       
   140     
       
   141     ASSERT(aOwner.Identifier());
       
   142     
       
   143     TInt parentlayouthandle = 0;
       
   144     if (aParentLayout)
       
   145         {
       
   146         parentlayouthandle = aParentLayout->Identifier();
       
   147         }
       
   148     
       
   149     TInt2 inputParams(aOwner.Identifier(), parentlayouthandle);
       
   150    
       
   151     TPckg<TInt2> paramBuf(inputParams);
       
   152     
       
   153     visual->ConstructL( aOwner, 
       
   154                         (mappedType==KErrNotFound)?aVisualType:mappedType, 
       
   155                         aImplementationUid, paramBuf );
       
   156 
       
   157     return visual;    
       
   158     }
       
   159     
       
   160 // ---------------------------------------------------------------------------
       
   161 // Creates new layout - TODO: Is this obsolete ?
       
   162 // ---------------------------------------------------------------------------
       
   163 //   
       
   164 EXPORT_C CAlfLayout* AlfVisualFactory::NewLayoutL(
       
   165         TAlfLayoutType aLayoutType,
       
   166 	    CAlfLayout* aParentLayout,
       
   167 	    CAlfControl& aOwner,
       
   168 	    CAlfEnv& aEnv,
       
   169 	    TInt aImplementationUid)
       
   170     {
       
   171     CAlfLayout* layout = NewLayoutLC(aLayoutType, aParentLayout, aOwner, aEnv, aImplementationUid);
       
   172     CleanupStack::Pop(layout);
       
   173     return layout;
       
   174     }
       
   175     
       
   176 // ---------------------------------------------------------------------------
       
   177 // Creates new layout
       
   178 // ---------------------------------------------------------------------------
       
   179 //      
       
   180 EXPORT_C CAlfLayout* AlfVisualFactory::NewLayoutLC(	    
       
   181         TAlfLayoutType aLayoutType,
       
   182 	    CAlfLayout* aParentLayout,
       
   183 	    CAlfControl& aOwner,
       
   184 	    CAlfEnv& /*aEnv*/,
       
   185 	    TInt aImplementationUid )
       
   186     {
       
   187     CAlfLayout* layout = NULL;
       
   188     TInt mappedType = KErrNotFound; 
       
   189     
       
   190     switch(aLayoutType)
       
   191         {
       
   192         case EAlfLayoutTypeLayout:
       
   193             if (aImplementationUid == 0)
       
   194                 mappedType = EAlfLayoutCreate;
       
   195             layout = new (ELeave) CAlfLayout();
       
   196             break;
       
   197                   
       
   198         case EAlfLayoutTypeGrid:
       
   199             if (aImplementationUid == 0)
       
   200                 {
       
   201                 mappedType = EAlfGridLayoutCreate;
       
   202                 }
       
   203             layout = new (ELeave) CAlfGridLayout();
       
   204             break;
       
   205 
       
   206 #ifdef RD_ALF_IN_PLATFORM            
       
   207         case EAlfLayoutTypeLCTGrid:
       
   208             if (aImplementationUid == 0)
       
   209                 {
       
   210                 mappedType = EAlfLCTGridLayoutCreate;
       
   211                 }                
       
   212             layout = new (ELeave) CAlfLCTGridLayout();
       
   213             break;
       
   214 #endif // RD_ALF_IN_PLATFORM            
       
   215             
       
   216             
       
   217         case EAlfLayoutTypeAnchor:
       
   218             if (aImplementationUid == 0)
       
   219                 {
       
   220                 mappedType = EAlfAnchorLayoutCreate;
       
   221                 }                
       
   222             layout = new (ELeave) CAlfAnchorLayout();
       
   223             break;
       
   224 
       
   225 #ifdef RD_ALF_IN_PLATFORM            
       
   226         case EAlfLayoutTypeLCTAnchor:
       
   227             if (aImplementationUid == 0)
       
   228                 {
       
   229                 mappedType = EAlfLCTAnchorLayoutCreate;
       
   230                 }                
       
   231             layout = new (ELeave) CAlfLCTAnchorLayout();
       
   232             break;
       
   233 #endif // RD_ALF_IN_PLATFORM            
       
   234             
       
   235         case EAlfLayoutTypeDeck:
       
   236             if (aImplementationUid == 0)
       
   237                 {
       
   238                 mappedType = EAlfDeckLayoutCreate;
       
   239                 }                
       
   240             layout = new (ELeave) CAlfDeckLayout();
       
   241             break;
       
   242             
       
   243         case EAlfLayoutTypeFlow:
       
   244             if (aImplementationUid == 0)
       
   245                 {
       
   246                 mappedType = EAlfFlowLayoutCreate;
       
   247                 }                
       
   248             layout = new (ELeave) CAlfFlowLayout();
       
   249             break;
       
   250             
       
   251         case EAlfLayoutTypeCurvePath:
       
   252             if (aImplementationUid == 0)
       
   253                 {
       
   254                 mappedType = EAlfCurvePathLayoutCreate;
       
   255                 }                
       
   256             layout = new (ELeave) CAlfCurvePathLayout();
       
   257             break;
       
   258             
       
   259         case EAlfLayoutTypeViewport:
       
   260             if (aImplementationUid == 0)
       
   261                 {
       
   262                 mappedType = EAlfViewportLayoutCreate;
       
   263                 }                
       
   264             layout = new (ELeave) CAlfViewportLayout();
       
   265             break;            
       
   266             
       
   267         default:
       
   268             User::Leave(KErrNotFound);
       
   269         }
       
   270 
       
   271     CleanupStack::PushL(layout);
       
   272 
       
   273     ASSERT(aOwner.Identifier());
       
   274     
       
   275     TInt parentlayouthandle = 0;
       
   276     if (aParentLayout)
       
   277         {
       
   278         parentlayouthandle = aParentLayout->Identifier();
       
   279         }
       
   280     
       
   281     TInt2 inputParams(aOwner.Identifier(), parentlayouthandle);
       
   282    
       
   283     TPckg<TInt2> paramBuf(inputParams);
       
   284 
       
   285     layout->CAlfVisual::ConstructL( aOwner, 
       
   286                         (mappedType==KErrNotFound)?aLayoutType:mappedType, 
       
   287                         aImplementationUid, paramBuf );
       
   288     return layout;    
       
   289     }
       
   290