photosgallery/viewframework/visuallistmanager/src/glxbordericonmanager.cpp
changeset 0 4e91876724a2
equal deleted inserted replaced
-1:000000000000 0:4e91876724a2
       
     1 /*
       
     2 * Copyright (c) 2008-2009 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:    Adds a border to icons in visual lists
       
    15 *
       
    16 */
       
    17 
       
    18 
       
    19 
       
    20 
       
    21 /**
       
    22  * @internal reviewed 31/07/2007 by Rowland Cook
       
    23  */
       
    24 
       
    25 #include "glxbordericonmanager.h"
       
    26 //#include "mglxmedialistobserver.h"
       
    27 #include "mglxvisuallist.h"
       
    28 
       
    29 #include <AknsUtils.h>
       
    30 #include <alf/alfvisual.h>
       
    31 #include <alf/alfbrush.h>
       
    32 #include <alf/alfbrusharray.h>
       
    33 #include <glxuiutility.h>
       
    34 #include <alf/alfborderbrush.h>
       
    35 
       
    36 const TInt KGlxBorderIconWidth = 1;
       
    37 const TInt KGlxBorderIconOffset = 1;
       
    38 
       
    39 // ---------------------------------------------------------------------------
       
    40 // 1st phase constructor
       
    41 // ---------------------------------------------------------------------------
       
    42 //
       
    43 EXPORT_C CGlxBorderIconManager* CGlxBorderIconManager::NewL(
       
    44                            MGlxMediaList& aMediaList, MGlxVisualList& aVisualList)
       
    45 	{
       
    46 	CGlxBorderIconManager* self = 
       
    47 	                new(ELeave)CGlxBorderIconManager(aMediaList, aVisualList);
       
    48 	CleanupStack::PushL(self);
       
    49 	self->ConstructL();
       
    50 	CleanupStack::Pop(self);
       
    51 	return self;
       
    52 	}
       
    53 
       
    54 // ---------------------------------------------------------------------------
       
    55 // Destructor
       
    56 // ---------------------------------------------------------------------------
       
    57 //	
       
    58 CGlxBorderIconManager::~CGlxBorderIconManager()
       
    59 	{
       
    60 	iVisualList.RemoveObserver(this);
       
    61 	delete iBorderBrush;
       
    62 	}
       
    63 	
       
    64 // ---------------------------------------------------------------------------
       
    65 // HandleVisualAddedL
       
    66 // ---------------------------------------------------------------------------
       
    67 // 
       
    68 void CGlxBorderIconManager::HandleVisualAddedL( CAlfVisual* aVisual, 
       
    69     TInt /*aIndex*/, MGlxVisualList* /*aList*/ )
       
    70 	{
       
    71 	AddBorderBrushL(aVisual);
       
    72 	}
       
    73 
       
    74 // ---------------------------------------------------------------------------
       
    75 // Constructor
       
    76 // ---------------------------------------------------------------------------
       
    77 //	
       
    78 CGlxBorderIconManager::CGlxBorderIconManager(MGlxMediaList& aMediaList, 
       
    79                                             MGlxVisualList& aVisualList)
       
    80 	: CGlxIconManager(aMediaList, aVisualList)
       
    81 	{
       
    82 	// No  implementation
       
    83 	}
       
    84 
       
    85 // ---------------------------------------------------------------------------
       
    86 // 2nd phase construction
       
    87 // ---------------------------------------------------------------------------
       
    88 //	
       
    89 void CGlxBorderIconManager::ConstructL()
       
    90 	{
       
    91 	BaseConstructL();
       
    92 	
       
    93 	// add as observer
       
    94 	iVisualList.AddObserverL(this);
       
    95 	
       
    96     TRgb brushColor;
       
    97     AknsUtils::GetCachedColor(AknsUtils::SkinInstance(), brushColor, 
       
    98         KAknsIIDQsnOtherColors, EAknsCIQsnOtherColorsCG12);
       
    99 
       
   100     iBorderBrush = 
       
   101         CAlfBorderBrush::NewL( 
       
   102             *( iUiUtility->Env() ),
       
   103             KGlxBorderIconWidth, KGlxBorderIconWidth, 
       
   104             KGlxBorderIconOffset, KGlxBorderIconOffset );
       
   105                                 
       
   106     iBorderBrush->SetLayer(EAlfBrushLayerForeground);
       
   107     iBorderBrush->SetColor(brushColor);
       
   108 	
       
   109 	// check for any visual already present in list
       
   110 	TInt itemCount = iVisualList.ItemCount();
       
   111 	for(TInt i = 0; i < itemCount; i++)
       
   112 	    {
       
   113 	    AddBorderBrushL(iVisualList.Visual(i));
       
   114 	    }
       
   115 	}
       
   116 
       
   117     
       
   118 // ---------------------------------------------------------------------------
       
   119 // AddBorderBrushL
       
   120 // ---------------------------------------------------------------------------
       
   121 //	
       
   122 void CGlxBorderIconManager::AddBorderBrushL(CAlfVisual* aVisual)
       
   123     {
       
   124 	if ( aVisual )
       
   125 	    {
       
   126     	aVisual->EnableBrushesL();
       
   127         	
       
   128     	aVisual->Brushes()->AppendL( iBorderBrush, EAlfDoesNotHaveOwnership );
       
   129     	}
       
   130     }
       
   131     
       
   132 // ---------------------------------------------------------------------------
       
   133 // SetThumbnailBorderColor
       
   134 // ---------------------------------------------------------------------------
       
   135 //
       
   136 EXPORT_C void CGlxBorderIconManager::SetThumbnailBorderColor()
       
   137 	{
       
   138 	TRgb brushColor;
       
   139     TInt errCode = AknsUtils::GetCachedColor(AknsUtils::SkinInstance(), brushColor, 
       
   140         KAknsIIDQsnOtherColors, EAknsCIQsnOtherColorsCG12);
       
   141         
       
   142 	if( KErrNone == errCode )
       
   143 		{
       
   144 		iBorderBrush->SetColor( brushColor );	
       
   145 		}
       
   146   }