taskswitcher/taskswitcherui/taskswitcherapp/inc/tsfastswapareautils.h
branchRCL_3
changeset 102 ba63c83f4716
parent 93 b01126ce0bec
child 103 966d119a7e67
equal deleted inserted replaced
93:b01126ce0bec 102:ba63c83f4716
     1 /*
       
     2 * Copyright (c) 2008 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:  Fast swap area utilities classes
       
    15  *
       
    16 */
       
    17 
       
    18 #ifndef TSFASTSWAPAREAUTILS_H_
       
    19 #define TSFASTSWAPAREAUTILS_H_
       
    20 
       
    21 #include <e32base.h>
       
    22 
       
    23 // Forwar class declarations
       
    24 class CEikonEnv;
       
    25 class TAknLayoutRect;
       
    26 class CTsFastSwapTimer;
       
    27 class CTsFastSwapArea;
       
    28 class CTsFastSwapGrid;
       
    29 class CTsFswEntry;
       
    30 class CBitmapScaler;
       
    31 class CTsFastSwapAreaExtension;
       
    32 
       
    33 
       
    34 /**
       
    35  * Interface for observing timer class.
       
    36  */
       
    37 class MTsFastSwapTimerObserver
       
    38     {
       
    39 public:
       
    40     /**
       
    41      * Called when timer is completed
       
    42      */
       
    43     virtual void TimerCompletedL( CTsFastSwapTimer* aSource ) = 0;
       
    44     };
       
    45 
       
    46 
       
    47 
       
    48 /**
       
    49  * Timer class for handling timed events
       
    50  */
       
    51 class CTsFastSwapTimer : public CTimer
       
    52     {
       
    53 public:
       
    54     // Constructor
       
    55     CTsFastSwapTimer( MTsFastSwapTimerObserver& aObserver );
       
    56     // Destructor
       
    57     ~CTsFastSwapTimer();
       
    58     // 2nd phase constructor
       
    59     void ConstructL();
       
    60     
       
    61 private: // From CTimer
       
    62     void RunL();
       
    63     
       
    64 private: // Data
       
    65     MTsFastSwapTimerObserver* iObserver; // not own
       
    66     };
       
    67 
       
    68 
       
    69 
       
    70 /**
       
    71  * Asynchronous class for handling screenshots loading
       
    72  * and rescaling to achieve better quality. 
       
    73  */
       
    74 class CTsBitmapScaleTask : public CActive
       
    75     {
       
    76 public:
       
    77     CTsBitmapScaleTask( CTsFastSwapAreaExtension& aObserver );
       
    78     ~CTsBitmapScaleTask();
       
    79     void StartLD( CFbsBitmap* aSourceBitmap,
       
    80                   CFbsBitmap* aTargetBitmap );
       
    81 private:
       
    82     void RunL();
       
    83     void DoCancel();
       
    84 private:
       
    85     // Data
       
    86     CTsFastSwapAreaExtension& iObserver;
       
    87     CBitmapScaler* iScaler; // owned
       
    88     CFbsBitmap* iSourceBmp; // owned
       
    89     };
       
    90 
       
    91 
       
    92 
       
    93 /**
       
    94  * Utility class containg methods for fast swap area handling.
       
    95  */
       
    96 class CTsFastSwapAreaExtension: public CBase
       
    97     {
       
    98 
       
    99 public:
       
   100     
       
   101     /**
       
   102      * Two-phase constructor.
       
   103      * 
       
   104      * @param aRect Area where fast swap info & list should draw itself.
       
   105      * @param aParent Parent CoeControl. 
       
   106      */
       
   107     static CTsFastSwapAreaExtension* NewL( CTsFastSwapArea& aFastSwapArea,
       
   108                                        CEikonEnv& aEnv);
       
   109 
       
   110     /**
       
   111      * @copydoc NewL
       
   112      */
       
   113     static CTsFastSwapAreaExtension* NewLC( CTsFastSwapArea& aFastSwapArea,
       
   114                                         CEikonEnv& aEnv );
       
   115 
       
   116     /**
       
   117      * Destructor.
       
   118      */
       
   119     ~CTsFastSwapAreaExtension();
       
   120     
       
   121 private:
       
   122 
       
   123     /**
       
   124      * @copydoc NewL
       
   125      */
       
   126     void ConstructL();
       
   127 
       
   128     /**
       
   129      * C++ constructor.
       
   130      */
       
   131     CTsFastSwapAreaExtension( CTsFastSwapArea& aFastSwapArea,
       
   132                           CEikonEnv& aEnv );
       
   133     
       
   134 public:
       
   135     
       
   136     /**
       
   137      * Returns current screen orientation:
       
   138      * 
       
   139      * @return  1 if landscape, 0 if portait 
       
   140      */
       
   141     TInt GetCurrentScreenOrientation();
       
   142     
       
   143     /**
       
   144      * Retrieves variety value, based on current screen resolution.
       
   145      * 
       
   146      * @param  aVariety  result of the function, 0 value means portrait
       
   147      *                   value of 1 indicates landscape
       
   148      * @return  ETrue if screen resolution differs from vale returned by
       
   149      *          layout meta data functions.
       
   150      */
       
   151     TBool GetVariety( TInt& aVariety );
       
   152     
       
   153     /**
       
   154      * Returns rectangles for fast swap area controls
       
   155      */
       
   156     void GetFastSwapAreaRects( RArray<TAknLayoutRect>& aRects );
       
   157     
       
   158     /**
       
   159      * Returns the position of the given item inside grid world rect.
       
   160      * Returns point in the middle of the view rectangle.
       
   161      * 
       
   162      * @param  aItemIdx  index of the item for which calculation will be done
       
   163      */
       
   164     TPoint ItemViewPosition( TInt aItemIdx );
       
   165     
       
   166     /**
       
   167      * Returns index of the shown item, based on the logical
       
   168      * position of the grids view. Item that is closest to the
       
   169      * middle of screen is returned.
       
   170      * 
       
   171      * @param  aViewPos  grids view position. This must be point in
       
   172      *                   the middle of the view rectangle
       
   173      * @return  index of the item
       
   174      */
       
   175     TInt ViewToVisibleItem( const TPoint aViewPos );
       
   176     
       
   177     /**
       
   178      * Launches increasing pop-up feedback.
       
   179      */
       
   180     void LaunchPopupFeedback();
       
   181     
       
   182     /**
       
   183      * Retrieves and returns size for image graphics.
       
   184      */
       
   185     TSize PreferredImageSize();
       
   186     
       
   187     /**
       
   188      * Calculates the correct size if aspect ratio needs to be preserved.
       
   189      */
       
   190     TSize CalculateSizePreserveRatio(const TSize& aTargetAreaSize,
       
   191             const TSize& aSourceSize);
       
   192     
       
   193     /**
       
   194      * Makes a copy of the given bitmap.
       
   195      * Also scaled to the given size, but maintains aspect ratio,
       
   196      * so the size of the returned bitmap may be less then aSize.
       
   197      */
       
   198     CFbsBitmap* CopyBitmapL( TInt aFbsHandle, TSize aSize, TBool aIsScreenshot );
       
   199     
       
   200     /**
       
   201      * Duplicates handle to bitmap.
       
   202      */
       
   203     CFbsBitmap* DuplicateBitmapLC( TInt aFbsHandle );
       
   204     
       
   205     /**
       
   206      * Duplicates handle to bitmap.
       
   207      */
       
   208     void ScaleBitmapL( CFbsBitmap* aSourceBitmap,
       
   209             CFbsBitmap* aTargetBitmap );
       
   210     
       
   211     /**
       
   212      * Cancels ongoing scale tasks
       
   213      */
       
   214     void CancelScaleTasks();
       
   215     
       
   216     /**
       
   217      * Callback for updating task list.
       
   218      */
       
   219     void ScaleFinished( CTsBitmapScaleTask* iFinishedTask );
       
   220     
       
   221 private: // Data
       
   222     
       
   223     CTsFastSwapArea& iFastSwapArea;
       
   224     
       
   225     CEikonEnv& iEnv;
       
   226     
       
   227     RPointerArray<CTsBitmapScaleTask> iScaleTasks;
       
   228     
       
   229     };
       
   230 
       
   231 #endif /* TSFASTSWAPAREAUTILS_H_ */