mobilemessaging/postcard/postcardinc/PostcardController.h
changeset 0 72b543305e3a
equal deleted inserted replaced
-1:000000000000 0:72b543305e3a
       
     1 /*
       
     2 * Copyright (c) 2005 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: PostcardController  declaration
       
    15 *
       
    16 */
       
    17 
       
    18 
       
    19 #ifndef POSTCARDCONTROLLER
       
    20 #define POSTCARDCONTROLLER
       
    21 
       
    22 #include <e32base.h>
       
    23 #include <coecntrl.h>
       
    24 #include <AknsItemID.h>
       
    25 #include "PostcardDocument.h"
       
    26 #ifdef RD_SCALABLE_UI_V2
       
    27 #include "PostcardPointerObserver.h"
       
    28 #endif
       
    29 
       
    30 // FOWARD DECLARTIONS
       
    31 class CGulIcon;
       
    32 class CAknsBasicBackgroundControlContext;
       
    33 
       
    34 // CLASS DECLARATION
       
    35 /**
       
    36 *  Container control class.
       
    37 *  
       
    38 */
       
    39 class CPostcardController : public CCoeControl
       
    40     {
       
    41     public: // Constructors and destructor
       
    42         /**
       
    43         * Constructor.
       
    44         * @return pointer to the object
       
    45         */
       
    46         static CPostcardController* NewL( CPostcardDocument& aDocument
       
    47 #ifdef RD_SCALABLE_UI_V2
       
    48             , MPocaPointerEventObserver& aObserver
       
    49 #endif
       
    50         );
       
    51 
       
    52         /**
       
    53         * Destructor.
       
    54         */
       
    55         ~CPostcardController();
       
    56 
       
    57     public: // New functions
       
    58 
       
    59         /**
       
    60         * Returns ETrue if front page is focused.
       
    61         */
       
    62         TBool Frontpage( );
       
    63 
       
    64         /**
       
    65         * Returns ETrue if aPart is focused
       
    66         */
       
    67         TBool IsFocused( TPostcardPart& aPart );
       
    68 
       
    69         /**
       
    70         * Returns the focused part
       
    71         */
       
    72         TPostcardPart Focused( );
       
    73 
       
    74         /**
       
    75         * Sets aPart as focused item
       
    76         */
       
    77         void SetFocused( TPostcardPart aPart );
       
    78 
       
    79         /**
       
    80         * Sets the bitmap of part aPart. Takes the ownership.
       
    81         * Deletes the previous one.
       
    82         */
       
    83         void SetBitmap( TPostcardPart aPart, CGulIcon* aIcon );
       
    84 
       
    85         /**
       
    86         * Removes and deletes bitmap aPart
       
    87         */
       
    88         void RemoveBitmap( TPostcardPart aPart );
       
    89 
       
    90         /**
       
    91          * Reloads icons. Called from AppUi, if skin has changed.
       
    92         */ 
       
    93         void ReLoadIconsL();
       
    94         
       
    95 		/**
       
    96 		* Rereads the coordinates of bitmaps from LAF
       
    97 		*/
       
    98 		void RefreshCoordinates( );
       
    99 
       
   100         /**
       
   101         * Calls MoveHorizontally or MoveVertically according to aKeyEvent
       
   102         */
       
   103         void Move( TInt aScanCode );
       
   104 
       
   105         /**
       
   106         * Changes the focus in the back side if possible
       
   107         */
       
   108         void MoveHorizontally( TBool aRight );
       
   109 
       
   110         /**
       
   111         * Changes the focus from back to front or vice versa if possible
       
   112         */
       
   113         void MoveVertically( TBool aUp );
       
   114 
       
   115         /**
       
   116         * Makes itself focused, visible and active.
       
   117         */
       
   118         void ActivateL( );
       
   119 
       
   120         /**
       
   121         * Gets an array of TRects and sets them as greeting field lines
       
   122         */
       
   123         void SetGreetingLines( CArrayPtrFlat<TRect>& aGreetingLines );
       
   124         
       
   125         /**
       
   126         * Gets an array of TRects and sets them as recipient field lines
       
   127         */
       
   128         void SetRecipientLines( CArrayPtrFlat<TRect>& aRecipientLines );
       
   129 
       
   130     private: // New functions
       
   131 
       
   132         /**
       
   133         * Default C++ constructor.
       
   134         */
       
   135         CPostcardController( CPostcardDocument& aDocument
       
   136 #ifdef RD_SCALABLE_UI_V2
       
   137             , MPocaPointerEventObserver& aObserver
       
   138 #endif
       
   139         );
       
   140 
       
   141         /**
       
   142         * 2nd phase Constructor.
       
   143         */
       
   144         void ConstructL( );
       
   145 
       
   146     private: // Functions from base classes
       
   147 
       
   148         /**
       
   149         * From CoeControl,CountComponentControls. Returns always 0.
       
   150         */
       
   151         TInt CountComponentControls( ) const;
       
   152 
       
   153         /**
       
   154         * From CCoeControl,ComponentControl. Returns always NULL.
       
   155         */
       
   156         CCoeControl* ComponentControl( TInt aIndex ) const;
       
   157 
       
   158         /**
       
   159         * Calls DrawBackground.
       
   160         * Also calls DrawIcons for the objects we have on top of the background
       
   161         */
       
   162         void Draw( const TRect& aRect ) const;
       
   163         
       
   164         /**
       
   165         * Draws possible skin background.
       
   166         * Draws the background icons.
       
   167         */
       
   168         void DrawBackground( ) const;
       
   169         
       
   170         /**
       
   171         * Draws the image side.
       
   172         */
       
   173         void DrawImageSide( ) const;
       
   174 
       
   175         /**
       
   176         * Draws the text side.
       
   177         */
       
   178         void DrawTextSide( ) const;
       
   179         
       
   180         /**
       
   181         * Draws icon aIcon in rect aRect. Called by DrawImageSide or DrawTextSide.
       
   182         */
       
   183         void DrawIcon( const CGulIcon& aIcon, const TRect& aRect ) const;
       
   184 
       
   185         /**
       
   186         * Draws arrow down or up icon based on the side and whether in editor or
       
   187         * in viewer mode.
       
   188         */
       
   189         void DrawScrollArrows() const;
       
   190 
       
   191         /**
       
   192         * Draws focus lines. Called by DrawTextSide.
       
   193         */
       
   194         void DrawFocus( ) const;
       
   195 
       
   196     protected: // From CCoeControl
       
   197 
       
   198         /**
       
   199         * Returns the Mop supply object for skin drawing
       
   200         */
       
   201 	    TTypeUid::Ptr MopSupplyObject(TTypeUid aId);
       
   202 
       
   203 #ifdef RD_SCALABLE_UI_V2
       
   204         /**
       
   205         * Handle pointer event
       
   206         */
       
   207         void HandlePointerEventL(const TPointerEvent& aPointerEvent);
       
   208 #endif
       
   209 
       
   210     private:
       
   211 
       
   212         /**
       
   213         *   LoadIconsL
       
   214         *   Calls DoLoadIconL to load icons needed by controller
       
   215         */
       
   216         void LoadIconsL();
       
   217 
       
   218         /**
       
   219         *   DoLoadIconL
       
   220         *   Calls AknsUtils::CreateIconL to load icons defined by parameters.
       
   221         *   Param IN aId - the id of the icon in AknsConstants.h
       
   222         *            aFileName - the name of the file where icons are loaded
       
   223         *            aFileBitmapId - the id of the bitmap file
       
   224         *   Returns - icon created by the function
       
   225         */
       
   226         CGulIcon* DoLoadIconL(  const TAknsItemID& aId,
       
   227                                 const TDesC& aFileName,
       
   228                                 const TInt aFileBitmapId,
       
   229                                 const TInt aFileMaskId = -1 );
       
   230                                
       
   231     private: //Data
       
   232 
       
   233         // Reference to AppUi
       
   234         CPostcardDocument& iDocument;
       
   235 
       
   236 		// Related to frontside
       
   237         CGulIcon* iFrontBg;
       
   238         CGulIcon* iImage; 
       
   239         CGulIcon* iInsertImage;
       
   240         CGulIcon* iInsertImageBg;
       
   241 
       
   242 		// Related to backside
       
   243         CGulIcon* iBgBg;
       
   244         CGulIcon* iStamp;
       
   245         CGulIcon* iEmptyGreetingFocused;
       
   246         CGulIcon* iEmptyGreeting;
       
   247         CGulIcon* iGreeting;
       
   248         CGulIcon* iEmptyAddressFocused;
       
   249         CGulIcon* iEmptyAddress;
       
   250         CGulIcon* iAddress;
       
   251 
       
   252         // Focus lines are here
       
   253         CArrayPtrFlat<TRect>*   iGreetingLines;
       
   254         CArrayPtrFlat<TRect>*   iRecipientLines;
       
   255 
       
   256 		// Related to arrows
       
   257         CGulIcon* iUpperArrow;
       
   258         CGulIcon* iLowerArrow;
       
   259 
       
   260 		// Related to frontside
       
   261         TRect iFrontBgC;
       
   262         TRect iImageC;
       
   263         TRect iInsertImageC;
       
   264         TRect iInsertImageBgC;
       
   265 
       
   266 		// Related to backside
       
   267         TRect iBgBgC;
       
   268         TRect iStampC;
       
   269         TRect iGreetingC;
       
   270         TRect iAddressC;
       
   271 
       
   272 		// Related to arrows
       
   273         TRect iUpperArrowC;
       
   274         TRect iLowerArrowC;
       
   275 
       
   276         TPostcardPart iFocusedItem;
       
   277 
       
   278     	CAknsBasicBackgroundControlContext* iBgContext; // Skin background control context
       
   279 
       
   280 #ifdef RD_SCALABLE_UI_V2
       
   281         TBool iPenEnabled;
       
   282         MPocaPointerEventObserver& iEventObserver;
       
   283 #endif
       
   284     };
       
   285 
       
   286 #endif // POSTCARDCONTROLLER_H
       
   287 
       
   288 // End of File