skins/AknSkins/src/AknsListBoxBackgroundControlContext.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:  Listbox background context item.
       
    15 *
       
    16 */
       
    17 
       
    18 
       
    19 // INCLUDE FILES
       
    20 #include "AknsCppPreface.h"
       
    21 
       
    22 #include <AknsListBoxBackgroundControlContext.h>
       
    23 
       
    24 #include "AknsBackgroundLayout.h"
       
    25 #include <AknsUtils.h>
       
    26 
       
    27 // ============================ MEMBER FUNCTIONS ===============================
       
    28 
       
    29 // -----------------------------------------------------------------------------
       
    30 // CAknsListBoxBackgroundControlContext::CAknsListBoxBackgroundControlContext
       
    31 // C++ default constructor can NOT contain any code, that
       
    32 // might leave.
       
    33 // -----------------------------------------------------------------------------
       
    34 //
       
    35 CAknsListBoxBackgroundControlContext::CAknsListBoxBackgroundControlContext() :
       
    36     CAknsBasicBackgroundControlContext()
       
    37     // CBase initializes: iTiledContext(NULL), iBottomLayout(NULL)
       
    38     {
       
    39     }
       
    40 
       
    41 // -----------------------------------------------------------------------------
       
    42 // CAknsListBoxBackgroundControlContext::ConstructL
       
    43 // Symbian 2nd phase constructor can leave.
       
    44 // -----------------------------------------------------------------------------
       
    45 //
       
    46 void CAknsListBoxBackgroundControlContext::ConstructL(
       
    47     const TRect& aRect, const TBool aParentAbsolute,
       
    48     const TAknsItemID& aImageID,
       
    49     const TAknsItemID& aTiledBitmapID, const TRect& aTiledRect )
       
    50     {
       
    51     CAknsBasicBackgroundControlContext::ConstructL( aRect, aParentAbsolute,
       
    52         aImageID );
       
    53 
       
    54     iTiledLayout = new (ELeave) TAknsBackground;
       
    55     iTiledLayout->iRect = aTiledRect;
       
    56     iTiledLayout->iAttr.iAttributes = EAknsImageAttributeTileY;
       
    57     iTiledLayout->iImageID = aTiledBitmapID;
       
    58 
       
    59     iBottomLayout = new (ELeave) TAknsBackground;
       
    60     iBottomLayout->iImageID = KAknsIIDNone;
       
    61     }
       
    62 
       
    63 // -----------------------------------------------------------------------------
       
    64 // CAknsListBoxBackgroundControlContext::NewL
       
    65 // Two-phased constructor.
       
    66 // -----------------------------------------------------------------------------
       
    67 //
       
    68 AKNS_EXPORTED_METHOD(CAknsListBoxBackgroundControlContext::NewL)
       
    69 EXPORT_C CAknsListBoxBackgroundControlContext*
       
    70     CAknsListBoxBackgroundControlContext::NewL(
       
    71     const TAknsItemID& aImageID, const TRect& aRect,
       
    72     const TBool aParentAbsolute, const TAknsItemID& aTiledBitmapID,
       
    73     const TRect& aTiledRect )
       
    74     {
       
    75     CAknsListBoxBackgroundControlContext* self =
       
    76         new( ELeave ) CAknsListBoxBackgroundControlContext();
       
    77 
       
    78     CleanupStack::PushL( self );
       
    79     self->ConstructL( aRect, aParentAbsolute, aImageID, aTiledBitmapID,
       
    80         aTiledRect );
       
    81     CleanupStack::Pop( self );
       
    82 
       
    83     return self;
       
    84     }
       
    85 
       
    86 // -----------------------------------------------------------------------------
       
    87 // CAknsListBoxBackgroundControlContext::~CAknsListBoxBackgroundControlContext
       
    88 // Destructor.
       
    89 // -----------------------------------------------------------------------------
       
    90 //
       
    91 CAknsListBoxBackgroundControlContext::~CAknsListBoxBackgroundControlContext()
       
    92     {
       
    93     delete iTiledLayout;
       
    94     delete iBottomLayout;
       
    95     }
       
    96 
       
    97 // -----------------------------------------------------------------------------
       
    98 // CAknsListBoxBackgroundControlContext::SetTiledBitmap
       
    99 // (other items were commented in a header).
       
   100 // -----------------------------------------------------------------------------
       
   101 //
       
   102 AKNS_EXPORTED_METHOD(CAknsListBoxBackgroundControlContext::SetTiledBitmap)
       
   103 EXPORT_C void CAknsListBoxBackgroundControlContext::SetTiledBitmap(
       
   104     const TAknsItemID& aID )
       
   105     {
       
   106     iTiledLayout->iImageID = aID;
       
   107     }
       
   108 
       
   109 // -----------------------------------------------------------------------------
       
   110 // CAknsListBoxBackgroundControlContext::SetTiledRect
       
   111 // (other items were commented in a header).
       
   112 // -----------------------------------------------------------------------------
       
   113 //
       
   114 AKNS_EXPORTED_METHOD(CAknsListBoxBackgroundControlContext::SetTiledRect)
       
   115 EXPORT_C void CAknsListBoxBackgroundControlContext::SetTiledRect(
       
   116     const TRect& aRect )
       
   117     {
       
   118     iTiledLayout->iRect = aRect;
       
   119     }
       
   120 
       
   121 // -----------------------------------------------------------------------------
       
   122 // CAknsListBoxBackgroundControlContext::SetBottomBitmap
       
   123 // (other items were commented in a header).
       
   124 // -----------------------------------------------------------------------------
       
   125 //
       
   126 AKNS_EXPORTED_METHOD(CAknsListBoxBackgroundControlContext::SetBottomBitmap)
       
   127 EXPORT_C void CAknsListBoxBackgroundControlContext::SetBottomBitmap(
       
   128     const TAknsItemID& aID )
       
   129     {
       
   130     iBottomLayout->iImageID = aID;
       
   131     }
       
   132 
       
   133 // -----------------------------------------------------------------------------
       
   134 // CAknsListBoxBackgroundControlContext::SetBottomRect
       
   135 // (other items were commented in a header).
       
   136 // -----------------------------------------------------------------------------
       
   137 //
       
   138 AKNS_EXPORTED_METHOD(CAknsListBoxBackgroundControlContext::SetBottomRect)
       
   139 EXPORT_C void CAknsListBoxBackgroundControlContext::SetBottomRect(
       
   140     const TRect& aRect )
       
   141     {
       
   142     iBottomLayout->iRect = aRect;
       
   143     }
       
   144 
       
   145 // -----------------------------------------------------------------------------
       
   146 // CAknsListBoxBackgroundControlContext::IsCompatibleWithType
       
   147 // (other items were commented in a header).
       
   148 // -----------------------------------------------------------------------------
       
   149 //
       
   150 TBool CAknsListBoxBackgroundControlContext::IsCompatibleWithType(
       
   151     const TAknsControlContextType aType ) const
       
   152     {
       
   153     switch( aType )
       
   154         {
       
   155         case EAknsControlContextTypeUnknown:
       
   156         case EAknsControlContextTypeBasic:
       
   157         case EAknsControlContextTypeListBox:
       
   158             return ETrue;
       
   159 
       
   160 #ifdef RD_FULLSCREEN_WALLPAPER
       
   161         case EAknsControlContextTypeCombined:
       
   162 #endif //RD_FULLSCREEN_WALLPAPER
       
   163         case EAknsControlContextTypeLayered:
       
   164         case EAknsControlContextTypeFrame:
       
   165             break;
       
   166         }
       
   167 
       
   168     return EFalse;
       
   169     }
       
   170 
       
   171 // -----------------------------------------------------------------------------
       
   172 // CAknsListBoxBackgroundControlContext::UpdateContext
       
   173 // (other items were commented in a header).
       
   174 // -----------------------------------------------------------------------------
       
   175 //
       
   176 TInt CAknsListBoxBackgroundControlContext::UpdateContext()
       
   177     {
       
   178     MAknsSkinInstance* skin = AknsUtils::SkinInstance();
       
   179     TBool tileExists( EFalse );
       
   180     TBool bottomExists( EFalse );
       
   181     if( skin )
       
   182         {
       
   183         if( skin->GetCachedItemData( iTiledLayout->iImageID ) )
       
   184             tileExists = ETrue;
       
   185         if( skin->GetCachedItemData( iBottomLayout->iImageID ) )
       
   186             bottomExists = ETrue;
       
   187         }
       
   188 
       
   189     if( tileExists )
       
   190         {
       
   191         iLayout->iNext = iTiledLayout;
       
   192         if( bottomExists )
       
   193             {
       
   194             iTiledLayout->iNext = iBottomLayout;
       
   195             }
       
   196         else
       
   197             {
       
   198             iTiledLayout->iNext = NULL;
       
   199             }
       
   200         }
       
   201     else
       
   202         {
       
   203         if( bottomExists )
       
   204             {
       
   205             iLayout->iNext = iBottomLayout;
       
   206             }
       
   207         else
       
   208             {
       
   209             iLayout->iNext = NULL;
       
   210             }
       
   211         }
       
   212 
       
   213     return 0;
       
   214     }
       
   215 
       
   216 //  End of File