photosgallery/viewframework/visuallistmanager/src/glxitemvisual.cpp
changeset 0 4e91876724a2
child 14 ce1c7ad1f18b
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:    Item visual container
       
    15 *
       
    16 */
       
    17 
       
    18 
       
    19 
       
    20 
       
    21 /**
       
    22  * @internal reviewed 04/07/2007 by M Byrne
       
    23  */
       
    24 
       
    25 #include "glxitemvisual.h"
       
    26 
       
    27 #include <alf/alfanchorlayout.h>
       
    28 #include <alf/alfcontrol.h>
       
    29 #include <alf/alfdecklayout.h>
       
    30 #include <AknUtils.h>
       
    31 #include <alf/alfimagevisual.h>
       
    32 #include <alf/alfimagebrush.h>
       
    33 #include <alf/alfdisplay.h>
       
    34 #include <alf/alfenv.h>
       
    35 #include <alf/alftexture.h>
       
    36 #include <mpxmediageneraldefs.h>
       
    37 #include <imageconversion.h>
       
    38 
       
    39 #include <glxlog.h>
       
    40 #include <glxtracer.h>
       
    41 
       
    42 #include <glxassert.h>
       
    43 #include <glxuiutility.h>
       
    44 #include <glxmedia.h>
       
    45 #include <glxmediageneraldefs.h>
       
    46 #include <glxtexturemanager.h>
       
    47 #include <glxthumbnailattributeinfo.h>
       
    48 #include <mglxmedialist.h>
       
    49 #include <glxthumbnailutility.h>
       
    50 #include <alf/alftransformation.h>
       
    51 #include "mglxvisualobjectstatusobserver.h"
       
    52 #include "mglxvisualobjectlayoutrefreshobserver.h"
       
    53 
       
    54 const TInt KGlxOpacityFadeDuration = 400;
       
    55 
       
    56 const TInt KGlxForegroundAnchorOrdinal = 2;
       
    57 
       
    58 // -----------------------------------------------------------------------------
       
    59 // Constructor. Inlined to save a few bits of rom
       
    60 // -----------------------------------------------------------------------------
       
    61 inline CGlxVisualObject::CGlxVisualObject( MGlxMediaList& aMediaList)
       
    62     : iMediaList( aMediaList )
       
    63     {
       
    64     // No implementation
       
    65     }
       
    66 
       
    67 // -----------------------------------------------------------------------------
       
    68 // NewLC
       
    69 // -----------------------------------------------------------------------------
       
    70 CGlxVisualObject* CGlxVisualObject::NewLC( 
       
    71             MGlxVisualObjectParameterFactory& aFactory,MGlxMediaList& aMediaList)
       
    72     {
       
    73     TRACER("CGlxVisualObject::NewLC");
       
    74     CGlxVisualObject* self = new ( ELeave ) CGlxVisualObject( aMediaList);
       
    75     CleanupStack::PushL( self );
       
    76     self->ConstructL( aFactory );
       
    77     return self;
       
    78     }
       
    79 
       
    80 // -----------------------------------------------------------------------------
       
    81 // Destructor
       
    82 // -----------------------------------------------------------------------------
       
    83 CGlxVisualObject::~CGlxVisualObject()
       
    84     {
       
    85     TRACER("CGlxVisualObject::~CGlxVisualObject");
       
    86     iForegroundIconAnchors.Close();
       
    87     iBackgroundIconAnchors.Close();
       
    88     
       
    89     while ( iZoomTiles.Count() )
       
    90         {
       
    91         RemoveZoomTile(0);
       
    92         }
       
    93     iZoomTiles.Close();
       
    94 
       
    95 	if ( iUiUtility && iImageValid )
       
    96         {
       
    97         // Clean up the texture from the texture manager
       
    98         iUiUtility->GlxTextureManager().RemoveTexture( iImage.Texture() );
       
    99         }
       
   100 
       
   101     if ( iVisual )
       
   102         {
       
   103         iVisual->RemoveAndDestroyAllD();
       
   104         }
       
   105         delete iAnimatedTexture;
       
   106     if ( iUiUtility )
       
   107         {
       
   108         iUiUtility->Close();
       
   109         }
       
   110     iObservers.Close();
       
   111     }
       
   112 
       
   113 // -----------------------------------------------------------------------------
       
   114 // ConstructL
       
   115 // -----------------------------------------------------------------------------
       
   116 void CGlxVisualObject::ConstructL( MGlxVisualObjectParameterFactory& aFactory) 
       
   117     {
       
   118     TRACER("CGlxVisualObject::ConstructL");
       
   119     iUiUtility = CGlxUiUtility::UtilityL();
       
   120     // create the visual with parents layout
       
   121     iVisual = CAlfAnchorLayout::AddNewL(aFactory.VisualOwner(),
       
   122                                         aFactory.Layout());
       
   123     iVisual->EnableTransformationL();
       
   124     
       
   125     // create background underlay anchor layout 
       
   126     //to act as a black screen and avoid overlapping images                                      
       
   127     iBackgroundOverlayVisual = 
       
   128         CAlfImageVisual::AddNewL( aFactory.VisualOwner(), iVisual); 
       
   129     CAlfTexture& backgroundTexture = 
       
   130     	iUiUtility->GlxTextureManager().CreateFlatColourTextureL(KRgbBlack);
       
   131     iBackgroundOverlayVisual->SetClipping(ETrue);	
       
   132     iBackgroundOverlayVisual->SetImage(TAlfImage(backgroundTexture));	
       
   133     // create main visual
       
   134     iMainVisual = 
       
   135         CAlfAnchorLayout::AddNewL( aFactory.VisualOwner(), iVisual );    
       
   136                                         
       
   137     // create the child image visual
       
   138     iImageVisual = 
       
   139         CAlfImageVisual::AddNewL( aFactory.VisualOwner(), iMainVisual );
       
   140     //iImageVisual->SetScaleMode( aFactory.ThumbnailScaleMode() );
       
   141 	iImageVisual->SetScaleMode(CAlfImageVisual::EScaleNormal);
       
   142     // Turn on clipping only if cover-mode has been chosen
       
   143     iImageVisual->SetClipping(ETrue);
       
   144 
       
   145 	User::LeaveIfError( iMainVisual->SetRelativeAnchorRect(
       
   146   	0, EAlfAnchorOriginLeft, EAlfAnchorOriginTop, TAlfRealPoint(),
       
   147 	 EAlfAnchorOriginRight, EAlfAnchorOriginBottom, TAlfRealPoint() ) );
       
   148 
       
   149 	// get screen size
       
   150 	SetVisible(EFalse);
       
   151 	TSize screenSize = iUiUtility->DisplaySize();
       
   152     RefreshLayout( screenSize );	
       
   153     }
       
   154         
       
   155 // -----------------------------------------------------------------------------
       
   156 // SetScaleMode
       
   157 // -----------------------------------------------------------------------------
       
   158 //
       
   159 EXPORT_C void CGlxVisualObject::SetScaleMode(CAlfImageVisual::TScaleMode aMode)
       
   160     {
       
   161     TRACER("CGlxVisualObject::SetScaleMode");
       
   162     iImageVisual->SetScaleMode(aMode);
       
   163     }
       
   164     
       
   165 // -----------------------------------------------------------------------------
       
   166 // Reset state of the object as if it had just been constructed
       
   167 // -----------------------------------------------------------------------------
       
   168 //
       
   169 void CGlxVisualObject::Reset() 
       
   170     {
       
   171     TRACER("CGlxVisualObject::Reset");
       
   172     SetVisible(EFalse);
       
   173     StopAnimation();
       
   174     iAnimateWhenAttributesAvailable = EFalse;
       
   175     iUiUtility->GlxTextureManager().RemoveTexture(iImage.Texture());
       
   176     }
       
   177 
       
   178 // -----------------------------------------------------------------------------
       
   179 // Remove and delete all child visuals of the layout
       
   180 // @param aLayout layout to reset
       
   181 // -----------------------------------------------------------------------------
       
   182 //	
       
   183 void CGlxVisualObject::ResetLayout( CAlfVisual& /*aVisual*/ )
       
   184     {
       
   185     //to be used when layouts are back
       
   186     // until no visuals left
       
   187     }
       
   188     
       
   189 // -----------------------------------------------------------------------------
       
   190 // Visual
       
   191 // -----------------------------------------------------------------------------
       
   192 CAlfVisual* CGlxVisualObject::Visual()
       
   193 	{
       
   194 	TRACER("CGlxVisualObject::Visual");
       
   195 	return iVisual;
       
   196 	}
       
   197     
       
   198 // -----------------------------------------------------------------------------
       
   199 // SetVisible
       
   200 // -----------------------------------------------------------------------------
       
   201 void CGlxVisualObject::SetVisible( TBool aVisible )
       
   202     {
       
   203     TRACER("CGlxVisualObject::SetVisible");
       
   204     if(aVisible)
       
   205 	    {
       
   206 	    iVisual->SetOpacity(  TAlfTimedValue(1.0 , 0 ));	
       
   207 	    }
       
   208     else
       
   209 	    {
       
   210 	    iVisual->SetOpacity( TAlfTimedValue(0.0, 0 ));	
       
   211 	    }
       
   212     
       
   213     }
       
   214 
       
   215 // -----------------------------------------------------------------------------
       
   216 // SetIndex
       
   217 // -----------------------------------------------------------------------------
       
   218 void CGlxVisualObject::SetIndex( TInt aIndex )
       
   219 	{
       
   220 	TRACER("CGlxVisualObject::SetIndex");
       
   221 	GLX_LOG_INFO1("CGlxVisualObject::SetIndex %d",aIndex);
       
   222 	iIndex = aIndex;
       
   223 	}
       
   224 
       
   225 // -----------------------------------------------------------------------------
       
   226 // SetImage
       
   227 // -----------------------------------------------------------------------------
       
   228 void CGlxVisualObject::SetImage( TAlfImage aImage )
       
   229 	{
       
   230 	TRACER("CGlxVisualObject::SetImage");
       
   231 	iImageVisual->SetImage( aImage );
       
   232 	iImage = aImage;
       
   233 	iImageValid = ETrue;
       
   234 	}
       
   235 
       
   236 // -----------------------------------------------------------------------------
       
   237 // Image
       
   238 // -----------------------------------------------------------------------------
       
   239 TAlfImage CGlxVisualObject::Image()
       
   240 	{
       
   241 	TRACER("CGlxVisualObject::Image");
       
   242 	return iImage;
       
   243 	}
       
   244 
       
   245 // -----------------------------------------------------------------------------
       
   246 // RefreshLayout
       
   247 // the visual list has requested us to refresh the layout
       
   248 // -----------------------------------------------------------------------------
       
   249 void CGlxVisualObject::RefreshLayout( TSize /*aScreenSize*/ )
       
   250 	{
       
   251 	TRACER("CGlxVisualObject::RefreshLayout");
       
   252     // get texture manager
       
   253     CGlxTextureManager& textureMgr = iUiUtility->GlxTextureManager();
       
   254     // get new size, note that this is synchronous c/s call
       
   255 	TSize visSize = Visual()->Size().ValueNow().AsSize();
       
   256 
       
   257 	// check if visual size has changed since last time
       
   258 	if( visSize != iVisSize )
       
   259 	    {
       
   260 	    // store size
       
   261 	    iVisSize = visSize;
       
   262 	    
       
   263 	    // get the media id and id space id for this index
       
   264 	    TGlxMedia item = iMediaList.Item( iIndex );
       
   265 	    TGlxIdSpaceId idspace = iMediaList.IdSpaceId( iIndex );
       
   266 
       
   267         // check if there was a better thumbnail available
       
   268         if( textureMgr.TextureNeedsUpdating( item, idspace, visSize ) )
       
   269             {
       
   270             // need to update the texture
       
   271             TRAP_IGNORE(CAlfTexture& texture = 
       
   272                 textureMgr.CreateThumbnailTextureL( 
       
   273                     item, idspace, visSize, this );
       
   274             // set the new texture in place
       
   275         	SetImage( TAlfImage( texture ) ));
       
   276             }
       
   277         
       
   278         // update positions of overlay icons            
       
   279         UpdateIconAnchors( Image().Texture(), visSize );             
       
   280 	    }
       
   281 	}
       
   282 
       
   283 // -----------------------------------------------------------------------------
       
   284 // HandleAttributesAvailableL
       
   285 // -----------------------------------------------------------------------------
       
   286 //
       
   287 void CGlxVisualObject::HandleAttributesAvailableL(
       
   288     const TGlxIdSpaceId& aIdSpaceId, const TGlxMedia& aItem,
       
   289     const RArray<TMPXAttribute>& aAttributes)
       
   290     {
       
   291     TRACER("CGlxVisualObject::HandleAttributesAvailableL");
       
   292     TBool animate = ( EHasDefaultIcon == Status() );
       
   293 
       
   294     // get texture manager
       
   295     CGlxTextureManager& textureMgr = iUiUtility->GlxTextureManager();
       
   296     // get new size, note that this is synchronous c/s call          
       
   297     TSize visSize = iUiUtility->DisplaySize();
       
   298 
       
   299     // check if there was a better thumbnail available
       
   300     if( textureMgr.TextureNeedsUpdating( aItem, aIdSpaceId, visSize ) )
       
   301         {
       
   302         // need to update the texture
       
   303         CAlfTexture& texture = 
       
   304             textureMgr.CreateThumbnailTextureL( 
       
   305                 aItem, aIdSpaceId, visSize, this );
       
   306         // set the new texture in place
       
   307     	SetImage( TAlfImage( texture ) );
       
   308 
       
   309         // update positions of overlay icons 
       
   310         UpdateIconAnchors( Image().Texture(), visSize );             
       
   311 
       
   312         if ( animate && iObserver )
       
   313             {
       
   314             iObserver->ThumbnailLoadedL( *this );
       
   315             }
       
   316         }
       
   317 
       
   318     if ( iAnimateWhenAttributesAvailable )
       
   319         {
       
   320         TryAnimateL(aItem);
       
   321         }
       
   322 
       
   323     }
       
   324 
       
   325 // -----------------------------------------------------------------------------
       
   326 // StartAnimation
       
   327 // -----------------------------------------------------------------------------
       
   328 void CGlxVisualObject::StartAnimation( CAlfTexture& aAnimatedTexture )
       
   329     {
       
   330     TRACER("CGlxVisualObject::StartAnimation");
       
   331     // if we have an old texture
       
   332     if ( iAnimatedTexture )
       
   333         {
       
   334         // release the old texture
       
   335         iUiUtility->GlxTextureManager().RemoveTexture( *iAnimatedTexture );
       
   336         iAnimatedTexture = NULL;
       
   337         }
       
   338     // store the texture pointer so that we can stop it without a 
       
   339     // reference to the texture
       
   340     iAnimatedTexture = &aAnimatedTexture;
       
   341 
       
   342     // start the animation
       
   343     aAnimatedTexture.StartAnimation();
       
   344     // set the image to the visual
       
   345     iImageVisual->SetImage( TAlfImage( aAnimatedTexture ) );
       
   346     }
       
   347     
       
   348 // -----------------------------------------------------------------------------
       
   349 // StopAnimation
       
   350 // -----------------------------------------------------------------------------
       
   351 void CGlxVisualObject::StopAnimation()
       
   352     {
       
   353     TRACER("CGlxVisualObject::StopAnimation");
       
   354     if ( iAnimatedTexture )
       
   355         {
       
   356         iImageVisual->SetImage( iImage );
       
   357 
       
   358         // stop the animation
       
   359         iAnimatedTexture->StopAnimation();
       
   360         
       
   361         // release the texture
       
   362         iUiUtility->GlxTextureManager().RemoveTexture( *iAnimatedTexture );
       
   363         iAnimatedTexture = NULL;
       
   364         }
       
   365     }
       
   366     
       
   367 // -----------------------------------------------------------------------------
       
   368 // SetAnimateWhenAttributesAvailable
       
   369 // -----------------------------------------------------------------------------
       
   370 void CGlxVisualObject::SetAnimateWhenAttributesAvailable(TBool aFlag)
       
   371     {
       
   372     TRACER("CGlxVisualObject::SetAnimateWhenAttributesAvailable");
       
   373     iAnimateWhenAttributesAvailable = aFlag;
       
   374     }
       
   375 
       
   376 // -----------------------------------------------------------------------------
       
   377 // TryAnimateL
       
   378 // -----------------------------------------------------------------------------
       
   379 //
       
   380 void CGlxVisualObject::TryAnimateL(const TGlxMedia& aItem)
       
   381     {
       
   382     TRACER("CGlxVisualObject::TryAnimateL");
       
   383     TInt frameCount = 0;
       
   384     TSize mediaItemSize( KErrNotFound, KErrNotFound );
       
   385     aItem.GetDimensions( mediaItemSize );
       
   386     if ( aItem.GetFrameCount( frameCount ) )
       
   387         {
       
   388         const TDesC& uri = aItem.Uri();
       
   389         if (frameCount > 1 && uri.Length() > 0)
       
   390             {
       
   391             // create the animated texture from the URI
       
   392     		CAlfTexture& animTexture =
       
   393     		   iUiUtility->GlxTextureManager().CreateAnimatedGifTextureL( uri, mediaItemSize );
       
   394             StartAnimation( animTexture );
       
   395     		}
       
   396         SetAnimateWhenAttributesAvailable(EFalse);
       
   397 		}
       
   398     else
       
   399         {
       
   400         SetAnimateWhenAttributesAvailable(ETrue);
       
   401         }
       
   402     }
       
   403 
       
   404 // -----------------------------------------------------------------------------
       
   405 // RemoveOldZoomTiles
       
   406 // -----------------------------------------------------------------------------
       
   407 //
       
   408 void CGlxVisualObject::RemoveOldZoomTiles(const TGlxMedia& aItem)
       
   409     {
       
   410     TRACER("CGlxVisualObject::RemoveOldZoomTiles");
       
   411     const CGlxMedia* properties = aItem.Properties();
       
   412     TInt firstPosition = iZoomTiles.Count();
       
   413 
       
   414     for ( TInt i = iZoomTiles.Count() - 1; i >= 0; i-- )
       
   415         {
       
   416         if ( !(properties && properties->IsSupported(TMPXAttribute(
       
   417                         KGlxMediaIdThumbnail, iZoomTiles[i].iAttributeId))) )
       
   418             {
       
   419             RemoveZoomTile(i);
       
   420             firstPosition = i;
       
   421             }
       
   422         }
       
   423 
       
   424     ReanchorZoomTiles( firstPosition );
       
   425     }
       
   426 
       
   427 // -----------------------------------------------------------------------------
       
   428 // AddNewZoomTilesL
       
   429 // -----------------------------------------------------------------------------
       
   430 //
       
   431 void CGlxVisualObject::AddNewZoomTilesL(TGlxIdSpaceId aIdSpaceId,
       
   432             const TGlxMedia& aItem, const RArray<TMPXAttribute>& aAttributes)
       
   433     {
       
   434     TRACER("CGlxVisualObject::AddNewZoomTilesL");
       
   435     // Get dimension if we don't already have it
       
   436     if ( (iDimensions.iWidth == 0 || iDimensions.iHeight == 0) )
       
   437         {
       
   438         // Ignore success/failure return, test dimension instead
       
   439         aItem.GetDimensions(iDimensions);
       
   440         }
       
   441 
       
   442     if ( iDimensions.iWidth == 0 || iDimensions.iHeight == 0 )
       
   443         {
       
   444         return;
       
   445         }
       
   446 
       
   447     TInt firstPosition = iZoomTiles.Count();
       
   448 
       
   449     // Check new attributes for cropped thumbnails
       
   450     TInt count = aAttributes.Count();
       
   451     for ( TInt i = 0; i < count; i++ )
       
   452         {
       
   453         TMPXAttribute attr(aAttributes[i]);
       
   454 
       
   455         if ( KGlxMediaIdThumbnail == attr.ContentId()
       
   456             && !GlxIsFullThumbnailAttribute( attr.AttributeId() ) )
       
   457             {
       
   458             const CGlxThumbnailAttribute* thumbnail = 
       
   459                                           aItem.ThumbnailAttribute( attr );
       
   460             if ( thumbnail )
       
   461                 {
       
   462                 TInt position = AddZoomTileL( aItem, attr, aIdSpaceId,
       
   463                                                 thumbnail->iCroppingRect );
       
   464 
       
   465                 if ( position < firstPosition )
       
   466                     {
       
   467                     firstPosition = position;
       
   468                     }
       
   469                 }
       
   470             }
       
   471         }
       
   472 
       
   473     ReanchorZoomTiles( firstPosition );
       
   474     }
       
   475 
       
   476 // -----------------------------------------------------------------------------
       
   477 // RemoveZoomTile
       
   478 // -----------------------------------------------------------------------------
       
   479 //
       
   480 void CGlxVisualObject::RemoveZoomTile(TInt aIndex)
       
   481     {
       
   482     TRACER("CGlxVisualObject::RemoveZoomTile");
       
   483     __ASSERT_ALWAYS(0 <= aIndex && aIndex < iZoomTiles.Count(),
       
   484                                             Panic(EGlxPanicIllegalArgument));
       
   485 
       
   486     CAlfImageVisual* visual = iZoomTiles[aIndex].iVisual;
       
   487 	const TAlfImage& image = visual->Image();
       
   488 	if( image.HasTexture() )
       
   489 	    {
       
   490         iUiUtility->GlxTextureManager().RemoveTexture( image.Texture() );
       
   491 	    }
       
   492 	iVisual->Owner().Remove(visual);   // Caller gets ownership of the visual
       
   493     delete visual;
       
   494     iZoomTiles.Remove(aIndex);
       
   495     }
       
   496 
       
   497 // ---------------------------------------------------------------------------
       
   498 // AddZoomTileL
       
   499 // ---------------------------------------------------------------------------
       
   500 //
       
   501 TInt CGlxVisualObject::AddZoomTileL(
       
   502                     const TGlxMedia& aItem, const TMPXAttribute& aAttribute,
       
   503                     TGlxIdSpaceId aIdSpaceId, const TRect& aCroppingRect )
       
   504     {
       
   505     TRACER("CGlxVisualObject::AddZoomTileL");
       
   506     // Reserve space for new tile
       
   507     iZoomTiles.ReserveL( iZoomTiles.Count() + 1 );
       
   508 
       
   509     // Extract zoom level field from attribute ID
       
   510     TInt zoomLevel = GlxZoomedThumbnailZoomLevel( aAttribute.AttributeId() );
       
   511     TInt position = 0;
       
   512     // Lowest zoom level goes to highest position (front)
       
   513     while ( position < iZoomTiles.Count()
       
   514             && zoomLevel < iZoomTiles[position].iZoomLevel )
       
   515         {
       
   516         position++;
       
   517         }
       
   518 
       
   519     CAlfImageVisual* visual = CAlfImageVisual::AddNewL(
       
   520                             static_cast<CAlfControl&>( iMainVisual->Owner() ),
       
   521                             iMainVisual );
       
   522     CleanupStack::PushL(visual);
       
   523 
       
   524     // Set temporary anchor to reserve space in anchors array
       
   525     TInt ordinal = iMainVisual->ChildOrdinal( iMainVisual->Count() - 1 );
       
   526     User::LeaveIfError( iMainVisual->SetRelativeAnchorRect( ordinal,
       
   527             EAlfAnchorOriginLeft, EAlfAnchorOriginTop, TAlfRealPoint(),
       
   528             EAlfAnchorOriginLeft, EAlfAnchorOriginTop, TAlfRealPoint() ) );
       
   529 
       
   530     // Move new visual to correct position
       
   531     iMainVisual->Reorder(*visual, position + 1);   // Full image thumbnail is position 0
       
   532 
       
   533     TReal32 imageWidth = iDimensions.iWidth;
       
   534     TReal32 imageHeight = iDimensions.iHeight;
       
   535 
       
   536     TZoomTile tile;
       
   537     tile.iVisual = visual;
       
   538     tile.iAttributeId = aAttribute.AttributeId();
       
   539     tile.iZoomLevel = zoomLevel;
       
   540     tile.iTopLeft.iX = aCroppingRect.iTl.iX / imageWidth;
       
   541     tile.iTopLeft.iY = aCroppingRect.iTl.iY / imageHeight;
       
   542     tile.iBottomRight.iX = aCroppingRect.iBr.iX / imageWidth;
       
   543     tile.iBottomRight.iY = aCroppingRect.iBr.iY / imageHeight;
       
   544     // Shouldn't leave due to reservation above
       
   545     iZoomTiles.InsertL(tile, position);
       
   546     CleanupStack::Pop(visual);
       
   547 
       
   548     return position;
       
   549     }
       
   550 
       
   551 // ---------------------------------------------------------------------------
       
   552 // ReanchorZoomTiles
       
   553 // ---------------------------------------------------------------------------
       
   554 //    
       
   555 void CGlxVisualObject::ReanchorZoomTiles( TInt aFirstPosition )
       
   556     {
       
   557     TRACER("CGlxVisualObject::ReanchorZoomTiles");
       
   558     TInt count = iZoomTiles.Count();
       
   559     for ( TInt i = aFirstPosition; i < count; i++ )
       
   560         {
       
   561         TZoomTile& tile( iZoomTiles[i] );
       
   562         TInt ordinal = iMainVisual->ChildOrdinal( i + 1 );
       
   563 
       
   564         TInt error = iMainVisual->SetRelativeAnchorRect( ordinal,
       
   565             EAlfAnchorOriginLeft, EAlfAnchorOriginTop, tile.iTopLeft,
       
   566             EAlfAnchorOriginLeft, EAlfAnchorOriginTop, tile.iBottomRight );
       
   567         if ( KErrNone != error )
       
   568             {
       
   569             // Should never fail since space was reserved in the anchor array
       
   570             GLX_LOG_WARNING1( "Failed to update anchor, error %d", error );
       
   571             __ASSERT_DEBUG( EFalse, Panic( EGlxPanicUnhandledError ) );
       
   572             }
       
   573         }
       
   574     }
       
   575 
       
   576 // -----------------------------------------------------------------------------
       
   577 // AddIconL
       
   578 // -----------------------------------------------------------------------------
       
   579 //    
       
   580 void CGlxVisualObject::AddIconL( const CAlfTexture& aTexture, 
       
   581                         NGlxIconMgrDefs::TGlxIconPosition /*aIconPos*/, 
       
   582                         TBool /*aForeground*/, TBool /*aStretch*/, TInt /*aBorderMargin*/,
       
   583                                                 TReal32 /*aWidth*/, TReal32 /*aHeight*/ )
       
   584     {
       
   585     TRACER("CGlxVisualObject::AddIconL");
       
   586     //currently foreground and background visuals are not being used
       
   587     //the implications needs to be studied
       
   588     //background visual is used mainly to provide a background for small visual objects
       
   589     //foreground visual is used to supply specialised icons for clips
       
   590     
       
   591     
       
   592     // Set image for corrupted thumbnail
       
   593       SetImage(TAlfImage( aTexture ));
       
   594    
       
   595     }
       
   596 
       
   597 // -----------------------------------------------------------------------------
       
   598 // RemoveIcon
       
   599 // -----------------------------------------------------------------------------
       
   600 //    
       
   601 TBool CGlxVisualObject::RemoveIcon(  const CAlfTexture& aTexture )
       
   602     {
       
   603     TRACER("CGlxVisualObject::RemoveIcon");
       
   604     
       
   605    TInt visPos = FindExistingTexture( aTexture, ETrue );
       
   606     if( visPos != KErrNotFound )
       
   607         {       
       
   608         DoRemoveIcon( *iMainVisual, 
       
   609                             iForegroundIconAnchors, visPos );
       
   610         }
       
   611     else 
       
   612         {
       
   613         visPos = FindExistingTexture( aTexture, EFalse );        
       
   614         }
       
   615     
       
   616     return ( visPos != KErrNotFound );
       
   617     
       
   618     }
       
   619 
       
   620 // -----------------------------------------------------------------------------
       
   621 // SetIconVisibility
       
   622 // -----------------------------------------------------------------------------
       
   623 //        
       
   624 void CGlxVisualObject::SetIconVisibility( const CAlfTexture& aTexture, TBool aVisible )
       
   625     {
       
   626     TRACER("CGlxVisualObject::SetIconVisibility");
       
   627     // find texture (assume it's a foreground visual)
       
   628     TInt pos = FindExistingTexture( aTexture, ETrue );
       
   629     if( pos != KErrNotFound )
       
   630         {
       
   631         CAlfVisual& vis = iMainVisual->Visual( pos );
       
   632         
       
   633         if( aVisible )
       
   634             {
       
   635             vis.SetOpacity( TAlfTimedValue( 1.0, KGlxOpacityFadeDuration ) );
       
   636             }
       
   637         else
       
   638             {
       
   639             vis.SetOpacity( TAlfTimedValue( 0.0, KGlxOpacityFadeDuration ) );
       
   640             }
       
   641         }
       
   642     }
       
   643 
       
   644 // -----------------------------------------------------------------------------
       
   645 // Status
       
   646 // -----------------------------------------------------------------------------
       
   647 //
       
   648 CGlxVisualObject::TVisualStatus CGlxVisualObject::Status() const
       
   649     {
       
   650     TRACER("CGlxVisualObject::Status()");
       
   651     return iStatus;
       
   652     }
       
   653 
       
   654 // -----------------------------------------------------------------------------
       
   655 // SetStatus
       
   656 // -----------------------------------------------------------------------------
       
   657 //
       
   658 void CGlxVisualObject::SetStatus( TVisualStatus aStatus )
       
   659     {
       
   660     TRACER("CGlxVisualObject::SetStatus");
       
   661     iStatus = aStatus;
       
   662     }
       
   663 
       
   664 // -----------------------------------------------------------------------------
       
   665 // SetObserver
       
   666 // -----------------------------------------------------------------------------
       
   667 //
       
   668 TBool CGlxVisualObject::SetObserver( MGlxVisualObjectStatusObserver& aObserver )
       
   669     {
       
   670     TRACER("CGlxVisualObject::SetObserver");
       
   671     iObserver = &aObserver;
       
   672     return iImage.HasTexture();
       
   673     }
       
   674 
       
   675 // -----------------------------------------------------------------------------
       
   676 // TextureContentChangedL
       
   677 // -----------------------------------------------------------------------------
       
   678 //
       
   679 void CGlxVisualObject::TextureContentChangedL( TBool aHasContent, CAlfTexture* /*aNewTexture */)
       
   680     {
       
   681     TRACER("CGlxVisualObject::TextureContentChangedL");
       
   682     if ( iObserver )
       
   683         {
       
   684         iObserver->VisualStatusChangedL( *this, iIndex, aHasContent );
       
   685         }
       
   686     }
       
   687 
       
   688 // -----------------------------------------------------------------------------
       
   689 // SetAnchors
       
   690 // -----------------------------------------------------------------------------
       
   691 //
       
   692 void CGlxVisualObject::SetAnchors( TGlxIconAnchors& aAnchors, 
       
   693                         CAlfAnchorLayout& aLayout, TInt aPos, TBool aUseOffsets )
       
   694     {
       
   695     TRACER("CGlxVisualObject::SetAnchors");
       
   696     TAlfTimedPoint leftPoint = aAnchors.iTopLeftAnchor.iPosition;
       
   697     TAlfTimedPoint rightPoint = aAnchors.iBotRightAnchor.iPosition;
       
   698      
       
   699     if( aUseOffsets && 
       
   700         aAnchors.iTopLeftAnchor.iAnchorMetric == EAlfAnchorMetricRelativeToSize )
       
   701         {
       
   702         // update horizontal positions if there is a horizontal offset  
       
   703         if( aAnchors.iTopLeftAnchor.iAnchorHorizOrigin == EAlfAnchorOriginLeft )
       
   704             {
       
   705             leftPoint.iX.SetValueNow( leftPoint.iX.Target() + iHoriIconOffset );
       
   706             
       
   707             if( rightPoint.iX.Target() == 1.0)
       
   708                 {
       
   709                 rightPoint.iX.SetValueNow( rightPoint.iX.Target() - iHoriIconOffset );
       
   710                 }
       
   711             
       
   712             }
       
   713         else if ( aAnchors.iTopLeftAnchor.iAnchorHorizOrigin == EAlfAnchorOriginRight )
       
   714             {
       
   715             if( leftPoint.iX.Target() == -1.0)
       
   716                 {
       
   717                 leftPoint.iX.SetValueNow( leftPoint.iX.Target() + iHoriIconOffset );
       
   718                 }
       
   719                  
       
   720             rightPoint.iX.SetValueNow( rightPoint.iX.Target() - iHoriIconOffset );
       
   721             }
       
   722         else
       
   723             {
       
   724             
       
   725             }
       
   726         
       
   727         // update vertical positions if there is a vertical offset    
       
   728         if( aAnchors.iTopLeftAnchor.iAnchorVertiOrigin == EAlfAnchorOriginTop )
       
   729             {
       
   730             leftPoint.iY.SetValueNow( leftPoint.iY.Target() + iVertIconOffset );
       
   731             if( rightPoint.iY.Target() == 1.0)
       
   732                 {
       
   733                 rightPoint.iY.SetValueNow( rightPoint.iY.Target() - iVertIconOffset );
       
   734                 }
       
   735             }
       
   736         else if ( aAnchors.iTopLeftAnchor.iAnchorHorizOrigin == EAlfAnchorOriginBottom )
       
   737             {
       
   738             if( leftPoint.iY.Target() == -1.0)
       
   739                 {
       
   740                 leftPoint.iY.SetValueNow( leftPoint.iY.Target() + iVertIconOffset );
       
   741                 }
       
   742             rightPoint.iY.SetValueNow( rightPoint.iY.Target() - iVertIconOffset );
       
   743             }
       
   744         else
       
   745             {
       
   746             
       
   747             }               
       
   748         }
       
   749    
       
   750     
       
   751     aLayout.SetAnchor( EAlfAnchorTopLeft, aPos,
       
   752                     aAnchors.iTopLeftAnchor.iAnchorHorizOrigin, 
       
   753                     aAnchors.iTopLeftAnchor.iAnchorVertiOrigin,
       
   754                     aAnchors.iTopLeftAnchor.iAnchorMetric,
       
   755                     aAnchors.iTopLeftAnchor.iAnchorMetric,
       
   756                     leftPoint );
       
   757                     
       
   758     aLayout.SetAnchor( EAlfAnchorBottomRight, aPos,
       
   759                     aAnchors.iBotRightAnchor.iAnchorHorizOrigin, 
       
   760                     aAnchors.iBotRightAnchor.iAnchorVertiOrigin,
       
   761                     aAnchors.iBotRightAnchor.iAnchorMetric,
       
   762                     aAnchors.iBotRightAnchor.iAnchorMetric,
       
   763                     rightPoint );
       
   764                     
       
   765     aLayout.UpdateChildrenLayout();
       
   766     }
       
   767 
       
   768 // -----------------------------------------------------------------------------
       
   769 // GenerateAnchors
       
   770 // -----------------------------------------------------------------------------
       
   771 //    
       
   772 void CGlxVisualObject::GenerateAnchors( TGlxIconAnchors& aAnchors,
       
   773                                         const CAlfTexture& aTexture, 
       
   774                                     NGlxIconMgrDefs::TGlxIconPosition aIconPos, 
       
   775                                             TInt aBorderMargin, TBool aStretch, 
       
   776                                             TReal32 aWidth, TReal32 aHeight )
       
   777     {
       
   778     TRACER("CGlxVisualObject::GenerateAnchors");
       
   779     // top-left anchor
       
   780     TGlxAnchorDetails topLeftAnchor;
       
   781     TGlxAnchorDetails bottomRightAnchor;
       
   782     
       
   783     if( aStretch)
       
   784         {
       
   785         topLeftAnchor.iAnchorMetric = EAlfAnchorMetricRelativeToSize;
       
   786         bottomRightAnchor.iAnchorMetric = EAlfAnchorMetricRelativeToSize;
       
   787         }
       
   788      else
       
   789         {
       
   790         topLeftAnchor.iAnchorMetric = EAlfAnchorMetricAbsolute;
       
   791         bottomRightAnchor.iAnchorMetric = EAlfAnchorMetricAbsolute;
       
   792         }
       
   793         
       
   794     TInt textureWidth = aTexture.Size().iWidth + aBorderMargin;
       
   795     TInt textureHeight = aTexture.Size().iHeight + aBorderMargin;
       
   796    
       
   797     // 
       
   798     switch( aIconPos )
       
   799         {
       
   800         case NGlxIconMgrDefs::EGlxIconTopLeft:
       
   801             {
       
   802             topLeftAnchor.iAnchorHorizOrigin = EAlfAnchorOriginLeft;
       
   803             topLeftAnchor.iAnchorVertiOrigin = EAlfAnchorOriginTop;
       
   804             
       
   805             bottomRightAnchor.iAnchorHorizOrigin = EAlfAnchorOriginLeft;
       
   806             bottomRightAnchor.iAnchorVertiOrigin = EAlfAnchorOriginTop;
       
   807             
       
   808             if( aStretch )
       
   809                 {
       
   810                 topLeftAnchor.iPosition = TAlfTimedPoint( 0, 0 );
       
   811                 bottomRightAnchor.iPosition = TAlfTimedPoint( aWidth, aHeight );
       
   812                 }
       
   813             else
       
   814                 {
       
   815                 topLeftAnchor.iPosition = 
       
   816                         TAlfTimedPoint( aBorderMargin, aBorderMargin );
       
   817                 bottomRightAnchor.iPosition = 
       
   818                       TAlfTimedPoint( textureWidth,textureHeight);
       
   819                 }
       
   820             
       
   821             break;
       
   822             }
       
   823         case NGlxIconMgrDefs::EGlxIconTopRight:
       
   824             {
       
   825             topLeftAnchor.iAnchorHorizOrigin = EAlfAnchorOriginRight;
       
   826             topLeftAnchor.iAnchorVertiOrigin = EAlfAnchorOriginTop;
       
   827             
       
   828             bottomRightAnchor.iAnchorHorizOrigin = EAlfAnchorOriginRight;
       
   829             bottomRightAnchor.iAnchorVertiOrigin = EAlfAnchorOriginTop;
       
   830             
       
   831             if( aStretch )
       
   832                 {
       
   833                 topLeftAnchor.iPosition = TAlfTimedPoint( -aWidth, 0.0 );
       
   834                 bottomRightAnchor.iPosition = TAlfTimedPoint( 0.0, aHeight );
       
   835                 }
       
   836             else
       
   837                 {
       
   838                 topLeftAnchor.iPosition = 
       
   839                     TAlfTimedPoint( -textureWidth, aBorderMargin );
       
   840                 bottomRightAnchor.iPosition = 
       
   841                     TAlfTimedPoint( -aBorderMargin, textureHeight);
       
   842                 }            
       
   843             break;
       
   844             }
       
   845         case NGlxIconMgrDefs::EGlxIconBottomLeft:
       
   846             {
       
   847             topLeftAnchor.iAnchorHorizOrigin = EAlfAnchorOriginLeft;
       
   848             topLeftAnchor.iAnchorVertiOrigin = EAlfAnchorOriginBottom;
       
   849             
       
   850             bottomRightAnchor.iAnchorHorizOrigin = EAlfAnchorOriginLeft;
       
   851             bottomRightAnchor.iAnchorVertiOrigin = EAlfAnchorOriginBottom;
       
   852            
       
   853             if( aStretch)
       
   854                 {
       
   855                 topLeftAnchor.iPosition = TAlfTimedPoint( aWidth, -aHeight );
       
   856                 bottomRightAnchor.iPosition = TAlfTimedPoint( 0.0, 1.0 );
       
   857                 }
       
   858             else
       
   859                 {
       
   860                 topLeftAnchor.iPosition = 
       
   861                     TAlfTimedPoint( aBorderMargin, -textureHeight );
       
   862                 bottomRightAnchor.iPosition = 
       
   863                     TAlfTimedPoint( textureWidth, aBorderMargin );
       
   864                 }  
       
   865                 
       
   866             break;
       
   867             }
       
   868         case NGlxIconMgrDefs::EGlxIconBottomRight:
       
   869             {
       
   870             topLeftAnchor.iAnchorHorizOrigin = EAlfAnchorOriginRight;
       
   871             topLeftAnchor.iAnchorVertiOrigin = EAlfAnchorOriginBottom;
       
   872             
       
   873             bottomRightAnchor.iAnchorHorizOrigin = EAlfAnchorOriginRight;
       
   874             bottomRightAnchor.iAnchorVertiOrigin = EAlfAnchorOriginBottom;
       
   875                           
       
   876             if( aStretch)
       
   877                 {
       
   878                 topLeftAnchor.iPosition = TAlfTimedPoint( -aWidth, -aHeight );
       
   879                 bottomRightAnchor.iPosition = TAlfTimedPoint( 0.0, 0.0 );
       
   880                 }
       
   881             else
       
   882                 {
       
   883                 topLeftAnchor.iPosition = 
       
   884                     TAlfTimedPoint(  -textureWidth, -textureHeight );
       
   885                 bottomRightAnchor.iPosition =
       
   886                     TAlfTimedPoint( -aBorderMargin, -aBorderMargin );
       
   887                 }  
       
   888                 
       
   889             break;
       
   890             }
       
   891         case NGlxIconMgrDefs::EGlxIconCentred:
       
   892             {
       
   893             topLeftAnchor.iAnchorHorizOrigin = EAlfAnchorOriginHCenter;
       
   894             topLeftAnchor.iAnchorVertiOrigin = EAlfAnchorOriginVCenter;
       
   895             
       
   896             bottomRightAnchor.iAnchorHorizOrigin = EAlfAnchorOriginHCenter;
       
   897             bottomRightAnchor.iAnchorVertiOrigin = EAlfAnchorOriginVCenter;
       
   898             
       
   899             if( aStretch)
       
   900                 {
       
   901                 topLeftAnchor.iPosition = TAlfTimedPoint( -aWidth/2, -aHeight/2 );
       
   902                 bottomRightAnchor.iPosition = TAlfTimedPoint( aWidth/2, aHeight/2 );
       
   903                 }
       
   904             else
       
   905                 {
       
   906                 topLeftAnchor.iPosition = 
       
   907                     TAlfTimedPoint( -textureWidth/2, -textureHeight/2 );
       
   908                 bottomRightAnchor.iPosition = 
       
   909                     TAlfTimedPoint( textureWidth/2, textureHeight/2 );
       
   910                 } 
       
   911                 
       
   912             break;
       
   913             }
       
   914         default:
       
   915             {
       
   916             
       
   917             }
       
   918         };
       
   919 
       
   920     aAnchors.iTexture = &aTexture;
       
   921     aAnchors.iTopLeftAnchor = topLeftAnchor;
       
   922     aAnchors.iBotRightAnchor = bottomRightAnchor;
       
   923     }
       
   924 
       
   925 // -----------------------------------------------------------------------------
       
   926 // FindExistingTexture
       
   927 // -----------------------------------------------------------------------------
       
   928 // 
       
   929 TInt CGlxVisualObject::FindExistingTexture( const CAlfTexture& aTexture,
       
   930                                             TBool aForeground )
       
   931     {
       
   932     TRACER("CGlxVisualObject::FindExistingTexture");
       
   933     TGlxIconAnchors icon;
       
   934     icon.iTexture = &aTexture;
       
   935 
       
   936     return ( aForeground )
       
   937             ? iForegroundIconAnchors.Find( icon, TGlxIconAnchors::Match )
       
   938             : iBackgroundIconAnchors.Find( icon, TGlxIconAnchors::Match );
       
   939     }
       
   940 
       
   941 // -----------------------------------------------------------------------------
       
   942 // DoRemoveIcon
       
   943 // -----------------------------------------------------------------------------
       
   944 //    
       
   945 void CGlxVisualObject::DoRemoveIcon( CAlfAnchorLayout& aLayout, 
       
   946                         RArray<TGlxIconAnchors>& aAnchorsArray, TInt aPos )
       
   947     {
       
   948     TRACER("CGlxVisualObject::DoRemoveIcon");
       
   949     // First remove the icon visual
       
   950     if ( aPos < aLayout.Count() )
       
   951         {
       
   952         CAlfVisual* visual = &aLayout.Visual( aPos );
       
   953         visual->Owner().Remove( visual );
       
   954         delete visual;
       
   955         }
       
   956 
       
   957     // after an icon has been removed from layout the anchor for all icons with
       
   958     // positions in layout after that of removed icon will need to be updated
       
   959     // due to HUI issue.
       
   960     TInt count = aAnchorsArray.Count();
       
   961     
       
   962     if ( aPos < count )
       
   963         {
       
   964         // removed anchor information for icon that has been removed
       
   965         aAnchorsArray.Remove( aPos );
       
   966         
       
   967         count--;
       
   968         
       
   969         // reset anchors for remaining icons
       
   970         // only for icons with positions that were after 
       
   971         // removed icon
       
   972         for ( TInt i = aPos; i < count; i++ )
       
   973             {
       
   974             SetAnchors( aAnchorsArray[i], aLayout, i );
       
   975             }
       
   976         }
       
   977     }
       
   978 
       
   979 // -----------------------------------------------------------------------------
       
   980 // UpdateIconAnchors
       
   981 // -----------------------------------------------------------------------------
       
   982 //    
       
   983 void CGlxVisualObject::UpdateIconAnchors( const CAlfTexture& aTexture, TSize aVisSize )
       
   984     {
       
   985     TRACER("CGlxVisualObject::UpdateIconAnchors");
       
   986     TInt iconCount = iForegroundIconAnchors.Count();
       
   987     
       
   988     // only proceed if there are foreground icons
       
   989     if( iconCount )  
       
   990         {
       
   991         TSize textureSize = aTexture.Size();
       
   992         
       
   993         iVertIconOffset = 0.0;
       
   994         iHoriIconOffset = 0.0;
       
   995         
       
   996         TReal32 visWidth = ( TReal32 )aVisSize.iWidth;
       
   997         TReal32 visHeight = ( TReal32 )aVisSize.iHeight;
       
   998 
       
   999         TReal32 textWidth = ( TReal32 )textureSize.iWidth;
       
  1000         TReal32 textHeight = ( TReal32 )textureSize.iHeight;
       
  1001         
       
  1002         if( textWidth == 0 || textHeight == 0 )
       
  1003             {
       
  1004             return;
       
  1005             }
       
  1006         
       
  1007         // compare aspect ratios between visual and texture
       
  1008         // and calculate either horizontal or vertical offset
       
  1009         if( (visWidth * textHeight ) < ( textWidth * visHeight ) )
       
  1010             {
       
  1011             TInt dispHeight = textHeight * visWidth/textWidth; 
       
  1012             
       
  1013             iVertIconOffset = ( visHeight - dispHeight ) /  visHeight;
       
  1014             iVertIconOffset /= 2;
       
  1015             }
       
  1016         else
       
  1017             {
       
  1018             TInt dispWidth = textWidth * visHeight/textHeight;
       
  1019             
       
  1020             iHoriIconOffset = ( visWidth - dispWidth ) / visWidth;
       
  1021             iHoriIconOffset /= 2;
       
  1022             }
       
  1023         }
       
  1024     
       
  1025     // move anchor positon of foreground anchor layout
       
  1026     iVisual->SetRelativeAnchorRect( KGlxForegroundAnchorOrdinal, 
       
  1027                 EAlfAnchorOriginLeft, EAlfAnchorOriginTop, 
       
  1028                 TAlfRealPoint( iHoriIconOffset, iVertIconOffset),
       
  1029                 EAlfAnchorOriginRight, EAlfAnchorOriginBottom, 
       
  1030                 TAlfRealPoint( -iHoriIconOffset, - iVertIconOffset));  
       
  1031     }
       
  1032 
       
  1033 // ---------------------------------------------------------------------------
       
  1034 // TGlxIconAnchors::Match
       
  1035 // ---------------------------------------------------------------------------
       
  1036 //    
       
  1037 TBool CGlxVisualObject::TGlxIconAnchors::Match(
       
  1038                 const TGlxIconAnchors& aIcon1, const TGlxIconAnchors& aIcon2 )
       
  1039     {
       
  1040     TRACER("CGlxVisualObject::Match");
       
  1041     return ( aIcon1.iTexture == aIcon2.iTexture );
       
  1042     }
       
  1043     
       
  1044 void CGlxVisualObject::AddObserver( MGlxVisualObjectLayoutRefreshObserver* aObserver ) 
       
  1045     {
       
  1046     TRACER("CGlxVisualObject::AddObserver");
       
  1047     	__ASSERT_DEBUG(iObservers.Find(aObserver) == KErrNotFound, 
       
  1048 	                    Panic(EGlxPanicIllegalArgument)); // Already exists
       
  1049 	iObservers.Append(aObserver);
       
  1050     }
       
  1051     
       
  1052 void CGlxVisualObject::RemoveObserver( MGlxVisualObjectLayoutRefreshObserver* aObserver )
       
  1053     {
       
  1054     TRACER("CGlxVisualObject::RemoveObserver");
       
  1055     TInt i = iObservers.Find(aObserver);
       
  1056     if (i != KErrNotFound)
       
  1057         {
       
  1058         iObservers.Remove(i);
       
  1059         }
       
  1060     }
       
  1061     
       
  1062  
       
  1063