exampleapps/alfexstickers/inc/AlfExStickersControl.h
changeset 0 15bf7259bb7c
equal deleted inserted replaced
-1:000000000000 0:15bf7259bb7c
       
     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: 
       
    15 *
       
    16 */
       
    17 
       
    18 
       
    19 
       
    20 #ifndef C_ALFEXSTICKERSCONTROL_H
       
    21 #define C_ALFEXSTICKERSCONTROL_H
       
    22 
       
    23 
       
    24 /* Includes */
       
    25 
       
    26 #include <alf/alfcontrol.h>
       
    27 
       
    28 //TEMP
       
    29 #include <alf/alfdecklayout.h>
       
    30 
       
    31 
       
    32 /* Forward declarations. */
       
    33 
       
    34 class CAlfViewportLayout;
       
    35 class CAlfExStickerLayout;
       
    36 class CAlfImageLoaderUtil;
       
    37 
       
    38 
       
    39 /* Constants */
       
    40 
       
    41 //Number of example stickers
       
    42 const TInt KStickerCount = 2;
       
    43 
       
    44 /** 
       
    45  * @class CAlfExStickersControl
       
    46  * @discussion Control class for the AlfExSticker application. Handles creation of application elements
       
    47  * like viewport and sticker text visuals. Also handles user interaction with application elements.
       
    48  */
       
    49 class CAlfExStickersControl : public CAlfControl
       
    50     {
       
    51 public:
       
    52 
       
    53 	/* Constructors and destructor. */
       
    54 	
       
    55 	/**
       
    56 	 * @function NewL
       
    57 	 * @discussion Constructs a new CAlfExStickersControl class instance. A static factory method.
       
    58 	 * @param aEnv	UI Accelerator Toolkit environment object.
       
    59 	 * @param aFs	A handle to a file server session.
       
    60 	 * @result Control for the AlfExStickers application
       
    61 	 */
       
    62 	static CAlfExStickersControl* NewL(CAlfEnv& aEnv, RFs* aFs);
       
    63 	
       
    64 	/**
       
    65 	 * @function NewLC
       
    66 	 * @discussion Constructs a new CAlfExStickersControl class instance. A static factory method.
       
    67 	 * @param aEnv	UI Accelerator Toolkit environment object.
       
    68 	 * @param aFs	A handle to a file server session.
       
    69 	 * @result Control for the AlfExStickers application
       
    70 	 */
       
    71     static CAlfExStickersControl* NewLC(CAlfEnv& aEnv, RFs* aFs);
       
    72     
       
    73     /**
       
    74      * @function ~CAlfExStickersControl
       
    75      * @discussion 	Destructor
       
    76      */
       
    77     virtual ~CAlfExStickersControl();
       
    78     
       
    79 
       
    80     /* Methods. */
       
    81     
       
    82     /**
       
    83      * @function OfferEventL
       
    84      * @discussion Handles events from the framework
       
    85      * @param aEvent Catched event
       
    86      * @result Success or failure
       
    87      */    
       
    88     virtual TBool OfferEventL(const TAlfEvent& aEvent);
       
    89     
       
    90     /**
       
    91      * @function GetControl
       
    92      * @discussion Provides Control to stickers
       
    93      * @result CAlfControl to child visuals
       
    94      */    
       
    95     CAlfControl* GetControl();
       
    96     
       
    97     //Control for the visuals
       
    98     CAlfControl* iControl;
       
    99     
       
   100     
       
   101 private:
       
   102 	
       
   103 	/* Constructors*/
       
   104 
       
   105 	/**
       
   106 	 * Constructs an instance of CAlfExStickersControl.
       
   107 	 * @note Protected because this constructor only needs to be called by 
       
   108 	 * derived classes. Use the provided static factory methods instead.
       
   109 	 * @see NewL()
       
   110 	 * @see NewLC()
       
   111 	 */
       
   112     CAlfExStickersControl();
       
   113     
       
   114     /**
       
   115      * @function ConstructL
       
   116      * @discussion Second phase constructor
       
   117 	 * @param aEnv	UI Accelerator Toolkit environment object.
       
   118 	 * @param aFs	A handle to a file server session.
       
   119      */
       
   120     void ConstructL(CAlfEnv& aEnv, RFs* aFs);
       
   121     
       
   122     
       
   123     /* Methods. */
       
   124     
       
   125     /**
       
   126      * @function CreateViewportL
       
   127      * @discussion Creates Viewport layout to the application to act as the root layout.
       
   128      * Also function is used to set the size for the viewport and to enable scrolling, ie.
       
   129      * dragging interaction with the background
       
   130      */
       
   131     void CreateViewportL();
       
   132     
       
   133     /**
       
   134      * @function SetTextureManagerL
       
   135      * @discussion The function is used to find out path to applications graphical
       
   136      * resources and giving the path to Texture Manager. 
       
   137      */
       
   138     void SetTextureManagerL();
       
   139     
       
   140     /**
       
   141      * @function LoadBackgroundImageL
       
   142      * @discussion Function uses Texture Manager to load board (application background)
       
   143      * texture from a png-file. Then creates new image visual to cover application background and
       
   144      * adds the loaded board texture in the visual.
       
   145      */
       
   146     void LoadBackgroundImageL();
       
   147     
       
   148     /**
       
   149      * @function CreateSVGTextureL
       
   150      * @discussion Function used to create SVG texture from SVG file
       
   151      * @param aFileName SVG file filename.
       
   152      * @param aSize Texture size
       
   153      * @param aImageLoaderUtil Image loader utility.
       
   154      * @result Reference to created texture. This texture is owned by texture manager.
       
   155      */
       
   156     CAlfTexture& CreateSVGTextureL(const TFileName& aFileName, TSize& aSize, CAlfImageLoaderUtil* aImageLoaderUtil);
       
   157     
       
   158     /**
       
   159      * @function CreateStickersL
       
   160      * @discussion Function used to create several stickers and applying the needed
       
   161      * changes into the visuals.
       
   162      * 
       
   163      * Easiest way to create text visual would be to use:
       
   164      * CAlfTextVisual* visual = CAlfTextVisual::AddNewL(*this, iPlainLayout);
       
   165      * We have however created new class for the text visual (alfexsticker).
       
   166      */
       
   167     void CreateStickersL();
       
   168 
       
   169     /**
       
   170      * @function LoadStickerImageL
       
   171      * @discussion Function used to load sticker background image from SVG file.
       
   172      * @param aIndex An index number of sticker where background is loaded.
       
   173      */
       
   174     void LoadStickerImageL(TInt aIndex);
       
   175     
       
   176     /* Member variables */
       
   177     
       
   178     //UI Accelerator Toolkit environment object
       
   179     CAlfEnv* iEnv;
       
   180     
       
   181     //Handle to file server session
       
   182     RFs* iFs;
       
   183 
       
   184     //Texture path
       
   185     TFileName iPrivateFolderPath;
       
   186     
       
   187     //Layouts && Co
       
   188     CAlfViewportLayout* iViewPort;
       
   189     CAlfLayout* iPlainLayout;
       
   190     
       
   191     //Application view and viewport sizes
       
   192     TSize iVirtualSize;
       
   193     TSize iLayoutsize;
       
   194     
       
   195     //Sticker array
       
   196     CAlfExStickerLayout* iStickerArray[KStickerCount];
       
   197     
       
   198     //Default timed values
       
   199     TAlfTimedValue x;
       
   200     TAlfTimedValue y;
       
   201     
       
   202     //Member data needed to handle interaction, like drag and drop
       
   203     CAlfVisual* iOnVisual;
       
   204     CAlfExStickerLayout* iSelectedDeck;
       
   205     TBool iDraggingVisual;
       
   206     TPoint iStartVisualPos;    // Original position of dragged visual.
       
   207     TPoint iStartDisplayPoint; // Point of display for Pointer Down.
       
   208     TAlfRealPoint iDraggedPosition;
       
   209     TAlfRealPoint iViewPos;
       
   210     TBool iHasBeenDragged;
       
   211     
       
   212     //Image loader array.
       
   213     RArray<CAlfImageLoaderUtil*> iImageLoaderUtilArray;
       
   214     };
       
   215 
       
   216 #endif // C_ALFEXSTICKERSCONTROL_H