scrsaver/scrsaverplugins/BmpAnimScrPlugin/inc/CBmpAnimScrPlugin.h
branchRCL_3
changeset 26 e8d784ac1a4b
parent 0 040fcad49f44
equal deleted inserted replaced
25:aaeeca1f15af 26:e8d784ac1a4b
       
     1 /*
       
     2 * Copyright (c) 2003 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:   Main include file for plugin
       
    15 *
       
    16 */
       
    17 
       
    18 
       
    19 
       
    20 #ifndef C_CBMPANIMSCRPLUGIN_H
       
    21 #define C_CBMPANIMSCRPLUGIN_H
       
    22 
       
    23 #include <e32base.h>
       
    24 #include <fbs.h>
       
    25 #include <eikenv.h>
       
    26 #include <coecntrl.h>
       
    27 #include <coeccntx.h>
       
    28 
       
    29 #include <ScreensaverpluginIntDef.h>
       
    30 
       
    31 #include "CBmpAnimModel.h"
       
    32 #include "CBmpAnimItem.h"
       
    33 #include "CBmpAnimSettings.h"
       
    34 
       
    35 // The screensaver plugin implementation must inherit from 
       
    36 // CScreensaverPluginInterfaceDefinition
       
    37 class CBmpAnimScrPlugin : public CScreensaverPluginInterfaceDefinition
       
    38     {
       
    39     enum TPluginState   
       
    40         {
       
    41         EPluginStateLoading = 0,
       
    42         EPluginStateInitializing,
       
    43         EPluginStateAnimation,
       
    44         EPluginStateStoppingAnimation,
       
    45         };
       
    46 
       
    47     enum TLoadedAnimation
       
    48         {
       
    49         ENone,
       
    50         EPortrait,
       
    51         ELandscape,
       
    52         EPortraitRotated
       
    53         };
       
    54     
       
    55 public:
       
    56     // Class instance creation
       
    57     static CBmpAnimScrPlugin* NewL();
       
    58 
       
    59 private:
       
    60     // Construction
       
    61     CBmpAnimScrPlugin();
       
    62     
       
    63 public:
       
    64     // Destruction
       
    65     ~CBmpAnimScrPlugin();
       
    66 
       
    67 public: // from MScreensaverPlugin
       
    68     TInt InitializeL(MScreensaverPluginHost *aHost);
       
    69     TInt Draw(CWindowGc& aGc);
       
    70     const TDesC16& Name() const;
       
    71     TInt HandleScreensaverEventL(TScreensaverEvent aEvent, TAny* aData);
       
    72     TInt Capabilities();
       
    73     TInt PluginFunction(TScPluginCaps aFunction, TAny* aParam);
       
    74 
       
    75 private:
       
    76     // Draws centered items
       
    77     void DrawCentered(CWindowGc& aGc, CBmpAnimItem* aItem);
       
    78 
       
    79     // Loads the animation into the model
       
    80     void LoadAnimationL(TBool aLandscape = EFalse, TBool aRotate = EFalse);
       
    81 
       
    82     // Re-loads the animation when display changes, if needed
       
    83     void ReloadAnimationL();
       
    84 
       
    85     // Starts the display timer
       
    86     void StartDisplayTimer();
       
    87 
       
    88     // Stops the display timer
       
    89     void StopDisplayTimer();
       
    90 
       
    91     // Display timer callback
       
    92     static TInt DisplayTimerCallback(TAny* aPtr);
       
    93 
       
    94     // Starts the lights timer
       
    95     void StartLightsTimer();
       
    96 
       
    97     // Stops the lights
       
    98     void StopLightsTimer();
       
    99 
       
   100     // Lights timer callback
       
   101     static TInt LightsTimerCallback(TAny* aPtr);
       
   102     
       
   103     // Advances the plugin state
       
   104     void HandlePluginState();
       
   105 
       
   106     // Requests a suitable display mode from host
       
   107     void SetDisplayMode();
       
   108 
       
   109     void Lights(TInt aSecs);
       
   110 
       
   111     // Configures the plugin
       
   112     TInt ConfigureL(TAny* aParam);
       
   113 
       
   114     // Sets sizes of bitmaps
       
   115     TInt ScaleBitmap(CFbsBitmap* aBmp, TBool aRotate = EFalse);
       
   116 
       
   117     // Returns ETrue if reload of the animation is needed
       
   118     TBool ReloadNeeded();
       
   119 
       
   120     // Returns ETrue if display is landscape
       
   121     TBool DisplayIsLandscape();
       
   122     
       
   123     // Returns ETrue if graphics should be rotated
       
   124     TBool RotateNeeded();
       
   125     
       
   126     // Returns ETrue if landscape graphics should be loaded
       
   127     TBool LoadLandscape();
       
   128     
       
   129     // Updates the saved display information
       
   130     void UpdateDisplayInfo();
       
   131 
       
   132     // Sets bitmap size and rotation (used instead of AknIconUtils function)
       
   133     // Actually an "Easy Leaving :)" wrapper around the L-version
       
   134     TInt SetSizeAndRotation(CFbsBitmap* aBmp, TSize aSize, TInt aAngle);
       
   135     
       
   136     // Sets bitmap size and rotation (used instead of AknIconUtils function)
       
   137     void SetSizeAndRotationL(CFbsBitmap* aBmp, TSize aSize, TInt aAngle);
       
   138 
       
   139     // Rotates and scales a source bitmap into target bitmap
       
   140     void RotateAndScaleBitmapL(
       
   141         const TRect& aTrgRect,
       
   142         CFbsBitmap* aTrgBitmap, 
       
   143         CFbsBitmap* aSrcBitmap,
       
   144         TInt aAngle);
       
   145     
       
   146 private:
       
   147     // Plugin host interface
       
   148     MScreensaverPluginHost* iHost;
       
   149     
       
   150     // Plugin state
       
   151     TInt iState;
       
   152 
       
   153     // Needed to retrieve bitmaps from files
       
   154     CEikonEnv* iEikEnv;
       
   155 
       
   156     // Animator model, stores and serves animation items
       
   157     CBmpAnimModel* iModel;
       
   158 
       
   159     // Animator settings. Created and deleted here, but used and managed by
       
   160     // the model. Creating here enables retrieving the plugin name
       
   161     // in non-plugin-host applications (such as Themes)
       
   162     CBmpAnimSettings* iSettings;
       
   163     
       
   164     // Timer to control how long the animation is displayed
       
   165     CPeriodic* iDisplayTimer;
       
   166     
       
   167     // Flag to control animation stop. Changed from display timer callback
       
   168     TInt iStopDisplaying;
       
   169 
       
   170     TScreensaverDisplayInfo iDi;
       
   171 
       
   172     TLoadedAnimation iLoadedAnimation;
       
   173     };
       
   174 
       
   175 
       
   176 #endif   // C_CBMPANIMSCRPLUGIN_H
       
   177 
       
   178 // End of file