camerauis/cameraapp/generic/inc/CamLocationIconController.h
branchRCL_3
changeset 24 bac7acad7cb3
parent 0 1ddebce53859
child 25 2c87b2808fd7
equal deleted inserted replaced
23:61bc0f252b2b 24:bac7acad7cb3
       
     1 /*
       
     2 * Copyright (c) 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:  Header file for CCamLocationIconController class.
       
    15 *
       
    16 *  Copyright © 2007 Nokia.  All rights reserved.
       
    17 *  This material, including documentation and any related computer
       
    18 *  programs, is protected by copyright controlled by Nokia.  All
       
    19 *  rights are reserved.  Copying, including reproducing, storing,
       
    20 *  adapting or translating, any or all of this material requires the
       
    21 *  prior written consent of Nokia.  This material also contains
       
    22 *  confidential information which may not be disclosed to others
       
    23 *  without the prior written consent of Nokia.
       
    24 
       
    25 *
       
    26 *
       
    27 */
       
    28 
       
    29 
       
    30 #ifndef CAMLocationIconCONTROLLER_H
       
    31 #define CAMLocationIconCONTROLLER_H
       
    32 
       
    33 // INCLUDES
       
    34 
       
    35 #include <e32base.h>
       
    36 #include "CamPropertyObserver.h" // MPropertyObserver
       
    37 #include "CamControllerObservers.h"
       
    38 
       
    39 // CONSTANTS
       
    40 
       
    41 const TInt KLocationSettingStateOff = 0;
       
    42 const TInt KLocationSettingStateOn = 1;
       
    43 
       
    44 // FORWARD DECLARATIONS
       
    45 
       
    46 class CCamAppController;
       
    47 class CCamIndicator;
       
    48 class CCamPropertyWatcher;
       
    49 class CWindowGc;
       
    50 class CBitmapContext;
       
    51 class CEikonEnv;
       
    52 
       
    53 // CLASS DECLARATION
       
    54 
       
    55 /**
       
    56 * Abstract API for location icon observer.
       
    57 * Derived classes, which have subscribed to CCamLocationIconController
       
    58 * receive notification when the location icon contents change
       
    59 */
       
    60 class MCamLocationIconObserver
       
    61     {
       
    62     public:    
       
    63         /**
       
    64         * The location icon contents have changed
       
    65         */
       
    66         virtual void LocationIconUpdated() = 0;
       
    67     };   
       
    68 
       
    69 /**
       
    70 * Watches changes in location state properties.
       
    71 * Notifies observer of changes in the location indocator.
       
    72 * Handles drawing requests by passing them to owned CCamLocationIconDrawer
       
    73 * object.
       
    74 */
       
    75 class CCamLocationIconController: public CBase, public MPropertyObserver, public MCamControllerObserver
       
    76     {
       
    77     
       
    78     public: // Construction and destruction
       
    79         /**
       
    80         * Descructor
       
    81         */
       
    82         ~CCamLocationIconController();
       
    83         /**
       
    84         * Two-phased constructor
       
    85         * @param aObserver location indicator observer
       
    86         * @param aCallbackActive Callback to the observer active
       
    87         * @return Pointer to the created 
       
    88         */
       
    89         static CCamLocationIconController* NewL( CCamAppController& aController, 
       
    90                                                  MCamLocationIconObserver& aObserver, 
       
    91                                                  TBool aCallbackActive, TRect& aRect );
       
    92     
       
    93     
       
    94     public: // From MPropertyObserver
       
    95         /**
       
    96         * The value of a watched property has changed
       
    97         * @param aCategory The category of the property
       
    98         * @param aKey the Identifier of the property
       
    99         */    
       
   100         void HandlePropertyChangedL( const TUid& aCategory, const TUint aKey );
       
   101         
       
   102                
       
   103     public: // New functions
       
   104         /**
       
   105         * Activate or deactivate callbacks to observer when there
       
   106         * are changes in the location indicator.
       
   107         * @param aActive Callback to observer active
       
   108         */          
       
   109         void SetCallbackActive( TBool aActive );
       
   110         
       
   111         /**
       
   112         * Set location state.
       
   113         * @param aState location state
       
   114         */
       
   115         void SetLocationState( TInt aState );
       
   116                 
       
   117         /**
       
   118         * location indicator's rectangle
       
   119         * @return rectangle
       
   120         */
       
   121         TRect Rect() const; 
       
   122         
       
   123         /**
       
   124         * Draw the location icon
       
   125         * @param aGc Graphics context
       
   126         */                 
       
   127         void Draw( CBitmapContext& aGc ) const;
       
   128         //void Draw( CWindowGc& aGc ) const;
       
   129         
       
   130         /**
       
   131         * From MCamControllerObserver
       
   132         * @since 2.8
       
   133         * @param aEvent The enumerated code for the event received
       
   134         * @param aError The error code associated with the event
       
   135         */
       
   136         void HandleControllerEventL( TCamControllerEvent aEvent,
       
   137                                             TInt aError );
       
   138 
       
   139     protected:
       
   140         /**
       
   141         * Second phase constructor
       
   142         */
       
   143         void ConstructL( TRect& aRect );
       
   144     
       
   145     private:
       
   146         /**
       
   147         * Constructor.
       
   148         * @param aObserver location indocator observer
       
   149         * @param aCallbackActive Callback to the observer active
       
   150         */
       
   151         CCamLocationIconController( CCamAppController& aController, 
       
   152                                     MCamLocationIconObserver& aObserver, 
       
   153                                     TBool aCallbackActive );
       
   154         
       
   155         void CreateLocationIndicatorL();
       
   156         void UpdateRect( TBool aSecondCameraEnabled );
       
   157         void UpdateRect();
       
   158         //TRect Rect() const;
       
   159         
       
   160         /**
       
   161         * Notifies observer of changes in the location indicator,
       
   162         * if iCallbackActive is set
       
   163         */
       
   164         void NotifyObserver();
       
   165         
       
   166         /**
       
   167         * Read current status of the properties. Set location state accordingly
       
   168         */
       
   169         void ReadCurrentState();
       
   170         
       
   171     private:
       
   172         CCamAppController&           iController; 
       
   173         // Array of pointer to the location indicators
       
   174         RPointerArray<CCamIndicator> iLocationIndicators;
       
   175         // The current location indicator
       
   176         TInt                         iLocationState;
       
   177         const CEikonEnv *            iEnv;
       
   178         // Observer of the location indicator changes
       
   179         MCamLocationIconObserver&    iObserver;
       
   180         TBool                        iCallbackActive;
       
   181         TRect                        iRect;
       
   182 
       
   183         // Property watchers for location state changes
       
   184         CCamPropertyWatcher*        iLocationStateWatcher;
       
   185     };
       
   186 
       
   187 #endif