camerauis/cameraapp/generic/inc/CamPreCaptureViewBase.h
branchRCL_3
changeset 24 bac7acad7cb3
equal deleted inserted replaced
23:61bc0f252b2b 24:bac7acad7cb3
       
     1 /*
       
     2 * Copyright (c) 2007-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:  Base class for pre-capture views*
       
    15 */
       
    16 
       
    17 
       
    18 #ifndef CAMPRECAPTUREVIEWBASE_H
       
    19 #define CAMPRECAPTUREVIEWBASE_H
       
    20 
       
    21 #include <akntoolbarobserver.h>
       
    22 #include <akntouchgesturefw.h>
       
    23 #include <akntouchgesturefwobserver.h>
       
    24 #include <akntouchgesturefwevents.h>
       
    25 
       
    26 #include "CamCaptureSetupViewBase.h"
       
    27 
       
    28 #include "CamControllerObservers.h"
       
    29 #include "CamAppController.h"
       
    30 
       
    31 // FORWARD DECLARATION
       
    32 class CCamCaptureSetupMenu;
       
    33 class CCamStandbyContainer;
       
    34 class MAknsSkinInstance; 
       
    35 class TAknsItemID;
       
    36 class CAknButton;
       
    37 
       
    38 
       
    39 using namespace AknTouchGestureFw;
       
    40 // CLASS DECLARATION
       
    41 
       
    42 /**
       
    43 * Base class for precapture views
       
    44 *
       
    45 *  @since 2.8
       
    46 */
       
    47 class CCamPreCaptureViewBase : 	public CCamCaptureSetupViewBase,
       
    48 								public MCamControllerObserver,
       
    49 								public MAknToolbarObserver,
       
    50 								public MAknTouchGestureFwObserver
       
    51     {
       
    52     public:  // Constructors and destructor
       
    53         
       
    54         /**
       
    55         * Destructor.
       
    56         * @since 2.8
       
    57         */
       
    58         virtual ~CCamPreCaptureViewBase();
       
    59 
       
    60     public: // Functions from base classes
       
    61 
       
    62         /**
       
    63         * From CAknView Handle commands
       
    64         * @since 2.8
       
    65         * @param aCommand command to be handled
       
    66         */
       
    67         void HandleCommandL( TInt aCommand );
       
    68 
       
    69         /**
       
    70         * From CAknView Handles the foreground/background event
       
    71         * @since 2.8
       
    72         * @param aForeground ETrue if this view is on foreground, else EFalse.
       
    73         */
       
    74         void HandleForegroundEventL( TBool aForeground );
       
    75 
       
    76         /**
       
    77         * From MCamControllerObserver
       
    78         * @since 2.8
       
    79         * @param aEvent The enumerated code for the event received
       
    80         * @param aError The error code associated with the event
       
    81         */
       
    82         void HandleControllerEventL( TCamControllerEvent aEvent,
       
    83                                             TInt aError );
       
    84         
       
    85         /**
       
    86         * From CAknView.
       
    87         * @since 2.8
       
    88         * @param aPreViewId the ID for previous view we are switching from
       
    89         * @param aCustomMessageId the Uid for message passed to this view
       
    90         * @param aCustomMessage descriptor containing data content for view specific message
       
    91         */
       
    92         void DoActivateL( const TVwsViewId& aPreViewId, TUid aCustomMessageId,
       
    93                                                     const TDesC8& aCustomMessage );
       
    94         /**
       
    95         * From CAknView.
       
    96         * @since 2.8
       
    97         */
       
    98         void DoDeactivate();
       
    99 
       
   100         /**
       
   101         * From CCamViewBase
       
   102         * Handle change of focus to another application
       
   103         * This only handles another application coming to the foreground when
       
   104         * the camera application is already in the background behind an eikon
       
   105         * server window
       
   106         * @since 2.8
       
   107         */
       
   108         void HandleFocusLossL();
       
   109 
       
   110         /**
       
   111         * From CCamCaptureSetupViewBase
       
   112         * Revert to normal mode
       
   113         * @since 2.8
       
   114         */
       
   115         virtual void ExitAllModesL();
       
   116 
       
   117         /**
       
   118          * Gesture events are subscribed once the containers are constructed by 
       
   119          * derived class. 
       
   120          */
       
   121         void CreateContainerL();
       
   122 
       
   123         /**
       
   124          * Gesture event notifications are received in this function. 
       
   125          */
       
   126         void HandleTouchGestureL( MAknTouchGestureFwEvent& aEvent );        
       
   127 
       
   128     public: // New functions
       
   129 
       
   130        /**
       
   131         * From CCamCaptureSetupViewBase
       
   132         * Return the active setting mode
       
   133         * @since 2.8
       
   134         * @return the active setting mode
       
   135         */
       
   136         TCamSettingMode ActiveSettingMode();
       
   137 
       
   138         /**
       
   139          * AppUi calls this to notify views of focusgained and focuslost
       
   140          * events.
       
   141          */
       
   142         void HandleAppEvent( const TCamAppEvent& aEvent );        
       
   143         
       
   144         /**
       
   145          * Sets a flag to true to indicate that access point dialog is shown and
       
   146          * viewfinder needs to be restarted.
       
   147          */        
       
   148         void SetLocationTrailConnecting();
       
   149         
       
   150         /**
       
   151          * AppUi calls this to indicate if postcapture view will be visible
       
   152          * in near future.
       
   153          */        
       
   154         void SetPostCaptureViewAsumption( TBool aAssumePostCaptureView );
       
   155         
       
   156         /**
       
   157         * Try to start the capture with MSK command. 
       
   158         * @since 9.1
       
   159         * @return ETrue if started.
       
   160         */
       
   161         virtual TBool StartMskCaptureL() = 0;
       
   162         
       
   163         
       
   164         /**
       
   165         * Getter for iCaptureSetupModeActive
       
   166         * @since 9.2
       
   167         * @return iCaptureSetupModeActive
       
   168         */
       
   169         TBool IsSetupModeActive();
       
   170 
       
   171     protected:    // Functions from base classes
       
   172 
       
   173         /**
       
   174         * From CCamPreCaptureViewBase 
       
   175         * Set the menu bar resource.
       
   176         */
       
   177         virtual void SetMenuBar() = 0;
       
   178 
       
   179         /**
       
   180         * From CCamCaptureSetupViewBase
       
   181         * Switches the current mode to capture setup and activates a 
       
   182         * specific control.
       
   183         * @since 2.8
       
   184         * @param aSetupCommand that specifies which setup control type to activate.
       
   185         */
       
   186         void SwitchToCaptureSetupModeL( TInt aSetupCommand );
       
   187 
       
   188         /**
       
   189         * From CCamCaptureSetupViewBase
       
   190         * Switches the current mode to scene setting and activates a 
       
   191         * specific control.
       
   192         * @since 2.8
       
   193         */
       
   194         void SwitchToSceneSettingModeL();
       
   195 
       
   196         /**
       
   197         * From CCamCaptureSetupViewBase
       
   198         * Exits capture setup mode and activates the capture setup menu control.
       
   199         * @since 2.8
       
   200         */
       
   201         void ExitCaptureSetupModeL();
       
   202 
       
   203         /**
       
   204         * From CCamCaptureSetupViewBase
       
   205         * Exits scene setting mode and activates the capture setup menu control.
       
   206         * @since 2.8
       
   207         */
       
   208         void ExitSceneSettingModeL();
       
   209         
       
   210         /**
       
   211         * From CCamCaptureSetupViewBase
       
   212         * Exits scene setting mode and activates the capture setup menu control.
       
   213         * @since 2.8
       
   214         */
       
   215         void ExitInfoListBoxL();
       
   216         
       
   217         /**
       
   218         * Returns whether the view is a precapture view or not
       
   219         * @since 3.0
       
   220         * @returns ETrue
       
   221         */
       
   222         virtual TBool IsPreCapture();
       
   223         
       
   224         /**
       
   225         * Update fixed toolbar icons according to current settings
       
   226         * @since S60 5.0
       
   227         */
       
   228         virtual void UpdateToolbarIconsL() = 0;
       
   229 		/**
       
   230         * Redraws the toolbar and toolbarextension if visible
       
   231         * @since S60 5.1
       
   232         */
       
   233 		virtual void RedrawToolBar();
       
   234         
       
   235         /**
       
   236         * Returns the toolbar button by id from either the toolbar or toolbar extension
       
   237         * @param aCommandId CommandId correpsonding to the button 
       
   238         * @returns the button or NULL
       
   239         * @since S60 5.1
       
   240         */
       
   241         CAknButton* ToolbarButtonById(const TCamCmd aCommandId) const;
       
   242         
       
   243 public:
       
   244     
       
   245         /**
       
   246         * Hides a toolbar/extension icon
       
   247         * @param aCommandId CommandId correpsonding to the button
       
   248         * @returns void
       
   249         * @since S60 5.1
       
   250         */
       
   251         virtual void HideButton(const TCamCmd aCommandId);
       
   252 
       
   253     protected:  // New functions
       
   254 
       
   255         /**
       
   256         * C++ default constructor.
       
   257         * @param aController Reference to either the application controller 
       
   258         * base class or test base class
       
   259         * @since 2.8
       
   260         */
       
   261         CCamPreCaptureViewBase( CCamAppController& aController );
       
   262 
       
   263         /**
       
   264         * Symbian 2nd phase constructor.
       
   265         * @since 2.8
       
   266         */
       
   267         void ConstructL();
       
   268 
       
   269         /**
       
   270         * Enter Viewfinder mode
       
   271         * @since 2.8
       
   272         */
       
   273         virtual void StartViewFinder() = 0;
       
   274 
       
   275         /**
       
   276         * Exit Viewfinder mode
       
   277         * @since 2.8
       
   278         */
       
   279         virtual void StopViewFinder() = 0;
       
   280 
       
   281         /**
       
   282         * Switch from current mode to standby mode
       
   283         * @since 2.8
       
   284         * @param aViewId the current view id
       
   285         * @param aError associated error code
       
   286         */
       
   287         void SwitchToStandbyModeL( TCamAppViewIds aViewId, TInt aError );
       
   288 
       
   289         /**
       
   290         * Exit standby mode and return to previous capture mode
       
   291         * @since 2.8
       
   292         */
       
   293         void ExitStandbyModeL();
       
   294 
       
   295 #if 0
       
   296         /**
       
   297         * Check whether the ok options menu can be displayed
       
   298         * @since 2.8
       
   299         * @return ETrue if the menu can be displayed, else EFalse
       
   300         */
       
   301         TBool IsOkOptionsMenuAllowed();
       
   302 #endif // 0
       
   303 
       
   304         /**
       
   305         * Stop the viewfinder and inform the controller that the engine is
       
   306         * no longer required by this view
       
   307         * @since 2.8
       
   308         */
       
   309         void ReleaseResources();
       
   310         
       
   311         /**
       
   312         * Switches the current mode to capture setup menu and activates 
       
   313         * the capture setup menu control.
       
   314         * @since 2.8
       
   315         */
       
   316         void SwitchToCaptureSetupMenuModeL();
       
   317 
       
   318         /**
       
   319         * Exits capture setup menu mode and activates the original precapture
       
   320         * view container that was active before entering this mode.
       
   321         * @since 2.8
       
   322         */
       
   323         void ExitCaptureSetupMenuModeL();
       
   324 
       
   325         /**
       
   326         * Creates a capture setup menu. Derived classes should create
       
   327         * either a video or photo menu, depending on the class type.
       
   328         * @since 2.8
       
   329         */
       
   330 		virtual void CreateCaptureSetupMenuL() = 0;
       
   331 
       
   332         /**
       
   333         * Removes the capture setup menu and original container from
       
   334         * the container stack.
       
   335         * @since 2.8
       
   336         */
       
   337         void RemoveCaptureSetupMenuContainers();		
       
   338 
       
   339         /**
       
   340         * Set the icon of a toolbar button
       
   341         * @since S60 5.0
       
   342         * @param aButton       The button whose icon is to be changed.
       
   343         * @param aIconFilename Full path to the MBM/MIF file
       
   344         * @param aIconId       Icon ID in MBM/MIF file
       
   345         * @param aMaskId       Mask ID in MBM/MIF file
       
   346         * @param aSkinInstance Current skin instance
       
   347         * @param aSkinItemId   Skin ID for the button graphic
       
   348         * 
       
   349         */
       
   350         void SetIconL(
       
   351             CAknButton* aButton,
       
   352             const TDesC& aIconFilename,
       
   353             TInt aIconId,
       
   354             TInt aMaskId,
       
   355             MAknsSkinInstance* aSkinInstance, 
       
   356             const TAknsItemID& aSkinItemId );
       
   357 
       
   358         /**
       
   359         * Initialise the switch camera menu item, used from
       
   360         * DynInitMenuPaneL()
       
   361         * @since 3.0
       
   362         * @param aMenuPane The menu pane to initialise
       
   363         */
       
   364         void DynInitSwitchCameraMenuItemL( CEikMenuPane* aMenuPane );
       
   365 
       
   366 // from base class MAknToolbarObserver
       
   367 
       
   368         void OfferToolbarEventL( TInt aCommand );
       
   369 
       
   370     private: // new functions
       
   371   
       
   372         /**
       
   373         * Cleans up the capture setup menu if a leave occurs
       
   374         * while switching to capture setup menu mode
       
   375         * @param aAny pointer to the object to cleanup
       
   376         * @since 2.8
       
   377         */
       
   378         static void CleanupCaptureSetupMenu( TAny* aAny );
       
   379         
       
   380         /**
       
   381         * Helper method to setup the Active Palette.
       
   382         * If needed, the AP is created.
       
   383         * For existing AP, the items are first cleared.
       
   384         * New items are set with resource from GetAPResourceId.
       
   385         */        
       
   386         void SetupActivePaletteL();
       
   387 
       
   388     protected: // data
       
   389         
       
   390         // An extra container that the view uses when in capture setup menu mode.
       
   391         CCamCaptureSetupMenu* iCaptureSetupMenuContainer;
       
   392         
       
   393         // Used to determine when the view is in capture setup mode       
       
   394         TBool iCaptureSetupMenuModeActive;
       
   395         
       
   396         // Used to determine which capture setup menu item to select
       
   397         // when a capture setup control is exited.
       
   398         TInt iCaptureSetupMenuLastItemIndex;
       
   399 
       
   400 
       
   401         // Indicates that the application has lost the foreground but has not
       
   402         // released the resources
       
   403         TBool iContinueInBackground;
       
   404 
       
   405         // Indicates if the view was told to initiate standby mode from
       
   406         // activation
       
   407         TBool iActivateToStandby;
       
   408         
       
   409         // Indicates if the view was told to exit to standby mode from
       
   410         // the current mode
       
   411         TBool iDeactivateToStandby;
       
   412         
       
   413         // Indicates if toolbar extension should be invisible when returning
       
   414         // precapture view
       
   415         TBool iToolbarExtensionInvisible;
       
   416         
       
   417         // Asumption that next view is postcaptureview. If true don't start
       
   418         // viewfinder if coming to foreground from background.
       
   419         TBool iAssumePostCaptureView;
       
   420         
       
   421         TBool iLocationTrailConnecting;
       
   422         
       
   423         //  Gesture related
       
   424         CAknTouchGestureFw *iGestureFw;
       
   425         TInt iLastMovement;
       
   426     };
       
   427 
       
   428 #endif      // CAMPRECAPTUREVIEWBASE_H 
       
   429             
       
   430 // End of File