phonebookui/Phonebook2/UIControls/inc/CPbk2ThumbnailScaler.h
branchRCL_3
changeset 20 f4a778e096c2
parent 0 e686773b3f54
equal deleted inserted replaced
19:5b6f26637ad3 20:f4a778e096c2
       
     1 /*
       
     2 * Copyright (c) 2002-2007 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: 
       
    15 *       Class for scaling bitmaps for the thumbnail control.
       
    16 *
       
    17 */
       
    18 
       
    19 
       
    20 #ifndef CPBK2THUMBNAILSCALER_H
       
    21 #define CPBK2THUMBNAILSCALER_H
       
    22 
       
    23 // INCLUDES
       
    24 #include <e32base.h>
       
    25 
       
    26 // FORWARD DECLARATIONS
       
    27 class CFbsBitmap;
       
    28 class CBitmapScaler;
       
    29 
       
    30 /**
       
    31  * Observer interface for the scaling process.
       
    32  */
       
    33 NONSHARABLE_CLASS(MPbk2ThumbnailScalerObserver)
       
    34     {
       
    35     public:
       
    36         /**
       
    37          * Called when the thumbnail scaling completes.
       
    38          * @param aError KErrNone if the scaling was done successfully,
       
    39          *               otherwise one of the system wide error codes.
       
    40          * @param aBitmap Result of the scaling operation
       
    41          *                callee takes the ownership.
       
    42          */
       
    43         virtual void ThumbnailScalingComplete
       
    44             (TInt aError, CFbsBitmap* aBitmap) = 0;
       
    45     };
       
    46 
       
    47 /**
       
    48  * Class for scaling bitmaps for the thumbnail control.
       
    49  */
       
    50 NONSHARABLE_CLASS(CPbk2ThumbnailScaler) : 
       
    51         public CActive
       
    52     {
       
    53     public:
       
    54         /**
       
    55          * Static 2-phased constructor.
       
    56          * @param aObserver Observer for the scaling process.
       
    57          * @return Newly created instance of CPbk2ThumbnailScaler.
       
    58          */
       
    59         static CPbk2ThumbnailScaler* NewL
       
    60             (MPbk2ThumbnailScalerObserver& aObserver);
       
    61 
       
    62         /**
       
    63          * Standard C++ destructor.
       
    64          */
       
    65         ~CPbk2ThumbnailScaler();
       
    66     public: // interface
       
    67         /**
       
    68          * Creates thumbnail from the givan bitmap.
       
    69          * @param aBitmap Bitmap that will be converted to thumbnail.
       
    70          *                This class takes ownership of the bitmap.
       
    71          */
       
    72         void CreateThumbnail(CFbsBitmap* aBitmap);
       
    73 
       
    74     private: // From CActive
       
    75         void RunL();
       
    76         void DoCancel();
       
    77         TInt RunError(TInt aError);
       
    78 
       
    79     private: // Implementation
       
    80         /**
       
    81          * C++ constructor.
       
    82          * @param aObserver Observer for the scaling process.
       
    83          */
       
    84         CPbk2ThumbnailScaler(MPbk2ThumbnailScalerObserver& aObserver);
       
    85 
       
    86         /**
       
    87          * Starts the scaling process.
       
    88          * @param aBitmap The bitmap to be scaled.
       
    89          * @param aSize Target size of the bitmap.
       
    90          */
       
    91         void StartScaleL(CFbsBitmap* aBitmap, const TSize& aSize);
       
    92 
       
    93         /**
       
    94          * Crops the bitmap if needed.
       
    95          * @param aBitmap Bitmap to be cropped.
       
    96          */
       
    97         void DoCropL(CFbsBitmap* aBitmap);
       
    98     private: // Data
       
    99         /// Ref: Observer for the scaling process.
       
   100         MPbk2ThumbnailScalerObserver& iObserver;
       
   101         /// Own: Bitmap scaler
       
   102         CBitmapScaler* iScaler;
       
   103         /// Own: The bitmap that is scaled.
       
   104         CFbsBitmap* iBitmap;
       
   105     };
       
   106 
       
   107 #endif // CPBK2THUMBNAILSCALER_H
       
   108 //End of file