camerauis/cameraapp/generic/inc/CamContainerBase.h
branchRCL_3
changeset 54 bac7acad7cb3
child 57 2c87b2808fd7
equal deleted inserted replaced
53:61bc0f252b2b 54: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 all camera application containers
       
    15 *
       
    16 *  Copyright © 2007-2008 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 
       
    31 #ifndef CAMCONTAINERBASE_H
       
    32 #define CAMCONTAINERBASE_H
       
    33 
       
    34 
       
    35 
       
    36 // INCLUDES
       
    37 #include <coecntrl.h>
       
    38 #include <AknUtils.h>
       
    39 #include "CamAppUiBase.h"             //  For TCamAppViewIds
       
    40 
       
    41 // FORWARD DECLARATIONS
       
    42 class CCamAppController;
       
    43 class CAknView;
       
    44 class MAknsControlContext;
       
    45 
       
    46 class CEnhancedSoftKeys;
       
    47 
       
    48 class CCamNaviCounterControl;
       
    49 class CCamNaviProgressBarControl;
       
    50 class MActivePalette2UI;
       
    51 class CCamBackupContainer;
       
    52 
       
    53 const TInt KCamPreCaptureWindowOrdinalPos = 100;
       
    54 const TInt KCamPostCaptureWindowOrdinalPos = 101;
       
    55 
       
    56 
       
    57 // CLASS DECLARATION
       
    58 
       
    59 /**
       
    60 * Container base class
       
    61 */
       
    62 class CCamContainerBase : public CCoeControl
       
    63   {
       
    64   // =======================================================
       
    65   // Typenames
       
    66   public:
       
    67 
       
    68     // Was defined in multiple child classes, now moved here.
       
    69     enum TVfState // ViewFinder states
       
    70       {
       
    71       EVfStateActive,
       
    72       EVfStateFrozenDimmed,
       
    73       EVfStateActiveMasked
       
    74       };    
       
    75     
       
    76     
       
    77     // Enumeration used to indicate the pane currently visible
       
    78     enum TCamActiveNaviPane
       
    79       {
       
    80       ECamPaneUndefined,
       
    81       ECamPaneCounter,
       
    82       ECamPaneProgress
       
    83       };
       
    84     
       
    85   // =======================================================
       
    86   // Methods
       
    87 
       
    88   // Constructors and destructor
       
    89   public: 
       
    90         
       
    91     /**
       
    92     * Destructor.
       
    93     * @since 2.8
       
    94     */
       
    95     virtual ~CCamContainerBase();
       
    96 
       
    97   // -------------------------------------------------------
       
    98   // From CCoeControl
       
    99   public: 
       
   100     
       
   101     /**
       
   102     * Return this controls window.
       
   103     * This is needed for direct viewfinding.
       
   104     * Protected in CCoeControl. (not virtual)
       
   105     */
       
   106     RWindow& Window() const;
       
   107 
       
   108     /**
       
   109     * Handle events sending app to foreground or background
       
   110     * @since 2.8
       
   111     * @param aForeground whether the event brings the app to fore or background
       
   112     */
       
   113     virtual void HandleForegroundEventL( TBool aForeground );
       
   114     
       
   115     /** 
       
   116     * Gets an object whose type is encapsulated by the specified TTypeUid object.
       
   117     * @since 2.8
       
   118     * @param aId Encapsulates the Uid that identifies the type of object required.
       
   119     * @return Encapsulates the pointer to the object provided. 
       
   120     */
       
   121     TTypeUid::Ptr MopSupplyObject( TTypeUid aId );
       
   122         
       
   123     /**
       
   124     * This method should change its client rect area and redraw properly.
       
   125     * @since 2.8
       
   126     * @param aType resource change
       
   127     */
       
   128     virtual void HandleResourceChange( TInt aType );
       
   129 
       
   130     /**
       
   131     * Handle application level event.
       
   132     * For example focus gained and lost are notified through this method.
       
   133     * Default implementation is empty, to be replaced in inherited classes.
       
   134     * @param aEvent Event type
       
   135     */
       
   136     virtual void HandleAppEvent( const TCamAppEvent& aEvent );
       
   137 
       
   138 
       
   139 
       
   140     /**
       
   141     * @since 2.8
       
   142     * @param aKeyEvent the key event
       
   143     * @param aType the type of the event
       
   144     * @return TKeyResponse key event was used by this control or not
       
   145     */
       
   146     TKeyResponse OfferKeyEventL( const TKeyEvent& aKeyEvent,
       
   147                                        TEventCode aType );  
       
   148 
       
   149   // -------------------------------------------------------
       
   150   // New functions
       
   151   public: 
       
   152     
       
   153     /**
       
   154     * Passes the value of the previous view to the container
       
   155     * @since 2.8
       
   156     * @param aId The ID of the previous view
       
   157     */
       
   158     void SetPreviousViewId( TCamAppViewIds aId );
       
   159 
       
   160     /**
       
   161     * Sets up a navipane for use by this container
       
   162     * @param aNaviPane specifies which navipane to set up.
       
   163     * @since 3.0
       
   164     */
       
   165     void SetupNaviPanesL( TCamActiveNaviPane aNaviPane );
       
   166     
       
   167     /**
       
   168     * Will show the zoom pane for a set time
       
   169     * Only implemented by pre capture containers
       
   170     * @since 2.8
       
   171     */
       
   172     virtual void ShowZoomPaneWithTimer();
       
   173          
       
   174     /**
       
   175     * Create the ActivePalette control
       
   176     * @since 3.0
       
   177     */
       
   178     void CreateActivePaletteL();
       
   179     
       
   180     /**
       
   181     * Destroys the ActivePalette control
       
   182     * @since 3.0
       
   183     */
       
   184      static void DestroyActivePalette();      
       
   185 
       
   186     /**
       
   187     * Requests that the camera application redraws the supplied area
       
   188     * @since 3.0
       
   189     * @param aArea the area to redraw
       
   190     */
       
   191     virtual void Redraw(const TRect& aArea);
       
   192         
       
   193       
       
   194     /**
       
   195     * Load layouts for the text      
       
   196     */      
       
   197     void PrepareProcessingBackgroundL();
       
   198 
       
   199     /**
       
   200     * Load processing image/video text from resources.
       
   201     */
       
   202     void PrepareProcessingTextL( TBool aStillMode );  
       
   203     
       
   204     /**
       
   205     * Delete and null processing text, after which
       
   206     * the text will no longer be drawn.
       
   207     */
       
   208     void DismissProcessingText();
       
   209     
       
   210     /**
       
   211      * Load processing image text for burst from resources.
       
   212      */
       
   213     void PrepareBurstProcessingTextL();  
       
   214 
       
   215     /**
       
   216      * Update processing image text for burst.
       
   217      * @param aHandled number of imagedata received
       
   218      * @param aTotal number of snapshots received
       
   219      */
       
   220     void UpdateBurstProcessingTextL( TInt aHandled, TInt aTotal );  
       
   221 
       
   222     /**
       
   223      * Delete and null processing text, after which
       
   224      * the text will no longer be drawn.
       
   225      */
       
   226     void DismissBurstProcessingText();
       
   227     
       
   228     /**
       
   229     * Viewfinder layout rect
       
   230 	* @param aTargetMode target mode for which viewfinder rect is required. Default(ECamControllerIdle) corresponds to current active mode.
       
   231     * @return TRect viewfinder rect from layout
       
   232     */
       
   233     TRect ViewFinderFrameRect(TCamCameraMode aTargetMode = ECamControllerIdle) const; 
       
   234  
       
   235     /**
       
   236     * We check for the file name whenever we call the UMP
       
   237     * or Properties view and come back.
       
   238     */
       
   239     virtual void CheckForFileName( TBool aDoCheck );
       
   240         
       
   241   protected: 
       
   242 
       
   243     /**
       
   244     * Whether or not this key is considered to be capture key
       
   245     * in the current context
       
   246     * @since 3.0
       
   247     * @param aKeyEvent the key event
       
   248     * @param aType the type of event
       
   249     * @return ETrue if this is a capture key, otherwise EFalse
       
   250     */
       
   251     TBool IsCaptureKeyL( const TKeyEvent& aKeyEvent,
       
   252                                TEventCode aType ) ;
       
   253 
       
   254     /**
       
   255     * Whether or not this key is considered to be shutter key
       
   256     * in the current context
       
   257     * @since 3.0
       
   258     * @param aKeyEvent the key event
       
   259     * @param aType the type of event
       
   260     * @return ETrue if this is a shutter key, otherwise EFalse
       
   261     */
       
   262     TBool IsShutterKeyL( const TKeyEvent& aKeyEvent,
       
   263                                TEventCode aType ) ;                 
       
   264 
       
   265     /**
       
   266     * Whether or not this key is considered to be zoom key
       
   267     * in the current context
       
   268     * @since 3.0
       
   269     * @param aKeyEvent the key event
       
   270     * @param aType the type of event
       
   271     * @return ETrue if this is a zoom key, otherwise EFalse
       
   272     */
       
   273     TBool IsZoomKeyL( const TKeyEvent& aKeyEvent,
       
   274                             TEventCode aType ) ;
       
   275     /**
       
   276     * Is zoom operation currently possible?
       
   277     * @since 3.0
       
   278     */               
       
   279     TBool ZoomAvailable();
       
   280     
       
   281     /**
       
   282     * Is Primary Capture Key
       
   283     * @since 9.1
       
   284     */               
       
   285     TBool IsPrimaryCameraCaptureKey( const TKeyEvent& aKeyEvent ) const ;     
       
   286     
       
   287     /**
       
   288     * Is Secondary Capture Key
       
   289     * @since 9.1 ( checking for scan codes )
       
   290     */               
       
   291     TBool IsSecondaryCameraCaptureKey( const TKeyEvent& aKeyEvent ) const ;    
       
   292     /**
       
   293     * Enters viewfinder mode either in image or videomode
       
   294     * depending current visible view. Also starts idle timer.
       
   295     */
       
   296     void ReserveAndStartVF();
       
   297     
       
   298   // -------------------------------------------------------
       
   299   // Constructors
       
   300   protected: 
       
   301 
       
   302     /**
       
   303     * C++ constructor
       
   304     * @since 2.8
       
   305     * @param aController reference to CCamAppController instance
       
   306     * @param aView reference to the view containing this container
       
   307     */
       
   308     CCamContainerBase( CCamAppController& aController,
       
   309                        CAknView& aView );
       
   310     /**
       
   311     * Symbian OS 2nd phase constructor.
       
   312     * @since 2.8
       
   313     * @param aRect Frame rectangle for container.
       
   314     */
       
   315     void BaseConstructL( const TRect& aRect ); 
       
   316     
       
   317   protected:
       
   318     /**
       
   319      * Create background context (iBgContext). May be overridden by
       
   320      * derived classes.
       
   321      * @since S60 v5.0
       
   322      */
       
   323     virtual void CreateBackgroundContextL();
       
   324     
       
   325 public:
       
   326     
       
   327     /**
       
   328     * Returns the number of component controls
       
   329     * @since 3.0
       
   330     * @return The number of owned controls to display
       
   331     */       
       
   332     TInt CountComponentControls() const;
       
   333     
       
   334     /**
       
   335     * Returns the specified component control
       
   336     * @since 3.0
       
   337     * @param aIndex The index of the control to return
       
   338     * @return Pointer to the specified control
       
   339     */               
       
   340     CCoeControl* ComponentControl( TInt aIndex ) const;
       
   341     
       
   342   // =======================================================
       
   343   private:
       
   344     /*
       
   345     * Checks for the zoom key with the mapped key's scan code
       
   346     */
       
   347     TBool CheckForZoomKey( const TKeyEvent& aKeyEvent );  
       
   348     
       
   349     /*
       
   350     * Checks for the zoom-in/out key from the mapped key's scan code 
       
   351     * from the zoom array
       
   352     */
       
   353     TBool CheckInZoomKeyArray( const TKeyEvent& aKeyEvent );
       
   354     
       
   355   // Data
       
   356   protected: 
       
   357 
       
   358     CAknView& iView;
       
   359     CCamAppController& iController; 
       
   360     
       
   361     // The ID of the previous view
       
   362     TCamAppViewIds iPrevViewId;
       
   363     
       
   364     // context for skin background drawing
       
   365     MAknsControlContext* iBgContext;
       
   366 
       
   367     // The current pane displayed in the Application Pane
       
   368     TCamActiveNaviPane iPaneInUse;
       
   369     
       
   370     // Instance of Navi Counter control (not owned)
       
   371     CCamNaviCounterControl* iNaviCounterControl;
       
   372     
       
   373     // Instance of Navi Progress control (not owned)
       
   374     CCamNaviProgressBarControl* iNaviProgressBarControl;
       
   375               
       
   376     // Instance of ActivePalette2 control (not owned)
       
   377     static MActivePalette2UI*   iActivePalette;
       
   378 
       
   379     // ETrue if shutter key (half-press) has been made
       
   380     TBool iKeyShutter;
       
   381 
       
   382     // zoom keys for primary and secondary camera
       
   383     RArray<TInt> iPrimaryZoomInKeys;
       
   384     RArray<TInt> iPrimaryZoomOutKeys;
       
   385     RArray<TInt> iSecondaryZoomInKeys;
       
   386     RArray<TInt> iSecondaryZoomOutKeys;
       
   387 
       
   388     // capture keys
       
   389     RArray<TInt> iPrimaryCameraCaptureKeys;
       
   390     RArray<TInt> iSecondaryCameraCaptureKeys;
       
   391     
       
   392     // AF key or half capture key press scan codes
       
   393     RArray<TInt> iPrimaryCameraAFKeys;    
       
   394     
       
   395     /// Remember current orientation, so we only redraw when necessary
       
   396     TCamOrientation iCamOrientation;
       
   397 
       
   398   TAknLayoutText iProcessingTextLayout;
       
   399   HBufC* iProcessingText;
       
   400       TAknLayoutText iBurstProcessingTextLayout;
       
   401       HBufC* iBurstProcessingText;
       
   402   
       
   403   //Backup child container to keep the background of viewfinder window always opaque
       
   404   CCamBackupContainer* iBackupContainer;
       
   405   };
       
   406 
       
   407 #endif // CAMCONTAINERBASE_H
       
   408 
       
   409 // End of File