uifw/AknGlobalUI/AknCapServer/inc/AknFastswapWindowControl.h
changeset 0 2f259fa3e83a
child 4 8ca85d2f0db7
child 47 2f0c06423c72
equal deleted inserted replaced
-1:000000000000 0:2f259fa3e83a
       
     1 /*
       
     2 * Copyright (c) 2002-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:  Control container for fastswap
       
    15 *
       
    16 */
       
    17 
       
    18 #ifndef __AKNFASTSWAPWINDOWCONTROL_H__
       
    19 #define __AKNFASTSWAPWINDOWCONTROL_H__
       
    20 
       
    21 // INCLUDES
       
    22 #include <AknPopupFader.h>
       
    23 #include <eiklbo.h>
       
    24 #include <coecntrl.h>
       
    25 #include <eikcmobs.h>
       
    26 #include <bldvariant.hrh>
       
    27 #include <apgcli.h>
       
    28 #include <coecobs.h> // MCoeControlObserver
       
    29 
       
    30 #include <WidgetRegistryClient.h>
       
    31 #include <eikmobs.h>
       
    32 
       
    33 // CONSTANTS
       
    34 
       
    35 // FORWARD DECLARATIONS
       
    36 class CAknQueryDialog;
       
    37 class CAknsFrameBackgroundControlContext;
       
    38 class CAknCapAppServerAppUi;
       
    39 class CEikFormattedCellListBox;
       
    40 class CAknGrid;
       
    41 class CEikButtonGroupContainer;
       
    42 class CGulIcon;
       
    43 class CAknInfoPopupNoteController;
       
    44 class CEikLabel;
       
    45 class CAknAlwaysShownAppList;
       
    46 
       
    47 class CAknWidgetList;
       
    48 class CAknChoiceList;
       
    49 class CAknStylusPopUpMenu;
       
    50 class CAknLongTapAnimation;
       
    51 class CPeriodic;
       
    52 class CAknPointerEventSuppressor;
       
    53 class CRepository;
       
    54 // CLASS DECLARATION
       
    55 
       
    56 /**
       
    57  *  Control container for fastswap.
       
    58  */
       
    59 NONSHARABLE_CLASS(CAknFastSwapWindowControl) : 
       
    60     public CCoeControl,
       
    61     public MEikListBoxObserver,
       
    62     public MAknFadedComponent,
       
    63     public MEikMenuObserver,
       
    64     public MCoeControlObserver
       
    65     {
       
    66 public: // Constructors and destructor
       
    67     /**
       
    68      * C++ default constructor.
       
    69      * @param aAppUi AppUi of Eikon server.
       
    70      */
       
    71     CAknFastSwapWindowControl( CAknCapAppServerAppUi& aAppUi );
       
    72     
       
    73     /**
       
    74      * Two-phased constructor.
       
    75      */
       
    76     void ConstructL();
       
    77     
       
    78     /**
       
    79      * Destructor.
       
    80      */
       
    81     ~CAknFastSwapWindowControl();
       
    82 
       
    83 public: // New functions
       
    84     /**
       
    85      * Called from akncapserver appui to run fastswap.
       
    86      */
       
    87     void RunFastSwapL();
       
    88     
       
    89     /**
       
    90      * Called from akncapserver appui to close fastswap.
       
    91      */
       
    92     void CloseFastSwap();
       
    93     
       
    94     /**
       
    95      * Updates window group lists (the list of applications).
       
    96      *
       
    97      * @param        aWaitForWGRemoval Changes are only made if a deleted 
       
    98      *               application has been removed from the window group list. 
       
    99      * @return       ETrue if the window group list has changed.
       
   100      *               EFalse if the window group list hasn't changed.
       
   101      */
       
   102     TBool InitializeWindowGroupListL( TInt aWaitForWGRemoval );
       
   103     
       
   104     /**
       
   105      * Calls InitializeWindowGroupListL() and returns the number of 
       
   106      * the window groups visible to the user.
       
   107      * 
       
   108      * @return        Number of winfow groups found in the system.
       
   109      */
       
   110     TInt VisibleWindowGroupsCountL();
       
   111     
       
   112     /**
       
   113      * Fast swap window is visible on the screen.
       
   114      *
       
   115      * @return        ETrue if full functional and visible.
       
   116      *                EFalse if in closed mode.
       
   117      */        
       
   118     TBool IsDisplayed(); 
       
   119     
       
   120     /**
       
   121      * Performs a short apps key press action.
       
   122      */
       
   123     void HandleShortAppsKeyPressL();
       
   124     
       
   125     /**
       
   126      * Performs a long apps key press action.
       
   127      */
       
   128     void HandleLongAppsKeyPressL();
       
   129     
       
   130     /**
       
   131      * Performs a long apps key press action.
       
   132      */
       
   133     void HandleChangeInWindowGroupListL();
       
   134     
       
   135     /**
       
   136      * Show tooltip when touch input is used.
       
   137      * Also AknFastSwapWindowGrid uses this when
       
   138      * drag scrolled to new item.
       
   139      *
       
   140      * @param aPointerOverItem      Is pointer currently over item in grid.
       
   141      */       
       
   142     void ShowTooltipTouchL(TBool aPointerOverItem);
       
   143     
       
   144 public: // Functions from base classes.
       
   145     /**
       
   146      * From CCoeControl    
       
   147      * Function where control's drawing is done.
       
   148      *
       
   149      * @param aRect Control's area.
       
   150      */
       
   151     void Draw( const TRect &aRect ) const;
       
   152     
       
   153     void HandleResourceChange( TInt aType );
       
   154     
       
   155     /**
       
   156      * Needed to handle background animation.
       
   157      */
       
   158     void FocusChanged( TDrawNow aDrawNow );
       
   159     
       
   160     /**
       
   161      * Overloads CCoeControl::SizeChanged. Needed to handle highlight animation.
       
   162      */
       
   163     void SizeChanged();
       
   164 
       
   165 private:
       
   166     /**
       
   167      * From CCoeControl.
       
   168      * Key event handling
       
   169      *
       
   170      * @return TKeyResponse  Indicates whether or not the key event was used by this control.
       
   171      * @param aKeyEvent      Key event.
       
   172      * @param aType          Type of key event.
       
   173      */
       
   174     TKeyResponse OfferKeyEventL( const TKeyEvent& aKeyEvent, TEventCode aType );
       
   175     
       
   176     /**
       
   177      * From MEikCommandObserver.
       
   178      *
       
   179      * @param aCommandId     Id of command.
       
   180      */
       
   181     void ProcessCommandL(TInt aCommandId );
       
   182     
       
   183     /**
       
   184      * From MEikListBoxObserver.
       
   185      *
       
   186      * @param aListBox        List handling the event.
       
   187      * @param aEventType      Type of listbox event.
       
   188      */
       
   189     void HandleListBoxEventL( CEikListBox* aListBox, TListBoxEvent aEventType );
       
   190 
       
   191     /**
       
   192      * From MCoeControlObserver.
       
   193      *
       
   194      * @param aControl        Control sending the event
       
   195      * @param aEventType      Event type
       
   196      */
       
   197     void HandleControlEventL(CCoeControl *aControl, TCoeEvent aEventType);
       
   198     
       
   199     /**
       
   200      * From CCoeControl      Method handling the pointer events while the fsw is used.
       
   201      *
       
   202      * @param aPointerEvent  Information about the event.
       
   203      */
       
   204     void HandlePointerEventL( const TPointerEvent &aPointerEvent );
       
   205     
       
   206     /**
       
   207      * from MEikMenuObserver
       
   208      * @param aMenuControl The menu control.
       
   209 	 * @param aEmphasis ETrue to emphasize the menu, EFalse otherwise
       
   210      */
       
   211     void SetEmphasis(CCoeControl* aMenuControl,TBool aEmphasis);
       
   212     
       
   213 private: // Functions that create/update/delete the child controls  
       
   214     /**
       
   215      * Updates UI components.
       
   216      */        
       
   217     void UpdateViewL();
       
   218     
       
   219     /**
       
   220      * Creates CCoeControlArray for child controls.
       
   221      */
       
   222     void CreateComponentArrayL();
       
   223     
       
   224     /**
       
   225      * Grid construction, called from CAknFastswapWindowControl:ConstructL().
       
   226      */
       
   227     void CreateGridL();
       
   228     
       
   229     /**
       
   230      * Updates grid.
       
   231      */
       
   232     void UpdateGridL();
       
   233     
       
   234     /**
       
   235      * Creates item (text and icon) arrays.
       
   236      */
       
   237     void CreateItemArraysL();
       
   238     
       
   239     /**
       
   240      * Creates updated item arrays.
       
   241      */
       
   242     void UpdateItemArraysL();
       
   243     
       
   244     /**
       
   245      * Clears the item arrays from dynamically loaded content.
       
   246      *
       
   247      * @param     TBool aCompress if the size of the item arrays
       
   248      *            is compressed as well.
       
   249      */
       
   250     void ClearItemArrays( TBool aCompress );
       
   251     
       
   252     /**
       
   253      * Creates tooltip control for fsw.
       
   254      */
       
   255     void CreateTooltipL();
       
   256     
       
   257     /**
       
   258      * Shows the tooltip control for highlighted application icon.
       
   259      */        
       
   260     void UpdateTooltipL();
       
   261     
       
   262     /**
       
   263      * Creates title for fsw.
       
   264      */
       
   265     void CreateLabelL();
       
   266     
       
   267     /**
       
   268      * Update label layouts and skinning.
       
   269      */        
       
   270     void UpdateLabelL(); 
       
   271     
       
   272     /**
       
   273      * Reserves the default application icon for the low memory situation.
       
   274      */
       
   275     void UpdateDefaultAppIconL();
       
   276             
       
   277     /**
       
   278      * Reserves heading icon for the heading pane.
       
   279      */        
       
   280     void UpdateHeadingIconL();
       
   281     
       
   282     /**
       
   283      * Update control context (especially rect size).
       
   284      */
       
   285     void UpdateControlContext();
       
   286     
       
   287     /**
       
   288      * CBA construction, called from CAknFastswapWindowControl:ConstructL().
       
   289      */
       
   290     void CreateCbaL();
       
   291        
       
   292 private: // Utility functions 
       
   293     /**
       
   294      * Fades the background application.
       
   295      *
       
   296      * @param aFade        State of fading.
       
   297      */
       
   298     void FadeBackground( TBool aFade );
       
   299     
       
   300     /**
       
   301      * Either Brings a task forward and dismisses fastswap or launches a new application.
       
   302      *
       
   303      * @param aIndex      The grid index of the task to switch to.
       
   304      */
       
   305     void SwitchToApplicationL( TInt aIndex );
       
   306     
       
   307     /**
       
   308      * Brings a task forward and dismisses fastswap.
       
   309      *
       
   310      * @param aWgId       The window group of the task.
       
   311      */
       
   312     void SwitchToTask( TInt aWgId );
       
   313     
       
   314     /**
       
   315      * Launches an application to the phone memory based on the given application uid.
       
   316      *
       
   317      * @param aAppUid      The uid of the application.
       
   318      */
       
   319     void LaunchAppL( TUid aAppUid );
       
   320     
       
   321     /**
       
   322      * Cleanup and closes FastSwap.
       
   323      */
       
   324     static void CleanupRunFastSwap( TAny* aThis );
       
   325     
       
   326     /**
       
   327      * Closes named application.
       
   328      * 
       
   329      * @param aName App name (given in fastswap grid).
       
   330      */
       
   331     TBool OfferCloseSelectedAppL( const TDesC& aName );
       
   332     
       
   333     /**
       
   334      * Test if given window id is among fastswaps shown windows ids
       
   335      * 
       
   336      * @param aWgId Id to be tested,
       
   337      */
       
   338     TBool IsWgIdInShownList( TInt aWgId );
       
   339     
       
   340     /**
       
   341      * Calculates Fastswap window size and position in the screen.
       
   342      * 
       
   343      * @return    TRect the window rect.
       
   344      */                
       
   345     TRect FastSwapWindowRect();
       
   346     
       
   347     /** 
       
   348      * Calculates and returns the icon size used in the fast swap list.
       
   349      *
       
   350      * @return Icon size.
       
   351      */
       
   352     TSize IconSize();      
       
   353     
       
   354     /**
       
   355      * Deletes aCount number of icons from the icon array starting from index aIndex.
       
   356      *
       
   357      * @param     TInt aIndex Index from which deletion begins .
       
   358      * @param     TInt ACount How many icons are deleted.
       
   359      */
       
   360     void DeleteIcons( TInt aIndex, TInt aCount );
       
   361     
       
   362     /**
       
   363      * Returns the number of rows shown in the fast swap window (1-3).
       
   364      *
       
   365      * @return Number of rows.
       
   366      */
       
   367     TInt NumberOfVisibleRows();
       
   368      
       
   369     /**
       
   370      * Shows the tooltip control for highlighted application icon.
       
   371      *
       
   372      * @return Name of the application with current highlight.
       
   373      */        
       
   374     TPtrC CurrentAppName();
       
   375     
       
   376     /**
       
   377      * The rect of current highlighted grid item.
       
   378      *
       
   379      * @return Rect of the selected grid item.
       
   380      */
       
   381     TRect CurrentGridItemRect();
       
   382     
       
   383     /**
       
   384      * Application icon is added to the item arrays.
       
   385      *
       
   386      * @param    TUid aAppUid the application uid.  
       
   387      * @return   ETrue addition was successful.
       
   388      *           EFalse icon wasn't added to the list.
       
   389      */        
       
   390     TBool AddIconToArrayL( TUid aAppUid );      
       
   391 
       
   392 private: // From MObjectProvider.
       
   393     TTypeUid::Ptr MopSupplyObject( TTypeUid aId );
       
   394     
       
   395     virtual TInt CountFadedComponents();
       
   396     virtual CCoeControl* FadedComponent( TInt aIndex );
       
   397     
       
   398     /**
       
   399      * Try to close a application.
       
   400      * @param aIndex  the index of the current item. 
       
   401      * @param aIsShift whether press Modifier key  
       
   402      */
       
   403     void TryCloseApplicationL(TInt aIndex, TBool aIsShift = EFalse);
       
   404     
       
   405     /**
       
   406      * Set a flag that directs Stylus Popup Menu is Hidden .
       
   407      */
       
   408     void SetHiddenFlag();
       
   409     
       
   410     /**
       
   411      * create a stylus popup menu .
       
   412      */
       
   413     void CreateStylusPopupMenuL();
       
   414     
       
   415     /**
       
   416      * Show stylus popup menu .
       
   417      */
       
   418     void ShowPopupMenuL();
       
   419     
       
   420     /**
       
   421      * Handle long Tap.
       
   422      * @param aEvent current pointer event 
       
   423      */
       
   424     void PointerEventL( const TPointerEvent& aEvent );
       
   425         
       
   426     /**
       
   427      * Start long tap animation.
       
   428      */    
       
   429     void StartAnimationL();
       
   430     
       
   431     /**
       
   432      * Stop long tap animation.
       
   433      */   
       
   434     void StopAnimation();   
       
   435     
       
   436     /**
       
   437      * Start showing long tap animation.
       
   438      */ 
       
   439     void ShowAnimationL();
       
   440     
       
   441     /**
       
   442      * A call back function used by iTimeOut.
       
   443      * @param aPtr a ponter to any object 
       
   444      */ 
       
   445     static TInt TimeOutCallBackL( TAny* aPtr );
       
   446     
       
   447     /**
       
   448      * A call back function used by iToolTipTimer.
       
   449      * @param aPtr a ponter to any object 
       
   450      */ 
       
   451     static TInt ToolTipTimeOutCallBackL( TAny* aPtr );
       
   452     
       
   453     /**
       
   454      * hide Tooltip after pointer up event .
       
   455      */ 
       
   456     void HideTooltip();
       
   457     
       
   458     void CancelAnimationAndPressDownEffect();
       
   459         
       
   460 private: // Data
       
   461     struct SWindowGroupInfo
       
   462         {
       
   463         TInt iWgId;
       
   464         TBool iIsSystemApp;
       
   465         };
       
   466         
       
   467     // for animation 
       
   468     enum TFswLongTapState
       
   469         {
       
   470         EWaiting, 				// normal state
       
   471         EWaitingForAnimation,	// Only "Pen down" event received, CTimer started
       
   472         EShowingAnimation,		// Long tap animation started
       
   473         EShowingPressedDownEffect // Pressed down effect started  
       
   474         };
       
   475         
       
   476     CAknGrid* iGrid;
       
   477     
       
   478     CArrayFixFlat<SWindowGroupInfo>* iShownWgIds;
       
   479     RArray<RWsSession::TWindowGroupChainInfo>* iAllWgIds;
       
   480     CDesCArray* iItemTextArray;
       
   481     TInt iNumberOfWGs;
       
   482     TAknPopupFader iPopupFader;
       
   483     TInt iBackgroundWgId;
       
   484     CEikButtonGroupContainer* iCba;
       
   485     CAknCapAppServerAppUi& iAppUi;
       
   486     TBool iIsDisplayed;
       
   487     CArrayPtrFlat<CGulIcon>* iIconArray;
       
   488     CAknQueryDialog* iConfirmCloseDialog;
       
   489     TInt iConfirmCloseWgId;
       
   490     CAknsFrameBackgroundControlContext *iFrameContext;
       
   491     
       
   492     // Low memory situation handling.
       
   493     TBool iLowMemory;  
       
   494     TBool iLowMemIcons; 
       
   495     
       
   496     // Previous mdca count.
       
   497     TInt iOldCount;
       
   498     
       
   499     // Default application icon fsw uses if there is no memory left for individual application 
       
   500     // icons.
       
   501     CGulIcon* iDefaultAppIcon;
       
   502     
       
   503     // AppArc session is created only once and handle is stored in the class.
       
   504     TBool iAppArcSessionInitiated;
       
   505     RApaLsSession iAppArcSession;
       
   506 
       
   507     /** Contains data of running widgets */
       
   508     CAknWidgetList* iWidgetList;
       
   509     friend class CAknWidgetList;
       
   510     /** Window group id of Widget application */
       
   511     TInt iWidgetAppUiWgId;
       
   512     TBool iWidgetsSupported;
       
   513 
       
   514     // Tooltip that shows application names.
       
   515     CAknInfoPopupNoteController* iTooltip;
       
   516     CEikLabel* iLabel;        
       
   517     CGulIcon* iHeadingIcon;
       
   518     
       
   519     CAknAlwaysShownAppList* iAlwaysShownList;
       
   520     friend class CAknAlwaysShownAppList;
       
   521     TBool iDisableFSWEffect;
       
   522     TBool iStylusDownIn;
       
   523     TBool iTooltipModeTouch;
       
   524     TBool iTransparencyEnabled;
       
   525     
       
   526     CAknStylusPopUpMenu* iPopupMenu; // Own 
       
   527     TBool iIsStylusPopupShow; 
       
   528     TFswLongTapState iState; //state variant
       
   529     CAknLongTapAnimation* iLongTapAnimation; //own
       
   530 
       
   531     CPeriodic* iTimeOut; //own, used for showing Animation and Stylus popup menu
       
   532     
       
   533     TBool iItemDraggingActioned;
       
   534 
       
   535     TPoint iAnimationPosition; // will show animation in this position 
       
   536       
       
   537     CPeriodic* iToolTipTimer; //own, used for showing ToolTip   
       
   538     TBool iIsAnimationShowing;    
       
   539     TBool iIsPointerDownOutOfGrid;
       
   540     TInt iFirstAppWgId;  
       
   541     TBool iIsClosing;
       
   542     TTime iPressDownTime;
       
   543     
       
   544     /** Indicates that an item has received highlight. */
       
   545     TBool iItemHighlighted;
       
   546 
       
   547     // Own. CenRep object for themes application keys.
       
   548     CRepository* iThemesAppRepository;
       
   549     };
       
   550 
       
   551 #endif // __AKNFASTSWAPWINDOWCONTROL_H__   
       
   552             
       
   553 // End of File