photosgallery/viewframework/views/cloudview/src/glxcloudviewcontrol.cpp
changeset 0 4e91876724a2
child 2 7d9067c6fcb1
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:    Cloud View control class 
       
    15  *
       
    16 */
       
    17 
       
    18 
       
    19 
       
    20 
       
    21 // INCLUDE FILES
       
    22 #include "glxcloudviewcontrol.h" //class header
       
    23 //AlfT headers
       
    24 
       
    25 #include <alf/alfanchorlayout.h> // For CAlfAnchorLayout 
       
    26 #include <alf/alfviewportlayout.h> // For CAlfViewPortLayout
       
    27 #include <touchfeedback.h>  // For MTouchFeedback
       
    28 #include <alf/alftextstyle.h>  // For CAlfTextStyle
       
    29 #include <alf/alftextvisual.h> // For CAlfTextVisual
       
    30 #include <alf/alftransformation.h>
       
    31 #include <alf/alfwidgetcontrol.h> // For CAlfWidgetControl
       
    32 #include <alf/alfroster.h> // For CalfRoster
       
    33 #include <alf/alfdisplay.h> // For CAlfDisplay
       
    34 #include <alf/ialfscrollbarmodel.h> // For alfScrollbar model
       
    35 #include <aknlayoutscalable_uiaccel.cdl.h>
       
    36 
       
    37 #include <glxuiutility.h>
       
    38 #include <glxgeneraluiutilities.h>
       
    39 #include <glxuistd.h>
       
    40 
       
    41 //AlfT
       
    42 #include <glxlog.h>			// For Logs
       
    43 #include <glxtracer.h>			// For Logs
       
    44 #include <glxattributecontext.h> //attribute context
       
    45 #include <mglxmedialist.h> //for medialist
       
    46 
       
    47 #include "glxcontainerinfobubble.h" //intelligent class for data of infobubble
       
    48 #include "glxcloudview.hrh"
       
    49 #include "mglxcloudviewmskobserver.h" // For Msk Observer
       
    50 #include "mglxenterkeyeventobserver.h" // For enterkey observer
       
    51 #include "mglxcloudviewlayoutobserver.h"
       
    52 
       
    53 //Constants
       
    54 const TInt KPrimaryFontSize = 21;
       
    55 //Font sizes
       
    56 const TInt KFontSmallest = 28;
       
    57 const TInt KFontSmaller = 32;
       
    58 const TInt KFontMedium = 36;
       
    59 const TInt KFontLarger = 40;
       
    60 const TInt KFontLargest = 44;
       
    61 const TInt KRowHeight = 72;
       
    62 const TInt KLeftMargin = 10;
       
    63 const TInt KNumMinRowSpace = 2;
       
    64 const TInt KColSpace = 20;
       
    65 const TInt KRightmargin = 20;
       
    66 const TInt KMinTagSize = 77;
       
    67 const TInt KTagScreenHeight = 460;
       
    68 const TInt KDragHoldTime = 500;
       
    69 
       
    70 
       
    71 // ---------------------------------------------------------------------------
       
    72 // Two-phased constructor.
       
    73 // ---------------------------------------------------------------------------
       
    74 // 
       
    75 CGlxCloudViewControl *CGlxCloudViewControl::NewL(CAlfDisplay& aDisplay,
       
    76         CAlfEnv &aEnv, MGlxMediaList& aMediaList, const TDesC& aEmptyText,
       
    77         MGlxCloudViewMskObserver& aObserver,MGlxEnterKeyEventObserver& aObserverEnterKeyEvent
       
    78         ,CAlfAnchorLayout *aAnchorLayout,MGlxCloudViewLayoutObserver& aLayoutObserver)
       
    79     {
       
    80     TRACER("GLX_CLOUD::CGlxCloudViewControl::NewL");
       
    81     CGlxCloudViewControl *self = CGlxCloudViewControl::NewLC (aDisplay, aEnv,
       
    82             aMediaList, aEmptyText,aObserver,aObserverEnterKeyEvent,aAnchorLayout,aLayoutObserver);
       
    83     CleanupStack::Pop (self);
       
    84     return self;
       
    85     }
       
    86 
       
    87 // ---------------------------------------------------------------------------
       
    88 // Two-phased constructor.
       
    89 // ---------------------------------------------------------------------------
       
    90 // 
       
    91 CGlxCloudViewControl *CGlxCloudViewControl::NewLC(CAlfDisplay& aDisplay,
       
    92         CAlfEnv &aEnv, MGlxMediaList& aMediaList, const TDesC& aEmptyText,
       
    93         MGlxCloudViewMskObserver& aObserver,MGlxEnterKeyEventObserver& aObserverEnterKeyEvent
       
    94         ,CAlfAnchorLayout *aAnchorLayout,MGlxCloudViewLayoutObserver& aLayoutObserver)
       
    95     {
       
    96     TRACER("GLX_CLOUD::CGlxCloudViewControl::NewLC");
       
    97     CGlxCloudViewControl *self = new(ELeave)CGlxCloudViewControl(aEnv,aMediaList,aObserver
       
    98             ,aObserverEnterKeyEvent,aLayoutObserver);
       
    99     CleanupStack::PushL (self);
       
   100     self->ConstructL (aEmptyText,aDisplay,aAnchorLayout);
       
   101     return self;
       
   102     }
       
   103 
       
   104 // ---------------------------------------------------------------------------
       
   105 // Default C++ Constructor
       
   106 // ---------------------------------------------------------------------------
       
   107 //
       
   108 
       
   109 CGlxCloudViewControl::CGlxCloudViewControl(CAlfEnv &aEnv, MGlxMediaList& aMediaList,
       
   110         MGlxCloudViewMskObserver& aObserver,MGlxEnterKeyEventObserver& aObserverEnterKeyEvent
       
   111         ,MGlxCloudViewLayoutObserver& aLayoutObserver):
       
   112         iEnv(aEnv),  iMediaList(aMediaList), iObserver(aObserver)
       
   113         ,iObserverEnterKeyEvent(aObserverEnterKeyEvent),iLayoutObserver(aLayoutObserver)
       
   114         {
       
   115         TRACER("GLX_CLOUD::CGlxCloudViewControl::CGlxCloudViewControl");
       
   116         //added for scrollbar widget implementation
       
   117         iScrollEventData.mChangedMask = 0;
       
   118         iScrollEventData.mViewStartPos = 0;
       
   119         iScrollEventData.mSpan = 0;
       
   120         iScrollEventData.mViewLength = 0;    
       
   121         }
       
   122 
       
   123 // ---------------------------------------------------------------------------
       
   124 //ConstructL()
       
   125 // ---------------------------------------------------------------------------
       
   126 //
       
   127 void CGlxCloudViewControl::ConstructL(const TDesC& aEmptyText,CAlfDisplay& aDisplay
       
   128         ,CAlfAnchorLayout *aAnchorLayout)
       
   129     {
       
   130     TRACER("GLX_CLOUD::CGlxCloudViewControl::ConstructL");
       
   131     iUiUtility = CGlxUiUtility::UtilityL ();
       
   132     CAlfControl::ConstructL(iEnv);
       
   133     BindDisplay (aDisplay);
       
   134     //Initializing data for cloud view display 
       
   135     iFocusRowIndex = 0; //initially focus row will be zero
       
   136 
       
   137     iEmptyText = aEmptyText.AllocL();
       
   138 
       
   139     TRect rect;
       
   140     AknLayoutUtils::LayoutMetricsRect (AknLayoutUtils::EMainPane, rect);
       
   141     iScreenHeight = rect.Height ();
       
   142     iParentLayout = CAlfLayout::AddNewL(*this, aAnchorLayout);                    
       
   143     iTagScreenWidth = rect.Width() - iScrollPaneHandle.iW - KRightmargin;
       
   144 
       
   145     if (GlxGeneralUiUtilities::IsLandscape())
       
   146         {	
       
   147         iTagScreenHeight = rect.Height();	
       
   148         }
       
   149     else 
       
   150         {
       
   151 
       
   152         iTagScreenHeight = KTagScreenHeight;
       
   153         }                                  
       
   154 
       
   155     iViewPortLayout = CAlfViewportLayout::AddNewL(*this, iParentLayout);      
       
   156     iLayout=CAlfAnchorLayout::AddNewL (*this,iViewPortLayout);
       
   157     iLayout->SetFlags ( EAlfVisualFlagLayoutUpdateNotification); //to get screen change notification
       
   158 
       
   159     iViewPortLayout->SetClipping(ETrue); 
       
   160 
       
   161     // Set the attribute context
       
   162     iAttributeContext = CGlxDefaultAttributeContext::NewL ();
       
   163     iAttributeContext->AddAttributeL (KMPXMediaGeneralTitle);
       
   164     iAttributeContext->AddAttributeL (KMPXMediaGeneralCount);
       
   165     iAttributeContext->SetRangeOffsets( 0, KMaxTInt / 2 );
       
   166     iMediaList.AddContextL ( iAttributeContext, KGlxFetchContextPriorityCloudView ); //highest one to use 0 or 1
       
   167     iMediaList.AddMediaListObserverL ( this); //make this control as medialist observer
       
   168 
       
   169     TInt listCount = iMediaList.Count();
       
   170     GLX_LOG_INFO1("GLX_CLOUD ::CGlxCloudViewControl::ConstructL MedialistCount  %d ",
       
   171             listCount);
       
   172     
       
   173     //Display Empty Cloud View if no tags exists and if the navigation is backwards
       
   174     //Since in backward navigation the callback HandlePopulatedL() does not come
       
   175     if ( listCount ==0 && (iUiUtility->ViewNavigationDirection ()== EGlxNavigationBackwards) ) 
       
   176         {
       
   177         DisplayEmptyCloudViewL();
       
   178         }
       
   179     else	//Setting focus on the 1 st Media List item
       
   180         {
       
   181         //get the attributes from Cache
       
   182         FetchAttributeFromCacheL();
       
   183 
       
   184         if ( iLabels.Count ()==listCount && iAttributeContext->RequestCountL (&iMediaList)==0)
       
   185             {
       
   186             //if we navigate in forward direction, first item should be highlighted.if we are navigating in
       
   187             // backwards direction, index is not necessarily zero, it will be restored.
       
   188             if ( iUiUtility->ViewNavigationDirection ()== EGlxNavigationForwards && iMediaList.Count ())
       
   189                 {
       
   190                 iMediaList.SetFocusL (NGlxListDefs::EAbsolute, 0);
       
   191                 }
       
   192             UpdateRowDataL ();
       
   193             }
       
   194         }
       
   195     //get touch feedback instance
       
   196     iTouchFeedback = MTouchFeedback::Instance(); 
       
   197     }
       
   198 
       
   199 
       
   200 // ---------------------------------------------------------------------------
       
   201 //VisualLayoutUpdated()
       
   202 // ---------------------------------------------------------------------------
       
   203 //
       
   204 void CGlxCloudViewControl::VisualLayoutUpdated(CAlfVisual &/* aVisual*/)
       
   205     {
       
   206     TRACER("GLX_CLOUD::CGlxCloudViewControl::VisualLayoutUpdated");
       
   207     TRect rect;
       
   208     AknLayoutUtils::LayoutMetricsRect (AknLayoutUtils::EMainPane, rect);
       
   209     if ( (rect.Width() != iTagScreenWidth) && ( rect.Height () != iScreenHeight))
       
   210         {
       
   211         //set the new screen dimensions
       
   212         UpdateLayoutL();
       
   213         }
       
   214     }
       
   215 
       
   216 // --------------------------------------------------------------------------- 
       
   217 // Destructor
       
   218 // --------------------------------------------------------------------------- 
       
   219 //
       
   220 CGlxCloudViewControl::~CGlxCloudViewControl()
       
   221 
       
   222     {
       
   223     TRACER("GLX_CLOUD::CGlxCloudViewControl::~CGlxCloudViewControl");
       
   224     iCloudInfo.Close ();
       
   225     iLabels.Close();
       
   226     iMediaList.RemoveContext (iAttributeContext);
       
   227     iMediaList.RemoveMediaListObserver (this);
       
   228     delete iAttributeContext;
       
   229     /*if ( iBubbleContainer )
       
   230 		{
       
   231 		iBubbleContainer->SetHost (NULL);
       
   232 		delete iBubbleContainer;
       
   233 		}*/
       
   234 
       
   235     if ( iUiUtility )
       
   236         {
       
   237         iUiUtility->Close ();
       
   238         }	
       
   239     delete iEmptyText;
       
   240     }
       
   241 
       
   242 // --------------------------------------------------------------------------- 
       
   243 // LayoutVisibleRows()
       
   244 // --------------------------------------------------------------------------- 
       
   245 //
       
   246 TInt CGlxCloudViewControl::LayoutVisibleRows(TPoint aStartPoint,TInt aRowStartIndex
       
   247         , TInt aRowEndIndex)
       
   248     {
       
   249     TRACER("GLX_CLOUD::CGlxCloudViewControl::DrawRow");
       
   250     TSize vsize;
       
   251     TPoint tl, br;
       
   252     tl = aStartPoint;
       
   253     br.iY = tl.iY + KRowHeight;
       
   254     //drawing in reverse for arabic hebrew support
       
   255     if ( GlxGeneralUiUtilities::LayoutIsMirrored ())
       
   256         {
       
   257         br.iX =  aStartPoint.iX; 
       
   258         const TInt KMaxScreenWidth = iTagScreenWidth - iScrollPaneHandle.iW;
       
   259         //Set the positions of tags in a row.
       
   260         for (TInt j = aRowStartIndex; j <= aRowEndIndex; j++)
       
   261             {
       
   262             vsize = iLabels[j]->TextExtents ();
       
   263             if ( vsize.iWidth < KMinTagSize )
       
   264                 {
       
   265                 vsize.iWidth = KMinTagSize;
       
   266                 }
       
   267             //If the size of the tag is more than the screen size then wrap it
       
   268             if (vsize.iWidth > KMaxScreenWidth)
       
   269                 {
       
   270                 TAlfRealSize tagSize( KMaxScreenWidth, br.iY );
       
   271                 iLabels[j]->SetWrapping( CAlfTextVisual::ELineWrapTruncate );
       
   272                 vsize = iLabels[j]->TextExtents ();
       
   273                 tl.iX -= aStartPoint.iX;
       
   274                 tl.iY = aStartPoint.iY;
       
   275                 br.iX = tagSize.iWidth;              
       
   276                 }
       
   277             else
       
   278                 {
       
   279                 tl.iX -= (vsize.iWidth + KColSpace);
       
   280                 }
       
   281             //Set the anchor points for the tags 	            	        
       
   282             iLayout->SetAnchor (EAlfAnchorTopLeft, iLayoutIndex,
       
   283                     EAlfAnchorOriginLeft, EAlfAnchorOriginTop,
       
   284                     EAlfAnchorMetricAbsolute, EAlfAnchorMetricAbsolute,
       
   285                     TAlfTimedPoint (tl.iX, tl.iY));
       
   286             iLayout->SetAnchor (EAlfAnchorBottomRight, iLayoutIndex,
       
   287                     EAlfAnchorOriginLeft, EAlfAnchorOriginTop,
       
   288                     EAlfAnchorMetricAbsolute, EAlfAnchorMetricAbsolute,
       
   289                     TAlfTimedPoint (br.iX, br.iY));
       
   290             br.iX -= (vsize.iWidth + KColSpace); 
       
   291             iLayoutIndex += 1;
       
   292             }
       
   293 
       
   294         }
       
   295     else
       
   296         {
       
   297         const TInt KMaxScreenWidth = iTagScreenWidth - iScrollPaneHandle.iW;
       
   298         for (TInt j = aRowStartIndex; j <= aRowEndIndex; j++)
       
   299             {
       
   300             vsize = iLabels[j]->TextExtents ();
       
   301             if( vsize.iWidth < KMinTagSize )
       
   302                 {
       
   303                 vsize.iWidth = KMinTagSize;
       
   304                 }
       
   305             if (vsize.iWidth > KMaxScreenWidth)
       
   306                 {
       
   307                 TAlfRealSize tagSize( KMaxScreenWidth, br.iY );
       
   308                 TAlfRealPoint startPos( aStartPoint.iX, 0 );
       
   309                 iLabels[j]->SetWrapping( CAlfTextVisual::ELineWrapTruncate );
       
   310                 tl.iX = aStartPoint.iX;
       
   311                 tl.iY = aStartPoint.iY;
       
   312                 br.iX = tagSize.iWidth;
       
   313                 }
       
   314             else
       
   315                 {
       
   316                 br.iX += vsize.iWidth + KColSpace;
       
   317                 }
       
   318             iLayout->SetAnchor (EAlfAnchorTopLeft, iLayoutIndex,
       
   319                     EAlfAnchorOriginLeft, EAlfAnchorOriginTop,
       
   320                     EAlfAnchorMetricAbsolute, EAlfAnchorMetricAbsolute,
       
   321                     TAlfTimedPoint (tl.iX, tl.iY));
       
   322             iLayout->SetAnchor (EAlfAnchorBottomRight, iLayoutIndex,
       
   323                     EAlfAnchorOriginLeft, EAlfAnchorOriginTop,
       
   324                     EAlfAnchorMetricAbsolute, EAlfAnchorMetricAbsolute,
       
   325                     TAlfTimedPoint (br.iX, br.iY));
       
   326             tl.iX = br.iX;
       
   327             iLayoutIndex += 1;
       
   328             }
       
   329         }
       
   330     return 0;
       
   331     }
       
   332 
       
   333 
       
   334 
       
   335 
       
   336 // --------------------------------------------------------------------------- 
       
   337 // LayoutVisibleArea()
       
   338 // 
       
   339 // ---------------------------------------------------------------------------
       
   340 void CGlxCloudViewControl::LayoutVisibleArea()
       
   341     {
       
   342     //screen height for boundary check:how many rows fit in.
       
   343     //find out how many rows can fit in.
       
   344     //add upper and lower margin spacing 5 pixels
       
   345 
       
   346     //draw the row on screens
       
   347     TPoint startpoint;
       
   348     // arabic hebrew change
       
   349     //If the layout is arabic hebrew then start positioning of tags from end
       
   350     if ( GlxGeneralUiUtilities::LayoutIsMirrored ())
       
   351         {
       
   352         startpoint.iX = iTagScreenWidth - KRightmargin;        
       
   353         }
       
   354 
       
   355     //else start from biginning
       
   356     else
       
   357         {
       
   358         startpoint.iX = KLeftMargin;
       
   359         }
       
   360         startpoint.iY = KNumMinRowSpace;
       
   361     //associate the active visuals with anchor layout
       
   362     GLX_LOG_INFO("GLX_CLOUD ::CGlxCloudViewControl::::LayoutVisibleArea Layout reset");
       
   363     GLX_LOG_INFO1("GLX_CLOUD ::CGlxCloudViewControl::::LayoutVisibleArea layout Count after reset  %d ", iLayout->Count ());
       
   364     GLX_LOG_INFO1("GLX_CLOUD ::CGlxCloudViewControl::::LayoutVisibleArea iCloudInfo[0].iStartIndex  %d ", iCloudInfo[0].iStartIndex);
       
   365     TInt endindex = iCloudInfo.Count()-1;
       
   366 
       
   367     for (TInt j = iCloudInfo[0].iStartIndex; j <=iCloudInfo[endindex].iEndIndex; j++)
       
   368         {
       
   369         GLX_LOG_INFO("GLX_CLOUD ::CGlxCloudViewControl::::FindEndRowIndex Entering layout append");
       
   370 
       
   371 
       
   372         TAlfTimedValue opacity;
       
   373         opacity.SetValueNow(1.0); // immediate change
       
   374         iLabels[j]->SetOpacity(opacity);
       
   375         }
       
   376 
       
   377     GLX_LOG_INFO("GLX_CLOUD ::CGlxCloudViewControl::::LayoutVisibleArea Exiting layout append");
       
   378     iLayoutIndex = 0;
       
   379     GLX_LOG_INFO1("GLX_CLOUD ::CGlxCloudViewControl::::LayoutVisibleArea layout Count realloc  %d ", iLayout->Count ());
       
   380     for (TInt j = 0; j <= iEndRowIndex; j++)
       
   381         {
       
   382         GLX_LOG_INFO1("GLX_CLOUD ::CGlxCloudViewControl::::LayoutVisibleArea Drawing row started  %d ", j);
       
   383         LayoutVisibleRows (startpoint,iCloudInfo[j].iStartIndex, 
       
   384                 iCloudInfo[j].iEndIndex);
       
   385         startpoint.iY += KRowHeight + KNumMinRowSpace;		
       
   386         }
       
   387     TInt totalHeight = 0;
       
   388     for (TInt j = 0; j <= iCloudInfo.Count()-1; j++)
       
   389         {
       
   390         totalHeight+=KRowHeight;
       
   391         totalHeight+=KNumMinRowSpace;
       
   392         }
       
   393 
       
   394     //Set the virtual size of viewport to the total size of anchor.	
       
   395     if( totalHeight > iTagScreenHeight )
       
   396         {
       
   397         iViewPortLayout->SetVirtualSize(TAlfRealSize(iTagScreenWidth,totalHeight ),0); 
       
   398         iViewPortVirtualSize.iHeight = totalHeight;
       
   399         }
       
   400     else
       
   401         {
       
   402         iViewPortLayout->SetVirtualSize(TAlfRealSize(iTagScreenWidth,iTagScreenHeight ),0);
       
   403         iViewPortVirtualSize.iHeight = iTagScreenHeight;
       
   404         }    
       
   405     iViewPortVirtualSize.iWidth = iTagScreenWidth;
       
   406 
       
   407     iViewPortLayout->SetViewportSize(TAlfRealSize(iTagScreenWidth,iTagScreenHeight), 0);
       
   408     iViewPortLayout->SetSize(TAlfRealSize(iTagScreenWidth,iTagScreenHeight), 0);
       
   409     iViewPortSize.iWidth = iTagScreenWidth;
       
   410     iViewPortSize.iHeight = iTagScreenHeight;	
       
   411     iViewPortLayout->SetViewportPos(TAlfRealPoint(0, 0),1000);
       
   412 
       
   413     iViewPortPosition.iX =0;
       
   414     iViewPortPosition.iY =0;
       
   415 
       
   416     iScrollEventData.mSpan = iViewPortVirtualSize.iHeight ;
       
   417     iScrollEventData.mViewLength = iViewPortSize.iHeight;
       
   418     if(iScrollBarWidget)
       
   419         {
       
   420         ((IAlfScrollBarModel *)(iScrollBarWidget->model()))->changeData(iScrollEventData.mSpan,
       
   421                 iScrollEventData.mViewLength,
       
   422                 0);
       
   423         DisplayScrollBar();
       
   424         }
       
   425     //constructing the bubblecontainer
       
   426     CreateBubleContainer();   	
       
   427 
       
   428     iLayout->UpdateChildrenLayout (); //update layout
       
   429 
       
   430     HandleLayoutFocusChange ();
       
   431     
       
   432     MoveDownIfRequired();
       
   433     }
       
   434 
       
   435 
       
   436 // --------------------------------------------------------------------------- 
       
   437 // OfferEventL()
       
   438 // --------------------------------------------------------------------------- 
       
   439 //
       
   440 TBool CGlxCloudViewControl::OfferEventL(const TAlfEvent &aEvent)
       
   441     {   TRACER("GLX_CLOUD:: CGlxCloudViewControl::OfferEventL");
       
   442 
       
   443     //check if key inputs needs handling
       
   444     TBool consumed = EFalse;
       
   445     if ( ( iLabels.Count () == 0 ) ) 
       
   446         {
       
   447         GLX_LOG_INFO( "GLX_CLOUD ::CGlxCloudViewControl::offerkeyeventL no key press returning  ");
       
   448         return EFalse; //return as no futher processing is required
       
   449         }
       
   450 
       
   451     if ( aEvent.IsKeyEvent ()&& aEvent.Code() == EEventKey )
       
   452         {
       
   453         switch (aEvent.KeyEvent().iCode)            
       
   454             {	
       
   455             //@ EABI-7R7FRU Fute failure: Tag views enter key has no functionality.
       
   456             case EKeyEnter :
       
   457             case EKeyDevice3:
       
   458                 {
       
   459                 iObserverEnterKeyEvent.HandleEnterKeyEventL( (TInt)EAknCmdOpen );
       
   460                 consumed= ETrue;
       
   461                 }
       
   462                 break;
       
   463             case EKeyUpArrow:
       
   464                 {             
       
   465                 if(iCloudInfo.Count() >1 )
       
   466                     {
       
   467                     HandleKeyUpL ();
       
   468                     consumed = ETrue;
       
   469                     iFocusRowIndex = RowNumber (iMediaList.FocusIndex ()); 
       
   470 
       
   471                     MoveUpIfRequired();                   
       
   472                     }
       
   473                 }
       
   474                 break;
       
   475 
       
   476             case EKeyDownArrow:
       
   477                 {              
       
   478                 if(iCloudInfo.Count() >1 )
       
   479                     {
       
   480                     HandleKeyDownL ();
       
   481                     consumed = ETrue;
       
   482                     iFocusRowIndex = RowNumber (iMediaList.FocusIndex ());
       
   483 
       
   484                     MoveDownIfRequired();                                 
       
   485                     }                  
       
   486                 }
       
   487                 break;
       
   488 
       
   489             case EKeyLeftArrow:
       
   490             case EKeyPrevious:
       
   491                 {
       
   492                 // arabic hebrew change
       
   493                 if ( GlxGeneralUiUtilities::LayoutIsMirrored () )
       
   494                     {
       
   495                     if ( iMediaList.FocusIndex() == iMediaList.Count() - 1 )
       
   496                         {
       
   497                         iMediaList.SetFocusL (NGlxListDefs::EAbsolute, 0);
       
   498                         }
       
   499                     else
       
   500                         {
       
   501                         iMediaList.SetFocusL (NGlxListDefs::EAbsolute,
       
   502                                 iMediaList.FocusIndex ()+ 1);
       
   503                         }
       
   504                     iScrollDirection = 0;
       
   505                     }
       
   506                 else
       
   507                     {
       
   508                     if ( iMediaList.FocusIndex ()== 0 )
       
   509                         {
       
   510                         iMediaList.SetFocusL (NGlxListDefs::EAbsolute,
       
   511                                 iMediaList.Count() - 1 );
       
   512                         }
       
   513                     else
       
   514                         {
       
   515                         iMediaList.SetFocusL (NGlxListDefs::EAbsolute,
       
   516                                 iMediaList.FocusIndex ()- 1);
       
   517                         }
       
   518                     iScrollDirection = 1;
       
   519                     }
       
   520                 consumed = ETrue;
       
   521                 TInt focusRowIndex = RowNumber (iMediaList.FocusIndex ());
       
   522                 if(iFocusRowIndex != focusRowIndex)
       
   523                     {
       
   524                     iFocusRowIndex = focusRowIndex; 
       
   525                     if( iScrollDirection == 0 )
       
   526                         {                      
       
   527                         MoveDownIfRequired();
       
   528                         }
       
   529                     else
       
   530                         {
       
   531                         MoveUpIfRequired();
       
   532                         }
       
   533                     }                
       
   534                 }
       
   535 
       
   536                 break;
       
   537 
       
   538             case EKeyRightArrow:
       
   539             case EKeyNext:
       
   540                 {               
       
   541                 // arabic hebrew change
       
   542                 if ( GlxGeneralUiUtilities::LayoutIsMirrored () )
       
   543                     {
       
   544                     if ( iMediaList.FocusIndex ()== 0 )
       
   545                         {
       
   546                         iMediaList.SetFocusL (NGlxListDefs::EAbsolute,
       
   547                                 iMediaList.Count() - 1 );
       
   548                         }
       
   549                     else
       
   550                         {
       
   551                         iMediaList.SetFocusL (NGlxListDefs::EAbsolute,
       
   552                                 iMediaList.FocusIndex ()- 1);
       
   553                         }
       
   554                     iScrollDirection = 1;
       
   555                     }
       
   556                 else
       
   557                     {
       
   558                     if ( iMediaList.FocusIndex ()== iMediaList.Count() - 1 )
       
   559                         {
       
   560                         iMediaList.SetFocusL (NGlxListDefs::EAbsolute, 0);
       
   561                         }
       
   562                     else
       
   563                         {
       
   564                         iMediaList.SetFocusL (NGlxListDefs::EAbsolute,
       
   565                                 iMediaList.FocusIndex ()+ 1);
       
   566                         }
       
   567                     iScrollDirection = 0;
       
   568                     }
       
   569                 TInt focusRowIndex = RowNumber (iMediaList.FocusIndex ());
       
   570 
       
   571                 if( iFocusRowIndex != focusRowIndex )
       
   572                     {
       
   573                     iFocusRowIndex = focusRowIndex;  
       
   574                     if( iScrollDirection == 1 )
       
   575                         {                           
       
   576                         MoveUpIfRequired();                               
       
   577                         }
       
   578                     else
       
   579                         {                           
       
   580                         MoveDownIfRequired();                               
       
   581                         }
       
   582                     }
       
   583                 }
       
   584                 consumed = ETrue;
       
   585                 break;
       
   586 
       
   587             default:
       
   588                 break;
       
   589             }
       
   590         }
       
   591 
       
   592     if(aEvent.IsPointerEvent() )
       
   593         {
       
   594         //if its a pointer event
       
   595         consumed = HandlePointerEventL(aEvent);
       
   596         }
       
   597     else if( aEvent.IsCustomEvent() )
       
   598         {
       
   599         if(aEvent.CustomParameter() == ECustomEventFocusDragScroll)
       
   600             {
       
   601             //dragging down
       
   602             if( iIsDragging == 1 )
       
   603                 {
       
   604                 if(iFocusRowIndex!=iCloudInfo.Count()-1)
       
   605                     {
       
   606                     SetRelativeFocusL(iFocusRowIndex+1);
       
   607                     iFocusRowIndex = RowNumber (iMediaList.FocusIndex ()); 
       
   608                     // iScrollDirection = 0;               
       
   609                     MoveDownIfRequired();  
       
   610                     }
       
   611                 }
       
   612             //dragging up
       
   613             else if(iIsDragging == 2)
       
   614                 {
       
   615                 if(iFocusRowIndex!=0)
       
   616                     {
       
   617                     SetRelativeFocusL(iFocusRowIndex-1);
       
   618                     iFocusRowIndex = RowNumber (iMediaList.FocusIndex ()); 
       
   619                     // iScrollDirection = 0;               
       
   620                     MoveUpIfRequired();  
       
   621                     }
       
   622                 }
       
   623             }
       
   624         consumed = EFalse;
       
   625         }
       
   626     return consumed;
       
   627     }
       
   628 
       
   629 // --------------------------------------------------------------------------- 
       
   630 // HandleKeyUp()
       
   631 // --------------------------------------------------------------------------- 
       
   632 //
       
   633 void CGlxCloudViewControl::HandleKeyUpL()
       
   634     {
       
   635     TRACER("GLX_CLOUD:: CGlxCloudViewControl::HandleKeyUpL");
       
   636 
       
   637     //If the first item is focused and if we are navigating upwards,then set the focus to last element.
       
   638     if( iFocusRowIndex ==  0 )
       
   639         {               
       
   640         iMediaList.SetFocusL (NGlxListDefs::EAbsolute,
       
   641                 iMediaList.Count() - 1);
       
   642         }
       
   643 
       
   644     //else set the focus to the item which is in the previous row,that overlaps with midpoint of the 
       
   645     //focused item.
       
   646     else
       
   647         { 
       
   648         TInt prevrownum = iFocusRowIndex - 1;
       
   649         SetRelativeFocusL(prevrownum);		
       
   650         }
       
   651 
       
   652     iScrollDirection = 1;
       
   653     }
       
   654 
       
   655 
       
   656 // --------------------------------------------------------------------------- 
       
   657 // HandleKeyDown()
       
   658 // --------------------------------------------------------------------------- 
       
   659 //
       
   660 void CGlxCloudViewControl::HandleKeyDownL()
       
   661     {
       
   662     TRACER("GLX_CLOUD:: CGlxCloudViewControl::HandleKeyDownL");
       
   663 
       
   664     // If the last item is focused and if we are navigating downwards,then set the
       
   665     // focus to first element.
       
   666     if( iFocusRowIndex == iCloudInfo.Count()-1 )
       
   667         {   
       
   668         iMediaList.SetFocusL (NGlxListDefs::EAbsolute,
       
   669                 0); 
       
   670         }
       
   671 
       
   672     //else set the focus to the item which is in the next row,that overlaps with midpoint of the 
       
   673     //focused item.     
       
   674     else
       
   675         { 
       
   676         TInt nextrownum = iFocusRowIndex + 1;            
       
   677         SetRelativeFocusL(nextrownum);	       
       
   678         }
       
   679 
       
   680     iScrollDirection = 0;
       
   681     }
       
   682 
       
   683 // --------------------------------------------------------------------------- 
       
   684 // HandleLayoutFocusChange()
       
   685 // --------------------------------------------------------------------------- 
       
   686 //
       
   687 void CGlxCloudViewControl::HandleLayoutFocusChange()
       
   688     {
       
   689     TRACER("GLX_CLOUD::CGlxCloudViewControl::HandleLayoutFocusChange");
       
   690 
       
   691     if ( iLabels.Count()-1 >= iMediaList.FocusIndex())
       
   692         {
       
   693         //to highlight focused element 
       
   694         SetFocusColor(); 
       
   695         //CalculateBubleMidPoint ();   
       
   696         }
       
   697     }
       
   698 
       
   699 
       
   700 // --------------------------------------------------------------------------- 
       
   701 // FocusUpdate()
       
   702 // --------------------------------------------------------------------------- 
       
   703 //
       
   704 void CGlxCloudViewControl::FocusUpdate()
       
   705     {
       
   706     TRACER("GLX_CLOUD::CGlxCloudViewControl::FocusUpdate");
       
   707     GLX_LOG_INFO1("GLX_CLOUD ::CGlxCloudViewControl::FocusUpdate HighLighted RowNum  %d ",iFocusRowIndex);
       
   708     GLX_LOG_INFO1("GLX_CLOUD ::CGlxCloudViewControl::FocusUpdate End RowNumn %d ",iCloudInfo.Count()-1);
       
   709     iFocusRowIndex = RowNumber (iMediaList.FocusIndex ());
       
   710     iEndRowIndex = iCloudInfo.Count()-1;
       
   711     LayoutVisibleArea();
       
   712     }
       
   713 
       
   714 
       
   715 // --------------------------------------------------------------------------- 
       
   716 // ResetLayout()
       
   717 // --------------------------------------------------------------------------- 
       
   718 //
       
   719 void CGlxCloudViewControl::UpdateLayout()
       
   720     {
       
   721     TRACER("GLX_CLOUD::CGlxCloudViewControl::UpdateLayout()");
       
   722     iCloudInfo.Close (); //row information is reset
       
   723     for(TInt i = 0;i<iLabels.Count();i++)
       
   724         {
       
   725         iLabels[i]->RemoveAndDestroyAllD(); // removes from control
       
   726         iLabels[i] = NULL;
       
   727         }        
       
   728     iLabels.Reset();
       
   729     }
       
   730 
       
   731 
       
   732 // --------------------------------------------------------------------------- 
       
   733 // GetRownum()
       
   734 // --------------------------------------------------------------------------- 
       
   735 //
       
   736 TInt CGlxCloudViewControl::RowNumber(TInt aItemIndex) const
       
   737 {
       
   738 
       
   739 TRACER("GLX_CLOUD::CGlxCloudViewControl::GetRownum");
       
   740 //Get the rownumber of the given item index.
       
   741 TInt i;
       
   742 for (i = 0; i < iCloudInfo.Count (); i++)
       
   743     {
       
   744     if ( (aItemIndex >= iCloudInfo[i].iStartIndex) && (aItemIndex <=iCloudInfo[i].iEndIndex))
       
   745         break;
       
   746     }
       
   747 return i;
       
   748 
       
   749 }
       
   750 
       
   751 // --------------------------------------------------------------------------- 
       
   752 // FetchAttributeFromCacheL()
       
   753 // --------------------------------------------------------------------------- 
       
   754 //
       
   755 void CGlxCloudViewControl::FetchAttributeFromCacheL()
       
   756     {
       
   757     TRACER("GLX_CLOUD::CGlxCloudViewControl::FetchAttributeFromCacheL");
       
   758     GLX_LOG_INFO("GLX_CLOUD ::CGlxCloudViewControl::FetchAttributeFromCache MediaList already filled" );
       
   759     //enable msk as the medialist is populated
       
   760     //iObserver.HandleMskChangedL (ETrue);
       
   761     iLayoutObserver.HandleLayoutChanged();
       
   762     if ( iLabels.Count ()==0)
       
   763         {
       
   764         for (TInt i=0; i<iMediaList.Count();i++)
       
   765             {
       
   766             CAlfTextVisual *tempVisual= NULL;
       
   767             tempVisual = CAlfTextVisual::AddNewL (*this,iLayout);
       
   768             iLabels.InsertL (tempVisual, i); //appending the visual text   /
       
   769             TAlfTimedValue opacity;
       
   770             opacity.SetValueNow(0.0);
       
   771             iLabels[i]->SetOpacity(opacity);
       
   772             }
       
   773         }
       
   774 
       
   775     for (TInt i=0; i<iMediaList.Count(); i++)
       
   776         {
       
   777         GLX_LOG_INFO1("GLX_CLOUD::Fetching title for item %d", i );
       
   778         // get the media item
       
   779         TGlxMedia item = iMediaList.Item( i );
       
   780         // get the title and set it to the text visual
       
   781         iLabels[i]->SetTextL( item.Title() );
       
   782         }
       
   783     }
       
   784 
       
   785 
       
   786 //medialist Observers
       
   787 
       
   788 // ---------------------------------------------------------------------------
       
   789 // HandleItemAddedL().
       
   790 // ---------------------------------------------------------------------------
       
   791 //
       
   792 void CGlxCloudViewControl::HandleItemAddedL(TInt aStartIndex, TInt aEndIndex,
       
   793         MGlxMediaList* aList)
       
   794     {
       
   795     TRACER("GLX_CLOUD::CGlxCloudViewControl::HandleItemAddedL");
       
   796     GLX_LOG_INFO1("GLX_CLOUD::CGlxCloudViewControl::HandleItemAddedL start index  %d ", aStartIndex);
       
   797     GLX_LOG_INFO1("GLX_CLOUD::CGlxCloudViewControl::HandleItemAddedL end index  %d ", aEndIndex);
       
   798     GLX_LOG_INFO1("GLX_CLOUD::CGlxCloudViewControl::HandleItemAddedL  media list count  %d ", aList->Count());
       
   799     GLX_LOG_INFO1("GLX_CLOUD::CGlxCloudViewControl::HandleItemAddedL  attribute request count %d ", iAttributeContext->RequestCountL(aList));
       
   800 
       
   801     if ( iEmptyString )
       
   802         {
       
   803         // remove the empty string so it does not fool around in animations
       
   804         iEmptyString->RemoveAndDestroyAllD(); // removes from control
       
   805         iEmptyString = NULL;
       
   806         }
       
   807     //The new item has been added and it is required to cleanup the visuals and info bubble
       
   808     //for the existing tags(if any).	
       
   809     //when a filter is applied attribute request count is zero but medialist count in non zero
       
   810     if (iAttributeContext->RequestCountL(aList) == 0 )
       
   811         {
       
   812         //reset the layout and get the items from cache
       
   813         UpdateLayout(); //remove all the visuals from the layout.layout is empty now.
       
   814         iCloudInfo.Close (); //row information is reset
       
   815         //get the new array contents from cache.no need to reset the array as the number
       
   816         //of items in array will remain same.
       
   817         FetchAttributeFromCacheL();
       
   818         UpdateRowDataL (); //updates the row data and reassigns font sizes and draw the layout on screen.
       
   819         }
       
   820 
       
   821     }
       
   822 
       
   823 
       
   824 // ---------------------------------------------------------------------------
       
   825 // HandleMediaL().
       
   826 // ---------------------------------------------------------------------------
       
   827 //
       
   828 void CGlxCloudViewControl::HandleMediaL(TInt /*aListIndex*/, MGlxMediaList* /*aList*/)
       
   829     {
       
   830     TRACER("GLX_CLOUD::CGlxCloudViewControl::HandleMediaL");
       
   831     }
       
   832 
       
   833 // ---------------------------------------------------------------------------
       
   834 // HandleItemRemovedL().
       
   835 // ---------------------------------------------------------------------------
       
   836 //
       
   837 void CGlxCloudViewControl::HandleItemRemovedL(TInt aStartIndex, TInt aEndIndex,
       
   838         MGlxMediaList* aList)
       
   839     {
       
   840     TRACER("GLX_CLOUD::CGlxCloudViewControl::HandleItemRemovedL");
       
   841     GLX_LOG_INFO1("GLX_CLOUD::CGlxCloudViewControl::HandleItemRemovedL Start RowNum  %d ", aStartIndex);
       
   842     GLX_LOG_INFO1("GLX_CLOUD::CGlxCloudViewControl::HandleItemRemovedL iCloudCount  %d ", aEndIndex);
       
   843     GLX_LOG_INFO1("GLX_CLOUD::CGlxCloudViewControl::HandleItemRemovedL  media list count  %d ", aList->Count());
       
   844 
       
   845     //when a filter is applied attribute request count is zero but medialist count in non zero
       
   846     if (iAttributeContext->RequestCountL(aList) == 0 )
       
   847         {
       
   848         //reset the layout and get the items from cache
       
   849         UpdateLayout(); //remove all the visuals from the layout.layout is empty now.       
       
   850         if( aList->Count() > 0 )
       
   851             {
       
   852             //get the new array contents from cache.no need to reset the array as the number
       
   853             //of items in array will remain same.
       
   854             FetchAttributeFromCacheL();
       
   855             UpdateRowDataL (); //updates the row data and reassigns font sizes and draw the layout on screen.
       
   856             }
       
   857         else
       
   858             {
       
   859             DisplayEmptyCloudViewL();
       
   860             }
       
   861         }
       
   862     }
       
   863 
       
   864 // ---------------------------------------------------------------------------
       
   865 // HandleItemModifiedL().
       
   866 // ---------------------------------------------------------------------------
       
   867 //
       
   868 void CGlxCloudViewControl::HandleItemModifiedL(
       
   869         const RArray<TInt>& /*aItemIndexes*/, MGlxMediaList* /*aList*/)
       
   870     {
       
   871     TRACER("GLX_CLOUD::CGlxCloudViewControl::HandleItemModifiedL");
       
   872     }
       
   873 
       
   874 // ---------------------------------------------------------------------------
       
   875 // HandleAttributesAvailableL().
       
   876 // ---------------------------------------------------------------------------
       
   877 //
       
   878 void CGlxCloudViewControl::HandleAttributesAvailableL(TInt aItemIndex,
       
   879         const RArray<TMPXAttribute>& aAttributes, MGlxMediaList* aList)
       
   880     {
       
   881     TRACER("GLX_CLOUD::CGlxCloudViewControl::HandleAttributesAvailableL");
       
   882     GLX_LOG_INFO1("GLX_CLOUD ::CGlxCloudViewControl::HandleAttributesAvailableL  iLabels.Count()  %d ",iLabels.Count());
       
   883     TInt attCount = aAttributes.Count ();
       
   884     GLX_LOG_INFO1("GLX_CLOUD ::CGlxCloudViewControl::HandleAttributesAvailableL  count: %d ",attCount);
       
   885     GLX_LOG_INFO1("GLX_CLOUD ::CGlxCloudViewControl::HandleAttributesAvailableL  Item Index: %d ", aItemIndex);
       
   886 
       
   887     TBool relevantAttribute = EFalse;
       
   888     for ( TInt i = 0 ; i < attCount ; i++ )
       
   889         {
       
   890         if ( ( aAttributes[i] == KMPXMediaGeneralTitle ) 
       
   891                 || ( aAttributes[i] == KMPXMediaGeneralCount ) )
       
   892             {
       
   893             relevantAttribute = ETrue;
       
   894             }
       
   895         }
       
   896     //if the title array has been loaded completely and request count for attribute context becomes 
       
   897     //zero update the row data and arrange layout
       
   898     if ( ( iAttributeContext->RequestCountL(aList) ==0 ) 
       
   899             && ( aList->Count() != 0) && relevantAttribute )
       
   900         {
       
   901         //get the new array contents from cache.no need to reset the array as the number
       
   902         //of items in array will remain same.
       
   903         UpdateLayout(); //remove all the visuals from the layout.layout is empty now.        
       
   904         FetchAttributeFromCacheL();
       
   905         //if we navigate in forward direction, first item should be highlighted.if we are navigating in
       
   906         // backwards direction, index is not necessarily zero, it will be restored.
       
   907         if ( iUiUtility->ViewNavigationDirection ()== EGlxNavigationForwards && iMediaList.Count ())
       
   908             {
       
   909             iMediaList.SetFocusL (NGlxListDefs::EAbsolute, 0);
       
   910             }
       
   911         //generate row structures and draw rows on screen
       
   912         UpdateRowDataL ();
       
   913         }
       
   914     }
       
   915 
       
   916 // ---------------------------------------------------------------------------
       
   917 // HandleFocusChangedL().
       
   918 // ---------------------------------------------------------------------------
       
   919 //
       
   920 void CGlxCloudViewControl::HandleFocusChangedL(
       
   921         NGlxListDefs::TFocusChangeType /*aType*/, TInt aNewIndex,
       
   922         TInt aOldIndex, MGlxMediaList* /*aList*/)
       
   923     {
       
   924     TRACER("GLX_CLOUD::CGlxCloudViewControl::HandleFocusChangedL");
       
   925     GLX_LOG_INFO1("GLX_CLOUD ::CGlxCloudViewControl::HandleFocusChangedL aNewIndex %d ", aNewIndex);
       
   926     GLX_LOG_INFO1("GLX_CLOUD ::CGlxCloudViewControl::HandleFocusChangedL aOldIndex %d ",aOldIndex);
       
   927     if ( (aOldIndex >= 0) && (iLabels.Count()-1 >= aOldIndex) )
       
   928         {      		  
       
   929         //Reset the focused color
       
   930         iLabels[aOldIndex]->SetColor (KAknsIIDQsnTextColors,
       
   931                 EAknsCIQsnTextColorsCG6);
       
   932         HandleLayoutFocusChange ();
       
   933         }
       
   934     }
       
   935 
       
   936 // ---------------------------------------------------------------------------
       
   937 // HandleItemSelectedL().
       
   938 // ---------------------------------------------------------------------------
       
   939 //
       
   940 void CGlxCloudViewControl::HandleItemSelectedL(TInt /*aIndex*/,
       
   941         TBool /*aSelected*/, MGlxMediaList* /*aList*/)
       
   942     {
       
   943     TRACER("GLX_CLOUD::CGlxCloudViewControl::HandleItemSelectedL");
       
   944     }
       
   945 
       
   946 // ---------------------------------------------------------------------------
       
   947 // HandleMessageL().
       
   948 // ---------------------------------------------------------------------------
       
   949 //
       
   950 void CGlxCloudViewControl::HandleMessageL(const CMPXMessage& /*aMessage*/,
       
   951         MGlxMediaList* /*aList*/)
       
   952     {
       
   953     TRACER("GLX_CLOUD::CGlxCloudViewControl::HandleMessageL");
       
   954     }
       
   955 
       
   956 // ---------------------------------------------------------------------------
       
   957 // HandlePopulatedL().
       
   958 // ---------------------------------------------------------------------------
       
   959 //
       
   960 void CGlxCloudViewControl::HandlePopulatedL(MGlxMediaList* /*aList*/)
       
   961     {
       
   962     //Display the Empty clould view only when we get this call back.
       
   963     // At this stage the medialist will be populated.    
       
   964     if(iMediaList.Count()<=0)
       
   965         {
       
   966         DisplayEmptyCloudViewL();
       
   967         }
       
   968     }
       
   969 
       
   970 // ---------------------------------------------------------------------------
       
   971 //UpdateRowDataL()
       
   972 // ---------------------------------------------------------------------------
       
   973 //
       
   974 void CGlxCloudViewControl::UpdateRowDataL()
       
   975 
       
   976     {
       
   977     TRACER("GLX_CLOUD::CGlxCloudViewControl::UpdateRowData()");
       
   978 
       
   979     TInt rowStartingTagIndex = 0;
       
   980     TInt lastRowStartTagIndex = 0;
       
   981     TInt currentTagIndex = 0;
       
   982     TSize currentTagSize(0, 0);
       
   983     TGlxCloudInfo cloudInfo;
       
   984     TInt rowHeight = 0;
       
   985     TInt rowWidth = 0;
       
   986     TInt itemUsageCount = 0;
       
   987     const TInt KLabelsCount = iLabels.Count();
       
   988     iScrollPaneHandle = AknLayoutScalable_UiAccel::aa_scroll_pane(0).LayoutLine();
       
   989     const TInt KMaxScreenWidth = iTagScreenWidth - KRightmargin - iScrollPaneHandle.iW;
       
   990 
       
   991     iCloudInfo.Close (); //delete existing structures for orintation change
       
   992 
       
   993 
       
   994     //Setting the Font Styles based on association counts
       
   995     //Finding the maximum value of image association
       
   996     //Determining the Font(Style) for each visual
       
   997     TInt maxCount= MaxUsageCount (); //Maximum Association count 
       
   998     GLX_LOG_INFO1("GLX_CLOUD ::CGlxCloudViewControl::UpdateRowData  mediaCount %d ", maxCount);
       
   999     GLX_LOG_INFO1("GLX_CLOUD ::CGlxCloudViewControl::UpdateRowData  iLabels.Count()  %d ",iLabels.Count());
       
  1000     if ( 0 == maxCount )
       
  1001         {
       
  1002         return; //do not proceed if max count is zero
       
  1003         }
       
  1004 
       
  1005     for (TInt i = 0; i < KLabelsCount; i++)
       
  1006         {
       
  1007         TInt percent( 0 );
       
  1008         GLX_LOG_INFO1("GLX_CLOUD ::CGlxCloudViewControl::UpdateRowData  Item Counter value  %d ",i);
       
  1009         itemUsageCount = UsageCount(i);
       
  1010         GLX_LOG_INFO1("GLX_CLOUD ::CGlxCloudViewControl::UpdateRowData  Usage Count  %d ", itemUsageCount);
       
  1011         percent = ((itemUsageCount * 99)/ maxCount);
       
  1012         GLX_LOG_INFO1("GLX_CLOUD ::CGlxCloudViewControl::UpdateRowData  iLabels.Count()  %d ",iLabels.Count());
       
  1013 
       
  1014         // percent is between 0 and 99 so divide it by 20 to make it 0, 1, 2, 3 or 4
       
  1015         // as there is 5 different font sizes
       
  1016         SetPropertiesL( i, TInt( percent / 20 ) );
       
  1017         }
       
  1018 
       
  1019     while ( currentTagIndex < KLabelsCount )
       
  1020         {
       
  1021         //Determining text size of visual.
       
  1022         currentTagSize = iLabels[currentTagIndex]->TextExtents();
       
  1023         if( currentTagSize .iWidth < KMinTagSize )
       
  1024             {
       
  1025             currentTagSize.iWidth = KMinTagSize;
       
  1026             }
       
  1027         GLX_LOG_INFO1("GLX_CLOUD ::CGlxCloudViewControl::UpdateRowData  currentTagSize.iHeight %d ", currentTagSize.iHeight);
       
  1028 
       
  1029         // The current row's height will always be the largest height of all the tags in that row
       
  1030         if ( currentTagSize.iHeight > rowHeight )
       
  1031             {
       
  1032             rowHeight = currentTagSize.iHeight;
       
  1033             }
       
  1034 
       
  1035         // Current row width will be progressively incremented to fit as many tags as possible
       
  1036         rowWidth += currentTagSize.iWidth + 10;
       
  1037         GLX_LOG_INFO1("GLX_CLOUD ::CGlxCloudViewControl::UpdateRowData   currentTagSize.iWidth %d ", currentTagSize.iWidth);
       
  1038         GLX_LOG_INFO1("GLX_CLOUD ::CGlxCloudViewControl::UpdateRowData  rowWidth %d ", rowWidth);
       
  1039 
       
  1040         // If the tag size crosses the Screen Size, Then wrap it.
       
  1041         if ( currentTagSize.iWidth > KMaxScreenWidth )
       
  1042             {
       
  1043             lastRowStartTagIndex = ((rowStartingTagIndex == currentTagIndex)?rowStartingTagIndex : currentTagIndex-1);
       
  1044             AppendToCloudArrayL( cloudInfo,/* rowHeight,*/  rowStartingTagIndex, lastRowStartTagIndex );
       
  1045             // Reset row height and row width for the next line
       
  1046             rowHeight = 0;
       
  1047             rowWidth = 0;
       
  1048             if (lastRowStartTagIndex != currentTagIndex-1 )
       
  1049                 {
       
  1050                 currentTagIndex++; 
       
  1051                 }
       
  1052             rowStartingTagIndex = currentTagIndex;
       
  1053             lastRowStartTagIndex++;
       
  1054             }
       
  1055 
       
  1056         // If the current row's width is overflowing the screen width
       
  1057         // then we must fit the current visual into the next row.
       
  1058         // Do that check now and adjust accordingly.
       
  1059         // Fix for EAHN-7BZD78 is to exclude the gap value between the row's tags from the logic
       
  1060         else if ( rowWidth - 10 > KMaxScreenWidth )
       
  1061             {
       
  1062             GLX_LOG_INFO("GLX_CLOUD :: CGlxCloudViewControl::UpdateRowData Row added");
       
  1063             lastRowStartTagIndex = currentTagIndex - 1;
       
  1064             AppendToCloudArrayL( cloudInfo,rowStartingTagIndex, lastRowStartTagIndex );
       
  1065             lastRowStartTagIndex++;
       
  1066             // Reset row height and row width for the next line
       
  1067             rowHeight = 0;
       
  1068             rowWidth = 0;
       
  1069             rowStartingTagIndex = currentTagIndex;
       
  1070             GLX_LOG_INFO1("GLX_CLOUD ::CGlxCloudViewControl::UpdateRowData  iCloudInfo.count  %d ", iCloudInfo.Count());
       
  1071             } 
       
  1072 
       
  1073         // need to work with next tag only if current tag has been taken care of
       
  1074         if ( rowWidth )
       
  1075             {
       
  1076             currentTagIndex++; 
       
  1077             }
       
  1078 
       
  1079         } // while ( currentTagIndex < KLabelsCount )
       
  1080 
       
  1081     if( lastRowStartTagIndex < KLabelsCount)
       
  1082         {
       
  1083         AppendToCloudArrayL( cloudInfo,lastRowStartTagIndex, KLabelsCount - 1 );
       
  1084         }
       
  1085 
       
  1086     GLX_LOG_INFO1("GLX_CLOUD ::CGlxCloudViewControl::UpdateRowData  iCloudInfo.count loop exit  %d ", iCloudInfo.Count());
       
  1087     FocusUpdate (); //Start screen drawing 
       
  1088 
       
  1089     iEndRowIndex = iCloudInfo.Count()-1;
       
  1090     }
       
  1091 
       
  1092 // ---------------------------------------------------------------------------
       
  1093 // SetProperties
       
  1094 // ---------------------------------------------------------------------------
       
  1095 //
       
  1096 void CGlxCloudViewControl::SetPropertiesL(TInt aIndex, TInt aScale)
       
  1097     {
       
  1098     TRACER("GLX_CLOUD::CGlxCloudViewControl::SetProperties()");
       
  1099     GLX_LOG_INFO1("GLX_CLOUD ::CGlxCloudViewControl::SetProperties layout Count after reset  %d ", iLayout->Count());
       
  1100     //Retrieving theme color
       
  1101 
       
  1102     TAlfTimedValue scale(0);
       
  1103     TRAP_IGNORE(iLabels[aIndex]->EnableTransformationL());   
       
  1104     TAlfTimedValue opacity;
       
  1105     opacity.SetStyle (EAlfTimedValueStyleLinear);
       
  1106     opacity.SetValueNow(0.0);
       
  1107     iLabels[aIndex]->SetOpacity(opacity);
       
  1108     iLabels[aIndex]->SetAlign (EAlfAlignHLocale, EAlfAlignVBottom); //setting allignment
       
  1109     iLabels[aIndex]->SetColor (KAknsIIDQsnTextColors,EAknsCIQsnTextColorsCG6);
       
  1110     //custom style cod
       
  1111     TInt typefaceSecondaryStyleId = CGlxCloudViewControl::Env().TextStyleManager().CreatePlatformTextStyleL(
       
  1112             EAknLogicalFontSecondaryFont,EAlfTextStyleNormal);
       
  1113     TInt typefacePrimaryStyleId = CGlxCloudViewControl::Env().TextStyleManager().CreatePlatformTextStyleL(
       
  1114             EAknLogicalFontPrimaryFont,EAlfTextStyleNormal);
       
  1115     CAlfTextStyle* stylePrimary = CGlxCloudViewControl::Env().TextStyleManager().TextStyle(
       
  1116             typefacePrimaryStyleId);
       
  1117     CAlfTextStyle* styleSecondary = CGlxCloudViewControl::Env().TextStyleManager().TextStyle(
       
  1118             typefaceSecondaryStyleId);
       
  1119     switch (aScale)
       
  1120         {
       
  1121         case 0:
       
  1122             {
       
  1123             styleSecondary->SetTextSizeInPixels (KFontSmallest, 0);
       
  1124             iLabels[aIndex]->SetTextStyle (typefaceSecondaryStyleId);
       
  1125             TAlfTimedValue opacity;
       
  1126             opacity.SetValueNow(0.0);
       
  1127             iLabels[aIndex]->SetOpacity(opacity);
       
  1128             scale.SetTarget(1, 1000);
       
  1129             break;
       
  1130             }
       
  1131         case 1:
       
  1132             {
       
  1133             styleSecondary->SetTextSizeInPixels (KFontSmaller, 0);
       
  1134             iLabels[aIndex]->SetTextStyle (typefaceSecondaryStyleId);
       
  1135             scale.SetTarget(1, 1200);
       
  1136             TAlfTimedValue opacity;
       
  1137             opacity.SetValueNow(0.0);
       
  1138             iLabels[aIndex]->SetOpacity(opacity);
       
  1139             break;
       
  1140             }
       
  1141         case 2:
       
  1142             {
       
  1143             stylePrimary->SetTextSizeInPixels (KFontMedium, 0);
       
  1144             iLabels[aIndex]->SetTextStyle (typefacePrimaryStyleId);
       
  1145             scale.SetTarget(1, 1500);
       
  1146             TAlfTimedValue opacity;
       
  1147             opacity.SetValueNow(0.0);
       
  1148             iLabels[aIndex]->SetOpacity(opacity);
       
  1149             break;
       
  1150             }
       
  1151         case 3:
       
  1152             {
       
  1153             stylePrimary->SetTextSizeInPixels (KFontLarger, 0);
       
  1154             iLabels[aIndex]->SetTextStyle (typefacePrimaryStyleId);
       
  1155             scale.SetTarget(1, 1800);
       
  1156             TAlfTimedValue opacity;
       
  1157             opacity.SetValueNow(0.0);
       
  1158             iLabels[aIndex]->SetOpacity(opacity);
       
  1159             break;
       
  1160             }
       
  1161         case 4:
       
  1162             {
       
  1163             stylePrimary->SetTextSizeInPixels (KFontLargest, 0);
       
  1164             iLabels[aIndex]->SetTextStyle (typefacePrimaryStyleId);
       
  1165             scale.SetTarget(1, 2200);
       
  1166             TAlfTimedValue opacity;
       
  1167             opacity.SetValueNow(0.0);
       
  1168             iLabels[aIndex]->SetOpacity(opacity);
       
  1169             break;
       
  1170             }
       
  1171         }
       
  1172 
       
  1173     iLabels[aIndex]->Transformation().Scale (scale, scale);
       
  1174     GLX_LOG_INFO1("GLX_CLOUD ::CGlxCloudViewControl::SetProperties layout Count after reset  %d ", iLayout->Count());
       
  1175     }
       
  1176 
       
  1177 // ---------------------------------------------------------------------------
       
  1178 // DisplayEmptyCloudView
       
  1179 // ---------------------------------------------------------------------------
       
  1180 // 
       
  1181 void CGlxCloudViewControl::DisplayEmptyCloudViewL()
       
  1182     {
       
  1183     TRACER("GLX_CLOUD::CGlxCloudViewControl::DisplayEmptyCloudView");
       
  1184     if( !iEmptyString )
       
  1185         {
       
  1186         iEmptyString = CAlfTextVisual::AddNewL ( *this, iViewPortLayout );
       
  1187         iViewPortLayout->SetSize(TAlfRealSize(iTagScreenWidth,iTagScreenHeight), 0);
       
  1188         iLayout->UpdateChildrenLayout (); //update layout
       
  1189         }
       
  1190     //Setting text color to default theme text color.
       
  1191     iEmptyString->SetColor(KAknsIIDQsnTextColors, EAknsCIQsnTextColorsCG6);
       
  1192     iEmptyString->SetTextStyle(iUiUtility->TextStyleIdL(EAknLogicalFontPrimaryFont
       
  1193             ,KPrimaryFontSize));
       
  1194     iEmptyString->SetWrapping( CAlfTextVisual::ELineWrapBreak );
       
  1195     iEmptyString->SetTextL (iEmptyText->Des());
       
  1196     // no shadow wanted for the text
       
  1197     iEmptyString->EnableShadow( EFalse );
       
  1198 
       
  1199     //disable msk
       
  1200     iLayoutObserver.HandleLayoutChanged();
       
  1201     //iObserver.HandleMskChangedL (EFalse);
       
  1202     iScrollEventData.mSpan = 0;
       
  1203     iScrollEventData.mViewLength = 0;
       
  1204     DisplayScrollBar();
       
  1205     GLX_LOG_INFO1("GLX_CLOUD ::CGlxCloudViewControl::DisplayEmptyCloudView layout Count after reset  %d ", iLayout->Count());
       
  1206     }
       
  1207 
       
  1208 // ---------------------------------------------------------------------------
       
  1209 // MaxUsageCount()
       
  1210 // ---------------------------------------------------------------------------
       
  1211 //
       
  1212 TInt CGlxCloudViewControl::MaxUsageCount()
       
  1213     {
       
  1214     TRACER("GLX_CLOUD::CGlxCloudViewControl::GetMaxusageCount");
       
  1215     TInt maxValue=0;
       
  1216     const TInt mediaListSize = iMediaList.Count();
       
  1217     GLX_LOG_INFO1("GLX_CLOUD ::CGlxCloudViewControl::GetMaxusageCount MediaList Count %d ",iMediaList.Count());
       
  1218     for (TInt k=0; k < mediaListSize; k++)
       
  1219         {
       
  1220         TInt count = UsageCount (k);
       
  1221         if ( count > maxValue)
       
  1222             {
       
  1223             GLX_LOG_INFO("GLX_CLOUD :: CGlxCloudViewControl::GetMaxusageCount  in the loop");
       
  1224             maxValue=count;
       
  1225             }
       
  1226         }
       
  1227     return maxValue;
       
  1228     }
       
  1229 
       
  1230 // ---------------------------------------------------------------------------
       
  1231 // UsageCount()
       
  1232 // ---------------------------------------------------------------------------
       
  1233 //
       
  1234 TInt CGlxCloudViewControl::UsageCount(TInt aIndex)
       
  1235     {
       
  1236     TRACER("GLX_CLOUD::CGlxCloudViewControl::UsageCount");
       
  1237     GLX_LOG_INFO1("GLX_CLOUD :: CGlxCloudViewControl::UsageCount Item index: %d ", aIndex);
       
  1238     TMPXAttribute attrCount(KMPXMediaGeneralCount); // get the attrCount
       
  1239     TInt usageCount =0;
       
  1240     const CGlxMedia* media = iMediaList.Item(aIndex).Properties ();
       
  1241     if ( media)
       
  1242         {
       
  1243         if ( media->IsSupported (attrCount))
       
  1244             {
       
  1245             usageCount = media->ValueTObject<TInt> (attrCount);
       
  1246             GLX_LOG_INFO1("GLX_CLOUD :: CGlxCloudViewControl::UsageCount Count: %d ", usageCount);
       
  1247             }
       
  1248         }
       
  1249     return usageCount;
       
  1250     }
       
  1251 
       
  1252 // ---------------------------------------------------------------------------
       
  1253 // SetFocusColor()
       
  1254 // ---------------------------------------------------------------------------
       
  1255 //
       
  1256 void CGlxCloudViewControl::AppendToCloudArrayL( 
       
  1257         TGlxCloudInfo& aCloudInfo,const TInt& aStartIndex, const TInt& aEndIndex )
       
  1258     {
       
  1259     TRACER("GLX_CLOUD::CGlxCloudViewControl::AppendToCloudArrayL");
       
  1260     aCloudInfo.iStartIndex = aStartIndex;
       
  1261     aCloudInfo.iEndIndex = aEndIndex; 
       
  1262     iCloudInfo.AppendL( aCloudInfo );
       
  1263     }
       
  1264 
       
  1265 // ---------------------------------------------------------------------------
       
  1266 // SetFocusColor()
       
  1267 // ---------------------------------------------------------------------------
       
  1268 //
       
  1269 void  CGlxCloudViewControl::SetFocusColor()
       
  1270     {
       
  1271     iLabels[iMediaList.FocusIndex()]->SetColor (KAknsIIDQsnHighlightColors ,EAknsCIQsnHighlightColorsCG3); 
       
  1272     }
       
  1273 
       
  1274 
       
  1275 // ---------------------------------------------------------------------------
       
  1276 // SetBubleMidPoint()
       
  1277 // ---------------------------------------------------------------------------
       
  1278 //
       
  1279 void  CGlxCloudViewControl::SetBubleMidPoint(TPoint& aMidPoint)
       
  1280     {
       
  1281     TRACER("GLX_CLOUD::CGlxCloudViewControl::SetBubleMidPoint");
       
  1282     //Substract the viewport position so as to set the buble at the right position on the screen     
       
  1283     aMidPoint.iX-=iViewPortPosition.iX;
       
  1284     aMidPoint.iY-=iViewPortPosition.iY;
       
  1285     }
       
  1286 
       
  1287 // ---------------------------------------------------------------------------
       
  1288 // CreateBubleContainer()
       
  1289 // ---------------------------------------------------------------------------
       
  1290 //   
       
  1291 void CGlxCloudViewControl::CreateBubleContainer()
       
  1292     {   
       
  1293     /* if ( !iBubbleContainer)
       
  1294         {
       
  1295         TRAPD(err1,
       
  1296             {
       
  1297             iBubbleContainer = CGlxContainerInfoBubble::NewL (&iMediaList,
       
  1298             CGlxCloudViewControl::Env (), *this);
       
  1299             });
       
  1300             ;
       
  1301         if ( err1!= KErrNone)
       
  1302             {
       
  1303             GLX_LOG_INFO1("GLX_CLOUD::CGlxCloudViewControl::LayoutVisibleArea - Error (%d)", err1);
       
  1304             }
       
  1305         iBubbleContainer->SetHost (this);
       
  1306         }*/
       
  1307     }
       
  1308 
       
  1309 // ---------------------------------------------------------------------------
       
  1310 // MoveUpIfRequired()
       
  1311 // ---------------------------------------------------------------------------
       
  1312 //
       
  1313 void CGlxCloudViewControl::MoveUpIfRequired()
       
  1314     {
       
  1315     TRACER("GLX_CLOUD::CGlxCloudViewControl::MoveUpIfRequired");
       
  1316     //get the focused item's position
       
  1317     TPoint point;
       
  1318     iLayout->ChildPos(iMediaList.FocusIndex(),point);
       
  1319     TSize size;
       
  1320     iLayout->ChildSize(iMediaList.FocusIndex(),size);
       
  1321     TInt focus = iMediaList.FocusIndex();
       
  1322     TInt rownumber = RowNumber(focus);
       
  1323     //if the focused item is not visible then move the viewport
       
  1324     if(point.iY < iViewPortPosition.iY)         
       
  1325         { 
       
  1326         //set the new position of viewport
       
  1327         TInt offeset = iViewPortPosition.iY - point.iY;
       
  1328         iViewPortPosition.iY-=offeset;
       
  1329         if( (iViewPortPosition.iY < 0) )
       
  1330             {
       
  1331             iViewPortPosition.iY = 0;
       
  1332             }   
       
  1333         }    
       
  1334     //if its key event then it should be cyclic
       
  1335     else if( rownumber == (iCloudInfo.Count()-1))
       
  1336         {
       
  1337         iViewPortPosition.iY = iViewPortVirtualSize.iHeight - iViewPortSize.iHeight;
       
  1338         }
       
  1339     iViewPortLayout->SetViewportPos (iViewPortPosition,1000); 
       
  1340     iScrollEventData.mViewStartPos = iViewPortPosition.iY;
       
  1341     Scroll();  
       
  1342     //CalculateBubleMidPoint ();   
       
  1343     }
       
  1344 
       
  1345 
       
  1346 // ---------------------------------------------------------------------------
       
  1347 // MoveDownIfRequired()
       
  1348 // ---------------------------------------------------------------------------
       
  1349 //
       
  1350 void CGlxCloudViewControl::MoveDownIfRequired()
       
  1351     {
       
  1352     TRACER("GLX_CLOUD::CGlxCloudViewControl::MoveDownIfRequired");  
       
  1353     //get the focused item's position
       
  1354     TPoint point;
       
  1355     iLayout->ChildPos(iMediaList.FocusIndex(),point);
       
  1356     TSize size;
       
  1357     iLayout->ChildSize(iMediaList.FocusIndex(),size);
       
  1358     //if the focused visual is not visible then move the viewport 
       
  1359     if(point.iY+size.iHeight > iViewPortPosition.iY+iViewPortSize.iHeight )
       
  1360         { 
       
  1361         //set the new position of viewport
       
  1362         TInt offeset = (point.iY+size.iHeight) - (iViewPortPosition.iY+iViewPortSize.iHeight);
       
  1363         iViewPortPosition.iY+=offeset;
       
  1364         if( (iViewPortPosition.iY > iViewPortVirtualSize.iHeight) )
       
  1365             {
       
  1366             iViewPortPosition.iY = iViewPortVirtualSize.iHeight - iViewPortSize.iHeight;
       
  1367             } 
       
  1368         }
       
  1369     //if its key event then it should be cyclic
       
  1370     else if (iMediaList.FocusIndex() == 0)
       
  1371         {
       
  1372         iViewPortPosition.iY = 0;
       
  1373         }     
       
  1374     iViewPortLayout->SetViewportPos (iViewPortPosition,1000); 
       
  1375     iScrollEventData.mViewStartPos = iViewPortPosition.iY;
       
  1376     if(iScrollBarWidget)
       
  1377         {
       
  1378         Scroll();           
       
  1379         }
       
  1380     //CalculateBubleMidPoint();   
       
  1381     }     
       
  1382 
       
  1383 // ---------------------------------------------------------------------------
       
  1384 // MoveDownIfRequired()
       
  1385 // ---------------------------------------------------------------------------
       
  1386 //
       
  1387 void CGlxCloudViewControl::CalculateBubleMidPoint()
       
  1388     { 
       
  1389     TRACER("GLX_CLOUD::CGlxCloudViewControl::CalculateBubleMidPoint");
       
  1390     TPoint midpoint;
       
  1391     TAlfRealRect focussedItemRect;
       
  1392     TRect mainPaneRect;
       
  1393     AknLayoutUtils::LayoutMetricsRect (AknLayoutUtils::EMainPane, mainPaneRect);
       
  1394 
       
  1395     CAlfVisual& visual = iLayout->Visual( iMediaList.FocusIndex() );
       
  1396     focussedItemRect = visual.DisplayRect();
       
  1397 
       
  1398     if( GlxGeneralUiUtilities::LayoutIsMirrored () )
       
  1399         {  
       
  1400         midpoint.iX = focussedItemRect.iBr.iX +
       
  1401         ((focussedItemRect.iTl.iX - focussedItemRect.iBr.iX )/2);
       
  1402         }
       
  1403 
       
  1404     else 
       
  1405         {
       
  1406         midpoint.iX=focussedItemRect.iTl.iX +
       
  1407         ((focussedItemRect.iBr.iX - focussedItemRect.iTl.iX )/2);
       
  1408         }
       
  1409 
       
  1410     midpoint.iY=focussedItemRect.iTl.iY+
       
  1411                 ((focussedItemRect.iBr.iY - focussedItemRect.iTl.iY )/2); 
       
  1412     TPoint anchorRect;
       
  1413 
       
  1414     //Get the position of anchor layout
       
  1415     iViewPortLayout->ChildPos (0, anchorRect);
       
  1416 
       
  1417     //Add the differance to the midpoint
       
  1418     midpoint.iX+=anchorRect.iX;
       
  1419     midpoint.iY+=anchorRect.iY; 
       
  1420 
       
  1421     //Substract from the viewport position the viewport position    
       
  1422     SetBubleMidPoint(midpoint);   
       
  1423 
       
  1424     //Set the buble focus    
       
  1425     // iBubbleContainer->SetFocus (midpoint);
       
  1426     } 
       
  1427 
       
  1428 // ---------------------------------------------------------------------------
       
  1429 // HandlePointerEventL()
       
  1430 // ---------------------------------------------------------------------------
       
  1431 //  
       
  1432 TBool CGlxCloudViewControl::HandlePointerEventL( const TAlfEvent &aEvent )
       
  1433     {
       
  1434     TRACER("GLX_CLOUD::CGlxCloudViewControl::HandlePointerEventL");
       
  1435     CAlfVisual* tappedvisual = aEvent.Visual();	
       
  1436     TBool consumed = EFalse;
       
  1437     if(aEvent.PointerEvent().iType == TPointerEvent::EButton1Down)
       
  1438         {	
       
  1439         if(tappedvisual)
       
  1440             {
       
  1441             for(TInt index=0;index<iLayout->Count();index++)
       
  1442                 {    	
       
  1443                 CAlfVisual* layoutvisual = &(iLayout->Visual(index));
       
  1444                 //if the tapped visual is same as the visual in the layout then focus that visual
       
  1445                 if(layoutvisual == tappedvisual)
       
  1446                     {
       
  1447                     TInt focus = iMediaList.FocusIndex();
       
  1448                     //if the visual is already focused then for next tap open the next view
       
  1449                     if( focus == index )
       
  1450                         {
       
  1451                         iTouchFeedback->InstantFeedback( ETouchFeedbackBasic );
       
  1452                         iObserverEnterKeyEvent.HandleEnterKeyEventL( (TInt)EAknCmdOpen );		    			
       
  1453                         consumed = ETrue;
       
  1454                         }
       
  1455                     else if( index!= focus )
       
  1456                         {
       
  1457                         iTouchFeedback->InstantFeedback( ETouchFeedbackBasic );
       
  1458                         TInt focusrowindex = iFocusRowIndex;
       
  1459                         iMediaList.SetFocusL (NGlxListDefs::EAbsolute,
       
  1460                                 index);
       
  1461                         SetFocusColor();
       
  1462                         iFocusRowIndex = RowNumber (iMediaList.FocusIndex ());
       
  1463                         if( iFocusRowIndex > focusrowindex)
       
  1464                             {
       
  1465                             GLX_LOG_INFO("GLX_CLOUD :: CGlxCloudViewControl::HandleDragL,b4 movedown");
       
  1466                             iScrollDirection = 0;               
       
  1467                             MoveDownIfRequired();               
       
  1468                             }
       
  1469                         else if( iFocusRowIndex < focusrowindex )
       
  1470                             {
       
  1471                             GLX_LOG_INFO("GLX_CLOUD :: CGlxCloudViewControl::HandleDragL,b4 moveup");
       
  1472                             iScrollDirection = 1;                
       
  1473                             MoveUpIfRequired();                 
       
  1474                             }
       
  1475                         }
       
  1476                     consumed = ETrue;
       
  1477                     Display()->Roster().SetPointerEventObservers( EAlfPointerEventReportDrag 
       
  1478                             + EAlfPointerEventReportLongTap 
       
  1479                             + EAlfPointerEventReportUnhandled, *this );
       
  1480                     Display()->Roster().DisableLongTapEventsWhenDragging(*this);
       
  1481                     break;
       
  1482                     }
       
  1483                 }
       
  1484             }
       
  1485         }			
       
  1486 
       
  1487     else if (aEvent.PointerEvent().iType == TPointerEvent::EDrag)
       
  1488         {
       
  1489         GLX_LOG_INFO("GLX_CLOUD :: CGlxCloudViewControl::HandlePointerEventL(EDrag) event");
       
  1490         iTouchFeedback->InstantFeedback( ETouchFeedbackBasic );
       
  1491         consumed =  HandleDragL(aEvent.PointerEvent());
       
  1492         }
       
  1493     else if (aEvent.PointerUp())
       
  1494         {
       
  1495         
       
  1496         Env().CancelCustomCommands(this,ECustomEventFocusDragScroll);
       
  1497         Display()->Roster().SetPointerEventObservers(0, *this);
       
  1498         consumed =  ETrue;
       
  1499         }
       
  1500     return consumed;
       
  1501     }
       
  1502 
       
  1503 // ---------------------------------------------------------------------------
       
  1504 // HandleDragL()
       
  1505 // ---------------------------------------------------------------------------
       
  1506 //
       
  1507 TBool CGlxCloudViewControl::HandleDragL(const TPointerEvent& aPointerEvent)
       
  1508     {
       
  1509     TRACER("GLX_CLOUD::CGlxCloudViewControl::HandleDragL");
       
  1510     TBool consumed = EFalse;
       
  1511     TInt itemindex = GetAbsoluteIndex(aPointerEvent.iPosition);
       
  1512     TInt focus = iMediaList.FocusIndex();
       
  1513     TInt focusrowindex = iFocusRowIndex;
       
  1514 
       
  1515     //if index is not NULL then focus the tag and move the viewport down if necessary
       
  1516     if ( itemindex != KErrNotFound )
       
  1517         {
       
  1518         if (focus != itemindex )
       
  1519             {
       
  1520             iTouchFeedback->InstantFeedback( ETouchFeedbackSensitive );
       
  1521             iMediaList.SetFocusL (NGlxListDefs::EAbsolute,itemindex);			
       
  1522             iFocusRowIndex = RowNumber (iMediaList.FocusIndex ());
       
  1523             GLX_LOG_INFO1("GLX_CLOUD :: CGlxCloudViewControl::HandleDragL,focusrowindex = %d",iFocusRowIndex);
       
  1524             if( iFocusRowIndex > focusrowindex)
       
  1525                 {
       
  1526                 GLX_LOG_INFO("GLX_CLOUD :: CGlxCloudViewControl::HandleDragL,b4 movedown");
       
  1527                 iScrollDirection = 0;
       
  1528                 MoveDownIfRequired(); 				
       
  1529                 }
       
  1530             else if( iFocusRowIndex < focusrowindex )
       
  1531                 {
       
  1532                 GLX_LOG_INFO("GLX_CLOUD :: CGlxCloudViewControl::HandleDragL,b4 moveup");
       
  1533                 iScrollDirection = 1;
       
  1534                 MoveUpIfRequired();					
       
  1535                 }			
       
  1536             }
       
  1537         consumed = ETrue;
       
  1538         }
       
  1539 
       
  1540     TRect screenstartrect;
       
  1541     //the starting rect of the visible screen
       
  1542     screenstartrect.SetRect(0,0,iTagScreenWidth,2*KRowHeight);
       
  1543 
       
  1544     TRect screenendrect;
       
  1545     //the end rect of the visible screen
       
  1546     screenendrect.SetRect(0,(iTagScreenHeight-(2*KRowHeight)),iTagScreenWidth,iTagScreenHeight);
       
  1547 
       
  1548     //dragging down
       
  1549     if(screenendrect.Contains(aPointerEvent.iPosition))
       
  1550         {            
       
  1551         iIsDragging = 1;            
       
  1552         Env().Send(TAlfCustomEventCommand(ECustomEventFocusDragScroll,
       
  1553                 this),KDragHoldTime);
       
  1554         }
       
  1555     //dragging up
       
  1556     else if  (screenstartrect.Contains(aPointerEvent.iPosition))
       
  1557         {
       
  1558         iIsDragging = 2;             
       
  1559         Env().Send(TAlfCustomEventCommand(ECustomEventFocusDragScroll,
       
  1560                 this),KDragHoldTime);
       
  1561         }        
       
  1562 
       
  1563     return consumed;
       
  1564     }
       
  1565 
       
  1566 // ---------------------------------------------------------------------------
       
  1567 // GetAbsoluteIndex()
       
  1568 // ---------------------------------------------------------------------------
       
  1569 //
       
  1570 TInt CGlxCloudViewControl::GetAbsoluteIndex(const TPoint& aPosition)
       
  1571     {
       
  1572     TRACER("GLX_CLOUD::CGlxCloudViewControl::GetAbsoluteIndex");
       
  1573     //find out the visual on which the drag event has occured
       
  1574     for(TInt j = 0; j < iLayout->Count(); j++)
       
  1575         {
       
  1576         CAlfVisual* visual = &(iLayout->Visual(j));
       
  1577         TRect visualrect = visual->DisplayRect();
       
  1578         TInt focusindex = iMediaList.FocusIndex();
       
  1579         if(visualrect.Contains(aPosition) && (focusindex != j))      
       
  1580             {
       
  1581             return j;
       
  1582             }
       
  1583         }
       
  1584     return KErrNotFound;	         
       
  1585     }
       
  1586 
       
  1587 // ---------------------------------------------------------------------------
       
  1588 // SetRelativeFocusL()
       
  1589 // ---------------------------------------------------------------------------
       
  1590 //
       
  1591 void CGlxCloudViewControl::SetRelativeFocusL(TInt aRowNumber)
       
  1592     {
       
  1593     TRACER("GLX_CLOUD::CGlxCloudViewControl::SetRelativeFocusL");
       
  1594     TInt focus = iMediaList.FocusIndex ();
       
  1595     //get the co-ordinates of the focused tag
       
  1596     TInt x = iLayout->Visual(focus).DisplayRect().Center().iX;
       
  1597     TInt y = iLayout->Visual(focus).DisplayRect().Center().iY;
       
  1598     TPoint midpoint(x, y);
       
  1599 
       
  1600     //find the tag below\above that overlaps with the focused tag
       
  1601     for(TInt index = iCloudInfo[aRowNumber].iStartIndex; 
       
  1602         index <= iCloudInfo[aRowNumber].iEndIndex; index++)
       
  1603         {	    
       
  1604         CAlfVisual* visual = &(iLayout->Visual(index));				
       
  1605         TRect visualrect = visual->DisplayRect();
       
  1606         if ( (visualrect.iTl.iX <= midpoint.iX) && (midpoint.iX <= visualrect.iBr.iX))
       
  1607             {            
       
  1608             iMediaList.SetFocusL (NGlxListDefs::EAbsolute,index);
       
  1609             break;
       
  1610             } 
       
  1611         }
       
  1612 
       
  1613     // if no element is found that overlaps with midpoint of the 
       
  1614     //focused item,then focus the last element of the next row.
       
  1615     if(focus == iMediaList.FocusIndex ())	
       
  1616         {        
       
  1617         iMediaList.SetFocusL (NGlxListDefs::EAbsolute,
       
  1618                 iCloudInfo[aRowNumber].iEndIndex);
       
  1619         } 	 	
       
  1620     }
       
  1621 
       
  1622 // ---------------------------------------------------------------------------
       
  1623 // setActiveStates()
       
  1624 // ---------------------------------------------------------------------------
       
  1625 //
       
  1626 void CGlxCloudViewControl::setActiveStates( unsigned int /*aStates*/ )
       
  1627     {
       
  1628     }
       
  1629 
       
  1630 // ---------------------------------------------------------------------------
       
  1631 // makeInterface()
       
  1632 // ---------------------------------------------------------------------------
       
  1633 //
       
  1634 IAlfInterfaceBase* CGlxCloudViewControl::makeInterface ( const IfId& /*aType*/ )
       
  1635     {
       
  1636     return NULL;
       
  1637     }
       
  1638 
       
  1639 // ---------------------------------------------------------------------------
       
  1640 // eventHandlerType()
       
  1641 // ---------------------------------------------------------------------------
       
  1642 //
       
  1643 IAlfWidgetEventHandler::AlfEventHandlerType CGlxCloudViewControl::eventHandlerType()
       
  1644     {
       
  1645     return IAlfWidgetEventHandler::ELogicalEventHandler;
       
  1646     }  
       
  1647 
       
  1648 // ---------------------------------------------------------------------------
       
  1649 // eventExecutionPhase()
       
  1650 // ---------------------------------------------------------------------------
       
  1651 //
       
  1652 IAlfWidgetEventHandler::AlfEventHandlerExecutionPhase CGlxCloudViewControl::eventExecutionPhase()
       
  1653     {
       
  1654     return IAlfWidgetEventHandler::ETunnellingPhaseEventHandler;
       
  1655     }
       
  1656 
       
  1657 // ---------------------------------------------------------------------------
       
  1658 // offerEvent()
       
  1659 // ---------------------------------------------------------------------------
       
  1660 //
       
  1661 AlfEventStatus CGlxCloudViewControl::offerEvent( CAlfWidgetControl& aControl, const TAlfEvent& aEvent )
       
  1662     {
       
  1663     TRACER("GLX_CLOUD::CGlxCloudViewControl::offerEvent");  
       
  1664     AlfEventStatus status = EEventNotHandled;  
       
  1665     if(aEvent.IsCustomEvent() && accept(aControl, aEvent))
       
  1666         {
       
  1667         if ((iScrollBarWidget!=NULL))
       
  1668             {    		
       
  1669             if (aEvent.IsCustomEvent())
       
  1670                 {
       
  1671                 switch(aEvent.CustomParameter())
       
  1672                     {
       
  1673                     case KAlfActionIdDeviceLayoutChanged:
       
  1674                         {
       
  1675                         // iObserver.HandleMskChangedL(ETrue);
       
  1676                         iLayoutObserver.HandleLayoutChanged();
       
  1677                         TRAP_IGNORE(UpdateLayoutL());
       
  1678                         }
       
  1679                          return EEventNotHandled;
       
  1680 
       
  1681                     case EEventDragVertical:
       
  1682                         {    
       
  1683                         GLX_LOG_INFO("GLX_CLOUD :: CGlxCloudViewControl::offerEvent(EEventScrollDown) event");
       
  1684                         TInt steps = TInt(aEvent.CustomEventData());
       
  1685                         UpdateScrollBar(steps,EFalse);                        
       
  1686                         Scroll();                       
       
  1687                         status = EEventHandled; 
       
  1688                         }
       
  1689                         break;                   
       
  1690                     case EEventScrollPageUp:
       
  1691                         { 
       
  1692                         GLX_LOG_INFO("GLX_CLOUD :: CGlxCloudViewControl::offerEvent(EEventScrollPageUp) event");                       
       
  1693                         UpdateScrollBar(-iScrollEventData.mViewLength); 
       
  1694                         Scroll();                        
       
  1695                         status = EEventHandled;    		    	    
       
  1696                         }
       
  1697                         break;
       
  1698                     case EEventScrollPageDown:
       
  1699                         {  
       
  1700                         GLX_LOG_INFO("GLX_CLOUD :: CGlxCloudViewControl::offerEvent(EEventScrollPageDown) event");                       
       
  1701                         UpdateScrollBar(iScrollEventData.mViewLength); 
       
  1702                         Scroll();
       
  1703                         status = EEventHandled; 		    	    
       
  1704                         }
       
  1705                         break;                    
       
  1706                     }//end switch
       
  1707                 }
       
  1708             }
       
  1709         }
       
  1710     return status;
       
  1711     }
       
  1712 
       
  1713 // ---------------------------------------------------------------------------
       
  1714 // accept()
       
  1715 // ---------------------------------------------------------------------------
       
  1716 //   
       
  1717 bool CGlxCloudViewControl::accept ( CAlfWidgetControl& /*aControl*/, const TAlfEvent& aEvent ) const
       
  1718     {
       
  1719     TRACER("GLX_CLOUD::CGlxCloudViewControl::accept");
       
  1720     if(	aEvent.CustomParameter() == EEventScrollPageUp 	||
       
  1721         aEvent.CustomParameter() == EEventScrollPageDown ||
       
  1722         aEvent.CustomParameter() == EEventDragVertical ||
       
  1723         aEvent.CustomParameter() == KAlfActionIdDeviceLayoutChanged )
       
  1724         {
       
  1725         return true;
       
  1726         }
       
  1727     return false;
       
  1728     }
       
  1729 
       
  1730 // ---------------------------------------------------------------------------
       
  1731 // attachScrollBar()
       
  1732 // ---------------------------------------------------------------------------
       
  1733 //	
       
  1734 void CGlxCloudViewControl::InitializeScrollBar(IAlfScrollBarWidget* aScrollBarWidget)
       
  1735     { 
       
  1736     TRACER("GLX_CLOUD::CGlxCloudViewControl::InitializeScrollBar");
       
  1737     iScrollBarWidget=aScrollBarWidget;
       
  1738     ((IAlfScrollBarModel *)(iScrollBarWidget->model()))->initializeData(iScrollEventData.mSpan,
       
  1739             iScrollEventData.mViewLength,0);													           
       
  1740     DisplayScrollBar();	
       
  1741     }
       
  1742 
       
  1743 // ---------------------------------------------------------------------------
       
  1744 // Scroll()
       
  1745 // ---------------------------------------------------------------------------
       
  1746 //
       
  1747 void CGlxCloudViewControl::Scroll()
       
  1748     {
       
  1749     TRACER("GLX_CLOUD::CGlxCloudViewControl::Scroll()");
       
  1750     TAlfEvent customevent(EEventScrollBarModelChanged,(TInt)&iScrollEventData);
       
  1751     IAlfElement* baseelement = iScrollBarWidget->control()->findElement ("BaseElement");
       
  1752     iScrollbarElement=static_cast<IAlfWidgetEventHandler*> (
       
  1753             baseelement->makeInterface (IAlfWidgetEventHandler::type()));
       
  1754     //pass the custom event to scrollbar element so as to scroll to the required position
       
  1755     iScrollbarElement->offerEvent(*(iScrollBarWidget->control()),customevent);
       
  1756     GLX_LOG_INFO1("GLX_CLOUD ::CGlxCloudViewControl::Scroll(),position %d ",iScrollEventData.mViewStartPos);
       
  1757     iViewPortPosition.iY = iScrollEventData.mViewStartPos;
       
  1758     iViewPortLayout->SetViewportPos (iViewPortPosition,1000);  
       
  1759     }
       
  1760 
       
  1761 // ---------------------------------------------------------------------------
       
  1762 // UpdateScrollBar()
       
  1763 // ---------------------------------------------------------------------------
       
  1764 //
       
  1765 void CGlxCloudViewControl::UpdateScrollBar(TInt aNumberOfSteps, TBool aDiff)
       
  1766     {
       
  1767     TRACER("GLX_CLOUD::CGlxCloudViewControl::UpdateScrollBar()");
       
  1768     TInt viewLength = ((IAlfScrollBarModel *)(iScrollBarWidget->model()))->getViewLength();
       
  1769     TInt viewStartPos=((IAlfScrollBarModel *)(iScrollBarWidget->model()))->getViewStartPosition();
       
  1770     TInt totalLength=((IAlfScrollBarModel *)(iScrollBarWidget->model()))->getTotalLength();
       
  1771 
       
  1772     TInt newViewStartPos=viewStartPos;
       
  1773     if(aDiff)
       
  1774         {
       
  1775         aNumberOfSteps+=viewStartPos;
       
  1776         }
       
  1777     if( (aNumberOfSteps <= (totalLength-viewLength))&&(aNumberOfSteps>=0) )
       
  1778         {
       
  1779         newViewStartPos=aNumberOfSteps;
       
  1780         }
       
  1781     else if( aNumberOfSteps > (totalLength-viewLength) )
       
  1782         {
       
  1783         newViewStartPos=totalLength-viewLength;
       
  1784         }
       
  1785     else if ( aNumberOfSteps < 0 )
       
  1786         {
       
  1787         newViewStartPos=0;
       
  1788         }
       
  1789     iScrollEventData.mViewStartPos = newViewStartPos;
       
  1790     }
       
  1791 
       
  1792 // ---------------------------------------------------------------------------
       
  1793 // DisplayScrollBar()
       
  1794 // ---------------------------------------------------------------------------
       
  1795 //
       
  1796 void CGlxCloudViewControl::DisplayScrollBar() 
       
  1797     {
       
  1798     if( iScrollBarWidget )
       
  1799         {
       
  1800         IAlfElement* vertBaseElement =(iScrollBarWidget->control()->findElement ("BaseElement"));
       
  1801         IAlfScrollBarDefaultBaseElement* scrollbarbaselement=static_cast<IAlfScrollBarDefaultBaseElement*> (
       
  1802             vertBaseElement->makeInterface (IAlfScrollBarDefaultBaseElement::type() ) );
       
  1803 
       
  1804         if( iScrollEventData.mSpan )
       
  1805             {       
       
  1806             scrollbarbaselement->setThumbOpacity(1.0);  
       
  1807             }
       
  1808         else
       
  1809             {
       
  1810             scrollbarbaselement->setThumbOpacity(0.0);  
       
  1811             }
       
  1812         }
       
  1813     }
       
  1814 
       
  1815 // ---------------------------------------------------------------------------
       
  1816 // UpdateLayoutL() 
       
  1817 // ---------------------------------------------------------------------------
       
  1818 //
       
  1819 void CGlxCloudViewControl::UpdateLayoutL() 
       
  1820     {
       
  1821     TRect rect;
       
  1822     AknLayoutUtils::LayoutMetricsRect (AknLayoutUtils::EMainPane, rect);
       
  1823     if ( (rect.Width() != iTagScreenWidth) && ( rect.Height () != iScreenHeight))
       
  1824         {
       
  1825         //set the new screen dimensions
       
  1826         iScreenHeight=rect.Height();
       
  1827        iTagScreenWidth = rect.Width()- iScrollPaneHandle.iW - KRightmargin;
       
  1828         if (GlxGeneralUiUtilities::IsLandscape())
       
  1829             {   
       
  1830             iTagScreenHeight = rect.Height();   
       
  1831             }
       
  1832         else 
       
  1833             {
       
  1834             iTagScreenHeight = KTagScreenHeight;
       
  1835             }
       
  1836 
       
  1837         iViewPortLayout->SetSize(TAlfRealSize(iTagScreenWidth,iTagScreenHeight), 0);
       
  1838         //delete all layout associations
       
  1839         if ( iCloudInfo.Count ()!= 0)//check for the empty cloud view
       
  1840             {
       
  1841             UpdateLayout();
       
  1842             FetchAttributeFromCacheL();
       
  1843             //generate row structures and draw rows on screen
       
  1844             UpdateRowDataL ();                                    
       
  1845             }
       
  1846         }
       
  1847     }
       
  1848         
       
  1849 //End of file