emailuis/emailui/inc/FreestyleEmailUiLauncherGridVisualiser.h
changeset 0 8466d47a6819
child 1 12c456ceeff2
equal deleted inserted replaced
-1:000000000000 0:8466d47a6819
       
     1 /*
       
     2 * Copyright (c) 2007-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:  FreestyleEmailUi main UI grid definition.
       
    15 *
       
    16 */
       
    17 
       
    18 
       
    19 
       
    20 #ifndef __FREESTYLEEMAILUI_MAINGRIDUIVISUALISER_H__
       
    21 #define __FREESTYLEEMAILUI_MAINGRIDUIVISUALISER_H__
       
    22 
       
    23 // SYSTEM INCLUDE FILES
       
    24 //<cmail> SF
       
    25 #include <alf/alfcontrol.h>
       
    26 //</cmail>
       
    27 // for AIW handling
       
    28 #include <AiwServiceHandler.h>
       
    29 //<cmail>
       
    30 #include <alf/alfdecklayout.h>
       
    31 #include <alf/alfgridlayout.h>
       
    32 #include <alf/alfmappingfunctions.h>
       
    33 #include <alf/alfbitmapprovider.h>
       
    34 //</cmail>
       
    35 
       
    36 // INTERNAL INCLUDE FILES
       
    37 #include "FreestyleEmailUiViewBase.h"
       
    38 #include "FreestyleEmailUiLauncherGridModel.h"
       
    39 #include "FreestyleEmailUiAppui.h"
       
    40 
       
    41 #include "FSEmailLauncherItem.h"
       
    42 #include "freestyleemailuimailboxdeleter.h"
       
    43 
       
    44 // FORWARD DECLARATIONS
       
    45 // <cmail> 
       
    46 class CBrushAnimation;
       
    47 // </cmail> 
       
    48 class CFsAlfScrollbarLayout;
       
    49 
       
    50 class TFSLauncherGridMailboxStatus
       
    51     {
       
    52     public:
       
    53         TInt iMailboxCount;
       
    54         TInt iMailboxesOnline;
       
    55         TInt iMailboxesOffline;
       
    56         TInt iMailboxesSyncing;
       
    57     };
       
    58 
       
    59 
       
    60 // Grid visualiser
       
    61 class CFSEmailUiLauncherGridVisualiser : public CFsEmailUiViewBase,
       
    62                      				   	 public MAlfBitmapProvider,
       
    63                      				   	 public MFSEmailLauncherItemObserver,
       
    64                      				   	 public MEikScrollBarObserver,
       
    65                      				   	 public MFSEmailUiMailboxDeleteObserver
       
    66     {
       
    67 public:
       
    68     enum TDirection
       
    69         {
       
    70         EDirectionRight=0,
       
    71         EDirectionLeft,
       
    72         EDirectionUp,
       
    73         EDirectionDown,
       
    74         EDirectionReset, 
       
    75         EDirectionNone,
       
    76         // <cmail> 
       
    77         EDirectionTouch 
       
    78         // </cmail> 
       
    79         };
       
    80 
       
    81     static CFSEmailUiLauncherGridVisualiser* NewL(CAlfEnv& aEnv, 
       
    82    									  CFSEmailUiLauncherGrid* aControl, 
       
    83     								  CFreestyleEmailUiAppUi* aAppUi,
       
    84     								  CAlfControlGroup& aControlGroup, 
       
    85     								  TInt aColumns, 
       
    86     								  TInt aRows);
       
    87 
       
    88     static CFSEmailUiLauncherGridVisualiser* NewLC(CAlfEnv& aEnv,
       
    89     									 CFSEmailUiLauncherGrid* aControl, 
       
    90     								   CFreestyleEmailUiAppUi* aAppUi,
       
    91     								   CAlfControlGroup& aControlGroup, 
       
    92     								   TInt aColumns, 
       
    93     								   TInt aRows);
       
    94 
       
    95     void AddMenuItemL(TUid aUid);
       
    96 	void SelectL();	
       
    97 	// Menu pane init and command handling
       
    98 	void DynInitMenuPaneL(TInt aResourceId, CEikMenuPane* aMenuPane);
       
    99 	void HandleCommandL(TInt aCommand);
       
   100 
       
   101     TBool OfferEventL(const TAlfEvent& aEvent);
       
   102     // <cmail> 
       
   103     /**
       
   104       * Handler for touch related events
       
   105       * @param aEvent, event type
       
   106       * @return ETrue if event was used
       
   107       */
       
   108     TBool HandlePointerEventL(const TAlfEvent& aEvent);
       
   109     
       
   110     /**
       
   111       * Function for searching right item when pointer event occurs
       
   112       * @param aEvent, event type
       
   113       * @return KErrnone if item was not found, else index to founded item
       
   114       */
       
   115     TInt FindPointedItem( const TAlfEvent& aEvent );
       
   116     
       
   117     /**
       
   118       * Function for setting focus to item 
       
   119       * @param aId, id of item where focus is going to be changed
       
   120       */
       
   121     void SetFocusedItemL( TInt aId );
       
   122     
       
   123     void HandleRowMovement( TDirection aDir, TInt aSelected );
       
   124     // </cmail> 
       
   125     TUid Id() const;			   
       
   126     // <cmail> Toolbar
       
   127     /*
       
   128     void DoActivateL(const TVwsViewId& aPrevViewId,
       
   129 	                 TUid aCustomMessageId,
       
   130 	                 const TDesC8& aCustomMessage);
       
   131      */
       
   132 	void ChildDoDeactivate(); 
       
   133   
       
   134     void VisualLayoutUpdatedL();
       
   135 
       
   136 	// Dynamic switch handling
       
   137 	void HandleDynamicVariantSwitchL( CFsEmailUiViewBase::TDynamicSwitchType aType );
       
   138 	void HandleDynamicVariantSwitchOnBackgroundL( CFsEmailUiViewBase::TDynamicSwitchType aType );
       
   139 	
       
   140 	// React to changes in grid contents
       
   141 	void HandleContentChangeL();
       
   142     
       
   143     void LaunchWizardL();
       
   144     void GoToInboxL( TFSMailMsgId& mailboxId, 
       
   145                      TFSMailMsgId& mailboxInboxId );
       
   146 
       
   147 	// From MFSEmailLauncherItemObserver
       
   148 	void RefreshLauncherViewL();
       
   149     
       
   150 	TBool UiOperationLaunched();
       
   151 
       
   152 	// Modifies the value of iWizardWaitnoteShown
       
   153     void SetWizardWaitnoteShown( TBool aWaitnoteShown );
       
   154     
       
   155 	// Bitmap provider for grid ecom plugins icons 
       
   156 	void ProvideBitmapL(TInt aId, CFbsBitmap*& aBitmap, CFbsBitmap*& aMaskBitmap);
       
   157 
       
   158     // Set refresh needed flag
       
   159 	void SetRefreshNeeded();
       
   160 	// <cmail> 
       
   161     // Handling of foreground events
       
   162 	void HandleForegroundEventL();
       
   163 	
       
   164     /**
       
   165      * From MEikScrollBarObserver
       
   166      * 
       
   167      * Callback method for scroll bar events
       
   168      *
       
   169      * Scroll bar observer should implement this method to get scroll bar events.
       
   170      *
       
   171      * @since S60 0.9
       
   172      * @param aScrollBar A pointer to scrollbar which created the event
       
   173      * @param aEventType The event occured on the scroll bar
       
   174      */
       
   175     void HandleScrollEventL(CEikScrollBar* aScrollBar, TEikScrollEvent aEventType);
       
   176     // </cmail> 
       
   177 	
       
   178 	// From base class CFsEmailUiViewBase
       
   179 	void GetParentLayoutsL( RPointerArray<CAlfVisual>& aLayoutArray ) const;
       
   180 	
       
   181     /**
       
   182      * Called when flip state changes.
       
   183 	 */
       
   184 	void FlipStateChangedL( TBool aKeyboardFlipOpen );
       
   185 
       
   186 // <cmail> Toolbar    
       
   187 private: // from
       
   188     
       
   189     /**
       
   190      * @see CFsEmailUiViewBase::ChildDoActivateL
       
   191      */
       
   192     void ChildDoActivateL( const TVwsViewId& aPrevViewId,
       
   193             TUid aCustomMessageId,
       
   194             const TDesC8& aCustomMessage );  
       
   195 // </cmail> Toolbar 
       
   196 
       
   197 private: // from MFSEmailUiMailboxDeleteObserver
       
   198     
       
   199     void MailboxDeletionComplete();
       
   200     
       
   201     
       
   202 private: // methods
       
   203     CFSEmailUiLauncherGridVisualiser(CAlfEnv& aEnv, 
       
   204     					 CFSEmailUiLauncherGrid* aControl,
       
   205     					 CFreestyleEmailUiAppUi* aAppUi,
       
   206     					 CAlfControlGroup& aControlGroup);
       
   207     void ConstructL(TInt aColumns, TInt aRows);
       
   208     virtual ~CFSEmailUiLauncherGridVisualiser();
       
   209 	void CreateModelL();
       
   210     void MoveSelection( TDirection aDir );
       
   211     void MoveSelectorToCurrentItem( TDirection aDir );
       
   212     void Select();
       
   213     void DisplayProductInfoL();
       
   214 	void RescaleIconsL();
       
   215     void SetRingWrapLimits();
       
   216 	void AddItemToModelL( CFSEmailLauncherItem* aItem,  TInt aPluginArrayIndex );
       
   217 
       
   218 	void ConstructScrollbarL( CAlfLayout* aParent );
       
   219     void UpdateScrollBarRangeL();
       
   220     CFSMailBox* ShowMailboxSelectionQueryL( const RPointerArray<CFSMailBox>& aMailBoxes );
       
   221 
       
   222     // Check status of all configured mailboxes
       
   223     TFSLauncherGridMailboxStatus CheckMailboxStatusL();
       
   224 
       
   225     void DoFirstStartL();
       
   226 
       
   227     /**
       
   228      * Funciton should decide if item focus should still be drawn dispite of
       
   229      * releasing button.
       
   230      */
       
   231     void HandleButtonReleaseEvent();
       
   232 
       
   233     /**
       
   234      * Reduces item's icon size.
       
   235      */
       
   236     void ResizeItemIcon( TBool aReduce );
       
   237 	
       
   238     /**
       
   239      * Handles the focus removal of CFSEmailUiLauncherGridVisualiser
       
   240      * @param aShow Indicates if focus should become visible or removed
       
   241      */
       
   242 	void HandleTimerFocusStateChange( TBool aShow );
       
   243 
       
   244 private: // data types
       
   245 
       
   246     struct TItemVisualData
       
   247         {
       
   248         CAlfAnchorLayout* iBase;
       
   249         CAlfImageVisual* iImage;
       
   250         CAlfTextVisual* iText;
       
   251         };
       
   252 
       
   253 	struct TLevel
       
   254         {
       
   255 	    CAlfGridLayout* iGridLayout;
       
   256 		RArray<TItemVisualData> iItemVisualData;
       
   257 		TInt iSelected;
       
   258         TInt iParent; 
       
   259 		TPoint iParentPos;
       
   260         RArray<TMenuItem> iItems; 
       
   261         };      
       
   262 
       
   263 	struct TPluginIdIconIdPair
       
   264 		{
       
   265 		TInt iPluginArrayIndex;
       
   266 		TInt iIconId;
       
   267 		};
       
   268 	
       
   269     class TRingMovementFuncMappingDataProvider: public MAlfTableMappingFunctionDataProvider
       
   270         {
       
   271     public:
       
   272         inline TRingMovementFuncMappingDataProvider() : iStart(0), iEnd(0) { }
       
   273         // From MAlfTableMappingFunctionDataProvider    
       
   274         TReal32 MapValue( TReal32 aValue, TInt aMode ) const;
       
   275         inline void SetStart( TReal32 aStart ) { iStart = aStart; }
       
   276         inline void SetEnd( TReal32 aEnd ) { iEnd = aEnd; }
       
   277     private:
       
   278         TReal32 iStart;
       
   279         TReal32 iEnd;
       
   280         };
       
   281 
       
   282     /**
       
   283      * Structure for passing button down events
       
   284      */
       
   285     struct TItemIdInButtonDownEvent
       
   286         {
       
   287         TInt iItemId;
       
   288         TBool iLaunchSelection;
       
   289         };
       
   290 
       
   291 private: // methods
       
   292     void ConstructRingL();
       
   293 
       
   294     void CreateCaptionForApplicationL(TUid aUid, TDes& aCaption, TBool aShortCaption);
       
   295 	void FocusItem(TBool aHasFocus, TInt aItem);
       
   296     void ScrollToRow(TInt row);
       
   297 	void PopulateL(TLevel& aLevel);
       
   298 	void UpdateLauncherItemListL();
       
   299 	void SetDefaultStatusPaneTextL();
       
   300 
       
   301     void DetachSelectorMappingFunctions();
       
   302     void UpdateFocusVisibility();
       
   303 
       
   304 private: // data
       
   305 	CAlfEnv& iEnv;
       
   306 	CAlfControl* iControl;
       
   307 	TLevel iCurrentLevel;
       
   308     CFSEmailUiLauncherGridModel* iModel;
       
   309     TInt iVisibleRows;
       
   310     TInt iVisibleColumns;
       
   311     TInt iRowCount;
       
   312     TInt iFirstVisibleRow;
       
   313     TReal iRowHeight;
       
   314     TReal iColumnWidth;
       
   315     // Selector layout. Not own.
       
   316     CAlfLayout* iSelector;
       
   317     // Mapping function for selector horizontal position. Own.
       
   318     CAlfTableMappingFunction* iRingMovementXFunc;
       
   319     // Mapping function for selector vertical position. Own.
       
   320     CAlfTableMappingFunction* iRingMovementYFunc;
       
   321     TRingMovementFuncMappingDataProvider iRingMovementXFuncMappingDataProvider;
       
   322     TRingMovementFuncMappingDataProvider iRingMovementYFuncMappingDataProvider;
       
   323 
       
   324 	TBool iStartupAnimation;
       
   325     CAlfAnchorLayout* iWaterMarkBackgroundImageLayout;
       
   326 	TInt iStartupEffectStyle;
       
   327     TInt iNewEmailCount;
       
   328     CAlfTextVisual* iNewMailTextVisual;
       
   329   	CAlfImageVisual* iNewMailBgVisual;
       
   330  	CAlfAnchorLayout* iTopTextLayout; 
       
   331   	CAlfTextVisual* iTimeTitle;
       
   332   	CAlfImageVisual *iSelectorImageVisual;
       
   333   	RPointerArray<CAlfTexture> iIconArray;
       
   334   	RArray<TInt> iMailboxRequestIds;
       
   335   	TBool iSynchronizingMailbox;
       
   336   	TBool iMailboxOnline;
       
   337   	RPointerArray<CFSEmailLauncherItem> iLauncherItems;
       
   338   	RArray<TUid> iLauncherItemUids;
       
   339 
       
   340     CAlfDeckLayout* iParentLayout;
       
   341     CAlfAnchorLayout* iWidgetLayout;
       
   342     // <cmail> 
       
   343     CAknDoubleSpanScrollBar* iScrollbar;
       
   344     TAknDoubleSpanScrollBarModel iScrollbarModel;
       
   345     // </cmail> 
       
   346 	CAlfImageVisual* iBgImageVisual;
       
   347     
       
   348     CAiwServiceHandler* iAiwSHandler;
       
   349 	
       
   350 	/**
       
   351 	 * ETrue if "Creating mailbox" wait note is shown. 
       
   352 	 * Then the key presses are ignored.
       
   353 	 */
       
   354 	TBool iWizardWaitnoteShown;
       
   355 
       
   356 	/**
       
   357 	 * ETrue indicates that the grid contents and layout must be updated next time when the
       
   358 	 * grid is activated.
       
   359 	 */
       
   360 	TBool iRefreshNeeded;
       
   361 	
       
   362 	// Array holding pairs of plugin id's vs icon id's
       
   363 	RArray<TPluginIdIconIdPair> iPluginIdIconIdPairs;
       
   364    
       
   365     // Plugin texture count, also serves as index when adding items to array
       
   366     // and if for bitmap provider
       
   367 	TInt iPluginTextureId;
       
   368 	
       
   369 	// Boolean value indicating that construction has completed.
       
   370 	TBool iConstructionCompleted;
       
   371 	
       
   372 	// To indicate whether grid has started, for ODS, IAD and 
       
   373 	// "create mailbox query" interoperability
       
   374 	TBool iFirstStartComplete;
       
   375 
       
   376 	// Boolean value to prevent wizard/help crash when double-clicking.
       
   377 	TBool iDoubleClickLock;
       
   378 
       
   379 	// Item id that was seleceted in button down event
       
   380 	TItemIdInButtonDownEvent iItemIdInButtonDownEvent;
       
   381 
       
   382 	// Boolean value - true is user has launched any operation from UI.
       
   383     TBool iUiOperationLaunched;
       
   384 
       
   385     // Mailbox deleter - handles deletion of one or more mailboxes.
       
   386     CFSEmailUiMailboxDeleter* iMailboxDeleter;
       
   387     };
       
   388 
       
   389 #endif // __FREESTYLEEMAILUI_MAINGRIDUIVISUALISER_H__