emailuis/uicomponents/src/fstexture.cpp
changeset 0 8466d47a6819
equal deleted inserted replaced
-1:000000000000 0:8466d47a6819
       
     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 implements class CFsTexture.
       
    15 *
       
    16 */
       
    17 
       
    18 
       
    19 // INCLUDE FILES
       
    20 #include "emailtrace.h"
       
    21 #include <e32std.h>
       
    22 #include <fbs.h>
       
    23 #include <bitmaptransforms.h>
       
    24 #include "fsbitmapprovider.h"
       
    25 #include "fstexture.h"
       
    26 #include "fstextureloader.h"
       
    27 
       
    28 // CONSTANTS
       
    29 
       
    30 // ============================= LOCAL FUNCTIONS  =============================
       
    31 
       
    32 // ----------------------------------------------------------------------------
       
    33 // TimerCallbackL
       
    34 // Timeout callback
       
    35 // (may leave)
       
    36 // Status : Draft
       
    37 // ----------------------------------------------------------------------------
       
    38 //
       
    39 TInt TimerCallbackL( TAny* aModel )
       
    40     {
       
    41     static_cast<CFsTexture*>( aModel )->TimerExpiredL();
       
    42 
       
    43     return 1;
       
    44     }  
       
    45 
       
    46 // ============================= MEMBER FUNCTIONS =============================
       
    47 
       
    48 // ----------------------------------------------------------------------------
       
    49 // CFsTexture::NewL
       
    50 // Two-phased constructor
       
    51 // (static, may leave)
       
    52 // Status : Draft
       
    53 // ----------------------------------------------------------------------------
       
    54 //
       
    55 
       
    56 CFsTexture* CFsTexture::NewL( CAlfTexture& aTexture,
       
    57                               MFsTextureLoaderObserver& aObserver,
       
    58                               CFsBitmapProvider* aProvider,
       
    59                               const TInt aId
       
    60                             )
       
    61 
       
    62     {
       
    63     FUNC_LOG;
       
    64     CFsTexture* pic = new (ELeave) CFsTexture( aTexture, 
       
    65                                                aObserver, 
       
    66                                                aProvider,
       
    67                                                aId
       
    68                                              );
       
    69     CleanupStack::PushL( pic );
       
    70     pic->ConstructL();
       
    71     CleanupStack::Pop( pic );
       
    72     
       
    73     return pic;
       
    74     }
       
    75 
       
    76 // ----------------------------------------------------------------------------
       
    77 // CFsTexture::CFsTexture
       
    78 // C++ Constructor
       
    79 // Status : Draft
       
    80 // ----------------------------------------------------------------------------
       
    81 // 
       
    82 
       
    83 CFsTexture::CFsTexture( CAlfTexture& aTexture,
       
    84                         MFsTextureLoaderObserver& aObserver,
       
    85                         CFsBitmapProvider* aProvider,
       
    86                         const TInt aId
       
    87                       )
       
    88 
       
    89     : iTexture( aTexture ),
       
    90       iObserver( aObserver ),
       
    91       iProvider( aProvider ),
       
    92       iId( aId )     
       
    93     {
       
    94     FUNC_LOG;
       
    95     return;
       
    96     }                         
       
    97 // ----------------------------------------------------------------------------
       
    98 // CFsTexture::~CFsTexture
       
    99 // C++ Destructor
       
   100 // Status : Draft
       
   101 // ----------------------------------------------------------------------------
       
   102 //
       
   103 CFsTexture::~CFsTexture()
       
   104     {
       
   105     FUNC_LOG;
       
   106     StopTimer();
       
   107 
       
   108     iObserver.Deleted( *this );
       
   109     
       
   110     if ( iProvider )
       
   111         {
       
   112         delete iProvider;
       
   113         iProvider = NULL;
       
   114         }
       
   115     
       
   116     return;
       
   117     }
       
   118 
       
   119 // ----------------------------------------------------------------------------
       
   120 // CFsTexture::Pos
       
   121 // Return bitmap position, internal for the application
       
   122 // Status : Draft
       
   123 // ----------------------------------------------------------------------------
       
   124 //
       
   125 TInt CFsTexture::Pos() const
       
   126     {
       
   127     FUNC_LOG;
       
   128     return iPos;
       
   129     }
       
   130 
       
   131 // ----------------------------------------------------------------------------
       
   132 // CFsTexture::SetPos
       
   133 // Set bitmap position, internal for the application
       
   134 // Status : Draft
       
   135 // ----------------------------------------------------------------------------
       
   136 //
       
   137 void CFsTexture::SetPos( const TInt& aPos )
       
   138     {
       
   139     FUNC_LOG;
       
   140     iPos = aPos;
       
   141     iObserver.PosUpdated( *this );
       
   142     
       
   143     return;
       
   144     }
       
   145     
       
   146 // ----------------------------------------------------------------------------
       
   147 // CFsTexture::TextSize
       
   148 // Return current size
       
   149 // Status : Draft
       
   150 // ----------------------------------------------------------------------------
       
   151 //
       
   152 TSize CFsTexture::TextSize() const
       
   153     {
       
   154     FUNC_LOG;
       
   155     return iTextSize;
       
   156     }
       
   157 
       
   158 // ----------------------------------------------------------------------------
       
   159 // CFsTexture::SetTextSize
       
   160 // Set new size
       
   161 // Status : Draft
       
   162 // ----------------------------------------------------------------------------
       
   163 //
       
   164 void CFsTexture::SetTextSize( const TSize& aSize )
       
   165     {
       
   166     FUNC_LOG;
       
   167     iTextSize = aSize;
       
   168     iObserver.SizeUpdated( *this );    
       
   169     
       
   170     return;
       
   171     }
       
   172     
       
   173 // ----------------------------------------------------------------------------
       
   174 // CFsTexture::TextFlags
       
   175 // Return flag status
       
   176 // Status : Draft
       
   177 // ----------------------------------------------------------------------------
       
   178 //
       
   179 TInt CFsTexture::TextFlags() const
       
   180     {
       
   181     FUNC_LOG;
       
   182     return iTextFlags;
       
   183     }
       
   184 
       
   185 // ----------------------------------------------------------------------------
       
   186 // CFsTexture::SetTextFlags
       
   187 // Set new flag status
       
   188 // Status : Draft
       
   189 // ----------------------------------------------------------------------------
       
   190 //
       
   191 void CFsTexture::SetTextFlags( const TInt& aFlags )
       
   192     {
       
   193     FUNC_LOG;
       
   194     iTextFlags = aFlags;
       
   195     iObserver.FlagsUpdated( *this );
       
   196     
       
   197     return;
       
   198     }
       
   199     
       
   200 // ----------------------------------------------------------------------------
       
   201 // CFsTexture::StopTimer
       
   202 // Stop unload timer and free timer resources
       
   203 // Status : Draft
       
   204 // ----------------------------------------------------------------------------
       
   205 //
       
   206 void CFsTexture::StopTimer()
       
   207     {
       
   208     FUNC_LOG;
       
   209 	if ( iUnloadTimer )
       
   210         {
       
   211 	    if ( iUnloadTimer->IsActive() )
       
   212             {
       
   213             iUnloadTimer->Cancel();
       
   214             }
       
   215         delete iUnloadTimer;
       
   216         iUnloadTimer = NULL;
       
   217         }
       
   218     
       
   219     return;
       
   220     }
       
   221 
       
   222 // ----------------------------------------------------------------------------
       
   223 // CFsTexture::TimerExpiredL
       
   224 // Timeout callback
       
   225 // (may leave)
       
   226 // Status : Draft
       
   227 // ----------------------------------------------------------------------------
       
   228 //
       
   229 void CFsTexture::TimerExpiredL()
       
   230     {
       
   231     FUNC_LOG;
       
   232     StopTimer();
       
   233     
       
   234     iObserver.TimerExpiredL( *this );
       
   235 
       
   236     return;
       
   237     }    
       
   238     
       
   239 // ----------------------------------------------------------------------------
       
   240 // CFsTexture::Texture
       
   241 // Return refence of Alf/Hitchock texture
       
   242 // Status : Draft
       
   243 // ----------------------------------------------------------------------------
       
   244 //
       
   245 CAlfTexture& CFsTexture::Texture()
       
   246     {
       
   247     FUNC_LOG;
       
   248     return iTexture;
       
   249     }
       
   250     
       
   251 // ----------------------------------------------------------------------------
       
   252 // CFsTexture::ConstructL
       
   253 // 2nd phase contructor
       
   254 // (may leave)
       
   255 // Status : Draft
       
   256 // ----------------------------------------------------------------------------
       
   257 //
       
   258 void CFsTexture::ConstructL( )
       
   259     {
       
   260     FUNC_LOG;
       
   261     return;
       
   262     }
       
   263     
       
   264 // ----------------------------------------------------------------------------
       
   265 // CFsTexture::UnloadL
       
   266 // Unload texture, or cancel unload
       
   267 // (may leave)
       
   268 // Status : Draft
       
   269 // ----------------------------------------------------------------------------
       
   270 //
       
   271 void CFsTexture::UnloadL( const TBool& aCancel )
       
   272     {
       
   273     FUNC_LOG;
       
   274     if ( aCancel )
       
   275         {
       
   276         if ( iUnloadTimer )
       
   277             {
       
   278             StopTimer();
       
   279             } // iUnloadTimer
       
   280         }
       
   281     else // aCancel
       
   282         {
       
   283         // Get current default
       
   284         TTimeIntervalMicroSeconds32 timeOut;
       
   285         iObserver.DefaultTimeOut( timeOut );
       
   286     
       
   287         if ( timeOut == TTimeIntervalMicroSeconds32( 0 ) )
       
   288             {
       
   289             TimerExpiredL();
       
   290             } // timeOut
       
   291         else if ( !iUnloadTimer )
       
   292             {
       
   293 	        iUnloadTimer = CPeriodic::NewL( CActive::EPriorityStandard );
       
   294 
       
   295             // Start timer
       
   296             iUnloadTimer->Start( timeOut, 
       
   297                                  timeOut,
       
   298                                  TCallBack( TimerCallbackL, 
       
   299                                             this
       
   300                                           )
       
   301                                );        
       
   302             }
       
   303         else
       
   304             {
       
   305             // Left for Lint
       
   306             }
       
   307         } // !aCancel
       
   308     
       
   309     return;
       
   310     }    
       
   311 
       
   312 // ----------------------------------------------------------------------------
       
   313 // CFsTexture::Provider
       
   314 // Return bitmap provider
       
   315 // Status : Draft
       
   316 // ----------------------------------------------------------------------------
       
   317 //
       
   318 CFsBitmapProvider* CFsTexture::Provider()
       
   319     {
       
   320     FUNC_LOG;
       
   321     return iProvider;
       
   322     }
       
   323 
       
   324 // ----------------------------------------------------------------------------
       
   325 // CFsTexture::Id
       
   326 // Return provider Id
       
   327 // Status : Draft
       
   328 // ----------------------------------------------------------------------------
       
   329 //
       
   330 TInt CFsTexture::Id() const
       
   331     {
       
   332     FUNC_LOG;
       
   333     return iId;
       
   334     } 
       
   335 
       
   336 // ========================= OTHER EXPORTED FUNCTIONS =========================
       
   337 
       
   338 // End of file
       
   339