mpxplugins/viewplugins/views/collectionviewhg/src/mpxcollectionviewhgswitchbuffer.cpp
branchRCL_3
changeset 21 a1247965635c
equal deleted inserted replaced
18:c54d95799c80 21:a1247965635c
       
     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: Implements a container for buffer switch handling.
       
    15 *
       
    16 */
       
    17 
       
    18 
       
    19 #include "mpxcollectionviewhgswitchbuffer.h"
       
    20 
       
    21 #include <gulicon.h>
       
    22 
       
    23 #include <ganes/HgScroller.h>
       
    24 #include <ganes/HgVgMediaWall.h>
       
    25 #include <ganes/HgItem.h>
       
    26 #include <ganes/HgVgItem.h>
       
    27 
       
    28 // ----------------------------------------------------------------------------
       
    29 // Create a copy of the icons used from input
       
    30 // ----------------------------------------------------------------------------
       
    31 CMPXCollectionViewHgSwitchBuffer* CMPXCollectionViewHgSwitchBuffer::CreateBufferLC( CHgScroller& aScroller )
       
    32     {
       
    33     CMPXCollectionViewHgSwitchBuffer* buffer = new (ELeave) CMPXCollectionViewHgSwitchBuffer();
       
    34     CleanupStack::PushL(buffer);
       
    35 
       
    36     for(TInt i = 0; i < aScroller.ItemCount(); ++i)
       
    37         {
       
    38         CGulIcon* icon = aScroller.ItemL(i).Icon();
       
    39         if(icon)
       
    40             {
       
    41             buffer->AddToBufferL(*icon, i);
       
    42             }
       
    43         }
       
    44 
       
    45     return buffer;
       
    46     }
       
    47 
       
    48 // ----------------------------------------------------------------------------
       
    49 // Create a copy of the icons used from input
       
    50 // ----------------------------------------------------------------------------
       
    51 CMPXCollectionViewHgSwitchBuffer* CMPXCollectionViewHgSwitchBuffer::CreateBufferLC( CHgVgMediaWall& aMediaWall )
       
    52     {
       
    53     CMPXCollectionViewHgSwitchBuffer* buffer = new (ELeave) CMPXCollectionViewHgSwitchBuffer();
       
    54     CleanupStack::PushL(buffer);
       
    55 
       
    56     for(TInt i = 0; i < aMediaWall.ItemCount(); ++i)
       
    57         {
       
    58         CGulIcon* icon = aMediaWall.ItemL(i).Icon();
       
    59         if(icon)
       
    60             {
       
    61             buffer->AddToBufferL(*icon, i);
       
    62             }
       
    63         }
       
    64 
       
    65     return buffer;
       
    66     }
       
    67 
       
    68 // ----------------------------------------------------------------------------
       
    69 //
       
    70 // ----------------------------------------------------------------------------
       
    71 CMPXCollectionViewHgSwitchBuffer::~CMPXCollectionViewHgSwitchBuffer ()
       
    72     {
       
    73     iBuffer.ResetAndDestroy();
       
    74     }
       
    75 
       
    76 // ----------------------------------------------------------------------------
       
    77 // Provide mediawall with the data from buffer.
       
    78 // ----------------------------------------------------------------------------
       
    79 void CMPXCollectionViewHgSwitchBuffer::FillFromBufferL( CHgVgMediaWall& aMediaWall )
       
    80     {
       
    81     for(TInt i = 0; i < iBuffer.Count(); ++i)
       
    82         {
       
    83         CGulIcon* icon = iBuffer[i]->GetIcon();
       
    84         CleanupStack::PushL(icon);
       
    85         if(icon)
       
    86             aMediaWall.ItemL(iBuffer[i]->Index() + iOffset).SetIcon(icon);
       
    87 
       
    88         CleanupStack::Pop(icon);
       
    89         }
       
    90     }
       
    91 
       
    92 // ----------------------------------------------------------------------------
       
    93 //
       
    94 // ----------------------------------------------------------------------------
       
    95 void CMPXCollectionViewHgSwitchBuffer::FillFromBufferL( CHgScroller& aScroller, TSize aSize )
       
    96     {
       
    97     User::Leave(KErrNotSupported);
       
    98     }
       
    99 
       
   100 // ----------------------------------------------------------------------------
       
   101 // Offset to start filling.
       
   102 // ----------------------------------------------------------------------------
       
   103 void CMPXCollectionViewHgSwitchBuffer::SetIndexOffset( TInt aOffset )
       
   104     {
       
   105     iOffset = aOffset;
       
   106     }
       
   107 
       
   108 // ----------------------------------------------------------------------------
       
   109 // Add icon to the buffer.
       
   110 // ----------------------------------------------------------------------------
       
   111 void CMPXCollectionViewHgSwitchBuffer::AddToBufferL(CGulIcon& aIcon, TInt aIndex)
       
   112     {
       
   113     CGulIcon* newIcon = CGulIcon::NewL(aIcon.Bitmap(), aIcon.Mask());
       
   114     TBool isShared = aIcon.BitmapsOwnedExternally();
       
   115     aIcon.SetBitmapsOwnedExternally(ETrue);
       
   116     newIcon->SetBitmapsOwnedExternally(isShared);
       
   117 
       
   118     CleanupStack::PushL(newIcon);
       
   119     CBufferItem* item = new (ELeave) CBufferItem( newIcon, aIndex );
       
   120     iBuffer.AppendL(item);
       
   121     CleanupStack::Pop(newIcon);
       
   122     }
       
   123 
       
   124 // ----------------------------------------------------------------------------
       
   125 //
       
   126 // ----------------------------------------------------------------------------
       
   127 CMPXCollectionViewHgSwitchBuffer::CMPXCollectionViewHgSwitchBuffer ()
       
   128     {
       
   129 
       
   130     }