skins/AknSkins/src/AknsLayeredBackgroundControlContext.cpp
changeset 0 05e9090e2422
equal deleted inserted replaced
-1:000000000000 0:05e9090e2422
       
     1 /*
       
     2 * Copyright (c) 2002-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:  Layered background context item.
       
    15 *
       
    16 */
       
    17 
       
    18 
       
    19 // INCLUDE FILES
       
    20 #include <AknsLayeredBackgroundControlContext.h>
       
    21 
       
    22 #include "AknsBackgroundLayout.h"
       
    23 #include "AknsDebug.h"
       
    24 
       
    25 // ============================ MEMBER FUNCTIONS ===============================
       
    26 
       
    27 // -----------------------------------------------------------------------------
       
    28 // CAknsLayeredBackgroundControlContext::CAknsLayeredBackgroundControlContext
       
    29 // C++ default constructor can NOT contain any code, that
       
    30 // might leave.
       
    31 // -----------------------------------------------------------------------------
       
    32 //
       
    33 CAknsLayeredBackgroundControlContext::CAknsLayeredBackgroundControlContext() :
       
    34     CAknsBasicBackgroundControlContext()
       
    35     // CBase initializes: iLayoutArray(NULL), iLayoutArraySize(0)
       
    36     {
       
    37     }
       
    38 
       
    39 // -----------------------------------------------------------------------------
       
    40 // CAknsLayeredBackgroundControlContext::ConstructL
       
    41 // Symbian 2nd phase constructor can leave.
       
    42 // -----------------------------------------------------------------------------
       
    43 //
       
    44 void CAknsLayeredBackgroundControlContext::ConstructL(
       
    45     const TRect& aRect, const TBool aParentAbsolute,
       
    46     const TAknsItemID& aImageID, const TInt aNumberOfLayers  )
       
    47     {
       
    48     CAknsBasicBackgroundControlContext::ConstructL( aRect, aParentAbsolute,
       
    49         aImageID );
       
    50 
       
    51     TInt arraySize = aNumberOfLayers-1;
       
    52     if( arraySize>0 )
       
    53         {
       
    54         iLayoutArray = new (ELeave) TAknsBackground[ //lint !e119 New operator exists
       
    55             static_cast<TUint>(arraySize) ];
       
    56         iLayout->iNext = &(iLayoutArray[0]);
       
    57         }
       
    58     iLayoutArraySize = arraySize;
       
    59 
       
    60     for( TInt i = 0; i<arraySize-1; i++ )
       
    61         {
       
    62         iLayoutArray[i].iNext = &(iLayoutArray[i+1]);
       
    63         }
       
    64     }
       
    65 
       
    66 // -----------------------------------------------------------------------------
       
    67 // CAknsLayeredBackgroundControlContext::NewL
       
    68 // Two-phased constructor.
       
    69 // -----------------------------------------------------------------------------
       
    70 //
       
    71 EXPORT_C CAknsLayeredBackgroundControlContext*
       
    72     CAknsLayeredBackgroundControlContext::NewL(
       
    73     const TAknsItemID& aImageID, const TRect& aRect,
       
    74     const TBool aParentAbsolute, const TInt aNumberOfLayers  )
       
    75     {
       
    76     CAknsLayeredBackgroundControlContext* self =
       
    77         new( ELeave ) CAknsLayeredBackgroundControlContext();
       
    78 
       
    79     CleanupStack::PushL( self );
       
    80     self->ConstructL( aRect, aParentAbsolute, aImageID, aNumberOfLayers );
       
    81     CleanupStack::Pop( self );
       
    82 
       
    83     return self;
       
    84     }
       
    85 
       
    86 // -----------------------------------------------------------------------------
       
    87 // CAknsLayeredBackgroundControlContext::~CAknsLayeredBackgroundControlContext
       
    88 // Destructor.
       
    89 // -----------------------------------------------------------------------------
       
    90 //
       
    91 CAknsLayeredBackgroundControlContext::~CAknsLayeredBackgroundControlContext()
       
    92     {
       
    93     delete [] iLayoutArray;
       
    94     }
       
    95 
       
    96 // -----------------------------------------------------------------------------
       
    97 // CAknsLayeredBackgroundControlContext::SetLayerImage
       
    98 // (other items were commented in a header).
       
    99 // -----------------------------------------------------------------------------
       
   100 //
       
   101 EXPORT_C void CAknsLayeredBackgroundControlContext::SetLayerImage(
       
   102     const TInt aLayer, const TAknsItemID& aID )
       
   103     {
       
   104     __ASSERT_DEBUG( (aLayer>=0 && aLayer<=iLayoutArraySize),
       
   105         AKNS_DEBUG_PANIC(EAknsDPanicInvalidParameter) );
       
   106 
       
   107     if (aLayer < 0 || aLayer>iLayoutArraySize)
       
   108         {
       
   109         return;
       
   110         }
       
   111 
       
   112     if( aLayer == 0 )
       
   113         {
       
   114         iLayout->iImageID = aID;
       
   115         }
       
   116     else
       
   117         {
       
   118         iLayoutArray[ aLayer-1 ].iImageID = aID;
       
   119         }
       
   120     }
       
   121 
       
   122 // -----------------------------------------------------------------------------
       
   123 // CAknsLayeredBackgroundControlContext::SetLayerRect
       
   124 // (other items were commented in a header).
       
   125 // -----------------------------------------------------------------------------
       
   126 //
       
   127 EXPORT_C void CAknsLayeredBackgroundControlContext::SetLayerRect(
       
   128     const TInt aLayer, const TRect& aRect )
       
   129     {
       
   130     __ASSERT_DEBUG( (aLayer>=0 && aLayer<=iLayoutArraySize),
       
   131         AKNS_DEBUG_PANIC(EAknsDPanicInvalidParameter) );
       
   132 
       
   133     if (aLayer < 0 || aLayer>iLayoutArraySize)
       
   134         {
       
   135         return;
       
   136         }
       
   137 
       
   138     if( aLayer == 0 )
       
   139         {
       
   140         iLayout->iRect = aRect;
       
   141         }
       
   142     else
       
   143         {
       
   144         iLayoutArray[ aLayer-1 ].iRect = aRect;
       
   145         }
       
   146     }
       
   147 
       
   148 // -----------------------------------------------------------------------------
       
   149 // CAknsLayeredBackgroundControlContext::IsCompatibleWithType
       
   150 // (other items were commented in a header).
       
   151 // -----------------------------------------------------------------------------
       
   152 //
       
   153 TBool CAknsLayeredBackgroundControlContext::IsCompatibleWithType(
       
   154     const TAknsControlContextType aType ) const
       
   155     {
       
   156     switch( aType )
       
   157         {
       
   158         case EAknsControlContextTypeUnknown:
       
   159         case EAknsControlContextTypeBasic:
       
   160         case EAknsControlContextTypeLayered:
       
   161             return ETrue;
       
   162 
       
   163 #ifdef RD_FULLSCREEN_WALLPAPER
       
   164         case EAknsControlContextTypeCombined:
       
   165 #endif //RD_FULLSCREEN_WALLPAPER
       
   166         case EAknsControlContextTypeListBox:
       
   167         case EAknsControlContextTypeFrame:
       
   168             // EFalse is returned
       
   169             break;
       
   170 
       
   171         default:
       
   172             // EFalse is returned
       
   173             break;
       
   174         }
       
   175 
       
   176     return EFalse;
       
   177     }
       
   178 
       
   179 //  End of File