emailuis/uicomponents/inc/fstextureloader.h
branchRCL_3
changeset 25 3533d4323edc
parent 0 8466d47a6819
equal deleted inserted replaced
24:d189ee25cf9d 25:3533d4323edc
       
     1 /*
       
     2 * Copyright (c) 2007-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: This file defines class CFsTextureLoader.
       
    15 *
       
    16 */
       
    17 
       
    18 
       
    19 #ifndef __FSTEXTURELOADER_H__
       
    20 #define __FSTEXTURELOADER_H__
       
    21 
       
    22 // INCLUDES
       
    23 #include <e32std.h>
       
    24 #include <e32base.h>
       
    25 //<cmail> removed __FS_ALFRED_SUPPORT flag 
       
    26 //#include <fsconfig.h>
       
    27 //</cmail> removed __FS_ALFRED_SUPPORT flag 
       
    28 //<cmail> SF
       
    29 #include <alf/alftexturemanager.h>
       
    30 //</cmail>
       
    31 #include "fstextureobserver.h"
       
    32 #include "fstextureloaderobserver.h"
       
    33 
       
    34 // FORWARD DECLARATIONS
       
    35 class CFsTexture;
       
    36 class CImageDecoder;
       
    37 class RFs;
       
    38 class TFrameInfo;
       
    39 
       
    40 // CLASS DECLARATION
       
    41 
       
    42 /**
       
    43 *  CFsTextureLoader
       
    44 *  Loader
       
    45 */
       
    46 class CFsTextureLoader
       
    47     : public CBase,
       
    48 
       
    49       public MAlfTextureLoadingCompletedObserver,
       
    50 
       
    51       public MFsTextureLoaderObserver
       
    52     {
       
    53     public:
       
    54         // Flags
       
    55         enum
       
    56             {
       
    57             EFlagNoneDefined,
       
    58             EFlagLoadSyncronously = 1 << 0,
       
    59             EFlagSetStatic = 1 << 1
       
    60             };
       
    61     public:
       
    62         // Internal view structure
       
    63         struct TView
       
    64             {
       
    65             TView& operator= ( const TView& aView );
       
    66             TInt iStart;
       
    67             TInt iLength;
       
    68             };
       
    69     public: // Constructor, destructor
       
    70         /**
       
    71          * 2-phased constructor
       
    72          * @param aManager Texture manager reference
       
    73          * @param aObserver Observer reference
       
    74          * @return Instance of loader
       
    75          */
       
    76 
       
    77         static CFsTextureLoader* NewL( CAlfTextureManager& aManager,
       
    78                                        MFsTextureObserver& aObserver 
       
    79                                      );
       
    80 
       
    81 
       
    82         /**
       
    83          * C++ Destructor
       
    84          */
       
    85         ~CFsTextureLoader();
       
    86         
       
    87     public: // New methods
       
    88         /**
       
    89          * Search texture
       
    90          * @param aImageFileName File criteria
       
    91          * @param aIndex Index, 0 by default
       
    92          * @return null, or first found texture from beginning to index
       
    93          */
       
    94         CFsTexture* SearchByImageName( const TDesC& aImageFileName, TInt* aIndex = NULL );
       
    95 
       
    96         /**
       
    97          * Search texture
       
    98          * @param aPos Position criteria
       
    99          * @param aIndex Index, 0 by default
       
   100          * @return null, or first found texture from beginning to index
       
   101          */
       
   102         CFsTexture* SearchByPos( const TInt& aPos, TInt* aIndex = NULL );
       
   103 
       
   104         /**
       
   105          * Search texture
       
   106          * @param aId
       
   107          */
       
   108         CFsTexture* SearchById( TInt aId );
       
   109 
       
   110         /**
       
   111          * Create texture
       
   112          * @param aImageFileName File
       
   113          * @param aFlag Hitchock flags
       
   114          * @param aId Texture unique id, 0 for automation 
       
   115          * @param aLoaderFlags Texture loader flags
       
   116          * @return Texture reference
       
   117          */
       
   118 
       
   119         CFsTexture& LoadTextureL( const TDesC& aImageFileName,
       
   120                                   TSize aTextureMaxSize = TSize( 0, 0 ),
       
   121                                   TAlfTextureFlags aFlags = EAlfTextureFlagDefault,
       
   122                                   TInt aId = 0,
       
   123                                   const TInt& aLoaderFlags = 0
       
   124                                 ); 
       
   125 
       
   126 
       
   127         /**
       
   128          * Create texture from bitmaps
       
   129          * @param aBitmap Bitmap
       
   130          * @param aBitmapMask Mask
       
   131          * @param aFlag Hitchock flags
       
   132          * @param aId Texture unique id, 0 for automation 
       
   133          * @param aLoaderFlags Texture loader flags
       
   134          * @return Texture reference
       
   135          */
       
   136 
       
   137         CFsTexture& AppendBitmapL( CFbsBitmap* aBitmap,
       
   138                                    CFbsBitmap* aBitmapMask,
       
   139                                    TAlfTextureFlags aFlags = EAlfTextureFlagDefault,
       
   140                                    TInt aId = 0,
       
   141                                    const TInt& aLoaderFlags = 0
       
   142                                  );
       
   143 
       
   144         
       
   145         /**
       
   146          * Set view
       
   147          * @param aStart Beginning of view area
       
   148          * @param aLength View area length
       
   149          */
       
   150         void SetViewL( const TInt& aStart, const TInt& aLength );
       
   151 
       
   152         /**
       
   153          * Set view
       
   154          * @param aView View structure
       
   155          */
       
   156         void SetViewL( const TView& aView );
       
   157 
       
   158         /**
       
   159          * Return current view area
       
   160          * @return View structure
       
   161          */
       
   162         TView View() const;
       
   163 
       
   164         /**
       
   165          * Unload texture
       
   166          * @param aTexture Texture reference
       
   167          */
       
   168         void Unload( CFsTexture& aTexture );
       
   169 
       
   170         /**
       
   171          * Texture count
       
   172          * @return Number of textures
       
   173          */
       
   174         TInt TextureCount() const;
       
   175 
       
   176         /**
       
   177          * Get texture by index
       
   178          * @param aIndex Texture index
       
   179          * @return null, or address of texture
       
   180          */
       
   181         CFsTexture* TextureAtIndex( const TInt& aIndex );
       
   182 
       
   183         /**
       
   184          * Read bitmap properties
       
   185          * @param aImageFileName Filename
       
   186          * @param aFrameInfo Bitmap properties as return value
       
   187          */
       
   188         static void GetFrameInfoL( const TDesC& aImageFileName, 
       
   189                                    TFrameInfo& aFrameInfo 
       
   190                                  );
       
   191         
       
   192         /**
       
   193          * Set default timeout for unloading the textures
       
   194          * @param aTimeOut Timeout in microseconds, 10 sec. by default
       
   195          */
       
   196         void SetDefaultTimeOut( const TTimeIntervalMicroSeconds32& aTimeOut );
       
   197 
       
   198     private: // New methods
       
   199 
       
   200         /**
       
   201          * Load texture
       
   202          * @param aTexture Address of texture
       
   203          */
       
   204         void LoadL( CFsTexture* aTexture = NULL );
       
   205 
       
   206         /**
       
   207          * Unload texture
       
   208          */
       
   209         void UnloadL();
       
   210 
       
   211         /**
       
   212          * Return texture id
       
   213          * @return Unique id
       
   214          */
       
   215         TInt GetId();
       
   216     private: // Constructors
       
   217         /**
       
   218          * C++ constructor
       
   219          * @param aManager Texture manager reference
       
   220          * @param aObserver Observer reference
       
   221          */
       
   222 
       
   223         CFsTextureLoader( CAlfTextureManager& aManager,
       
   224                           MFsTextureObserver& aObserver
       
   225                         );
       
   226 
       
   227 
       
   228         /**
       
   229          * 2nd phase constructor
       
   230          */
       
   231         void ConstructL();
       
   232         
       
   233     private: // MHuiTextureLoadingCompletedObserver / MAlfTextureLoadingCompletedObserver
       
   234 
       
   235         /**
       
   236          * Called to notify the observer that loading of a texture has
       
   237          * been completed.
       
   238          * @param aTexture Reference to the texture that has been loaded.
       
   239          * @param aTextureId Id of the texture in the texture manager. Can be used
       
   240          * to identify the loaded texture, provided that an id was assigned to the
       
   241          * texture.
       
   242          * @param aErrorCode KErrNone if the load was successful, otherwise one of
       
   243          * the system-wide error codes indicating reason why the texture loading
       
   244          * failed.
       
   245          * @note One should not commence loading of a new texture in this callback method.
       
   246          */
       
   247         void TextureLoadingCompleted( CAlfTexture& aTexture,
       
   248                                       TInt aTextureId,
       
   249                                       TInt aErrorCode
       
   250                                     );
       
   251 
       
   252 
       
   253     private: // MFsTextureLoaderObserver 
       
   254         /**
       
   255          * TimerExpiredL
       
   256          * @param aTexture Texture reference
       
   257          */
       
   258         virtual void TimerExpiredL( CFsTexture& aTexture );
       
   259 
       
   260         /**
       
   261          * Loader timeout
       
   262          * @param aTimeOut Timeout in microseconds as return value
       
   263          */
       
   264         virtual void DefaultTimeOut( TTimeIntervalMicroSeconds32& aTimeOut );
       
   265 
       
   266         /**
       
   267          * Texture position updated
       
   268          * @param aTexture Texture reference
       
   269          */
       
   270         virtual void PosUpdated( CFsTexture& aTexture );
       
   271 
       
   272         /**
       
   273          * Texture destroyed
       
   274          * @param aTexture Texture reference
       
   275          */
       
   276         virtual void Deleted( CFsTexture& aTexture );
       
   277         
       
   278         /**
       
   279          * Flags updated
       
   280          * @param aTexture Texture reference
       
   281          */
       
   282         virtual void FlagsUpdated( CFsTexture& aTexture );
       
   283 
       
   284         /**
       
   285          * Size updated
       
   286          * @param aTexture Texture reference
       
   287          */
       
   288         virtual void SizeUpdated( CFsTexture& aTexture );
       
   289 
       
   290     private: // data
       
   291         /** Texture manager reference */
       
   292 
       
   293         CAlfTextureManager& iManager;
       
   294 
       
   295         
       
   296         /**  File system reference */
       
   297         RFs& iFs;
       
   298 
       
   299         /** Owns: */
       
   300         CArrayPtr<CFsTexture>* iTextures;
       
   301 
       
   302         /**  View context */
       
   303         TView iView;
       
   304 
       
   305         /**  Scheduler */
       
   306         CActiveSchedulerWait iWait;
       
   307         
       
   308         /** Observer reference */
       
   309         MFsTextureObserver& iObserver;
       
   310         
       
   311         /** Id counter */
       
   312         TInt iId;
       
   313         
       
   314         /** Default timeout */
       
   315         TTimeIntervalMicroSeconds32 iDefaultTimeOut;        
       
   316     };
       
   317 
       
   318 #endif // __FSTEXTURELOADER_H__
       
   319 
       
   320 // End of File