photosgallery/viewframework/views/viewbase/inc/glxviewbase.h
changeset 0 4e91876724a2
child 9 6b87b143d312
equal deleted inserted replaced
-1:000000000000 0:4e91876724a2
       
     1 /*
       
     2 * Copyright (c) 2008-2009 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:    View Base 
       
    15 *
       
    16 */
       
    17 
       
    18 
       
    19 
       
    20 
       
    21 #ifndef C_GLXVIEWBASE_H
       
    22 #define C_GLXVIEWBASE_H
       
    23 
       
    24 // INCLUDES
       
    25 
       
    26 
       
    27 #include <aknview.h>
       
    28 #include  <akntitle.h>
       
    29 #include <alf/alftimedvalue.h>
       
    30 #include <alf/ialfviewwidget.h>
       
    31 #include <glxanimationfactory.h>
       
    32 #include "glxkeyeventreceiver.h"
       
    33 #include <mglxanimationobserver.h>
       
    34 #include <glxlog.h>
       
    35 #include <akntoolbar.h>
       
    36 #include <akntoolbarobserver.h>
       
    37 #include "mglxsoftkeyhandler.h"
       
    38 #include <mul/mulevent.h>
       
    39 #include <alf/ialfwidgetfactory.h>
       
    40 class CGlxCommandHandler;
       
    41 class CGlxUiUtility;
       
    42 class CAlfControlGroup;
       
    43 class CGlxKeyMonitor;
       
    44 
       
    45 // CLASS DECLARATION
       
    46 
       
    47 /**
       
    48  *  View base
       
    49  *
       
    50  *  @lib glxviewbase.lib
       
    51  */
       
    52 class CGlxViewBase : public CAknView, 
       
    53                      public MGlxAnimationObserver,
       
    54                      public MAknToolbarObserver
       
    55     {
       
    56 public:
       
    57     /**
       
    58      * Constructor
       
    59      */
       
    60     IMPORT_C CGlxViewBase(TBool aSyncActivation = EFalse);
       
    61 
       
    62     /**
       
    63      * Destructor.
       
    64      */
       
    65     IMPORT_C virtual ~CGlxViewBase();
       
    66 
       
    67     /**
       
    68      * Add a command handler to the view (ownership transferred and the
       
    69      * command handler is deleted in the event of a leave).
       
    70      * @param aCommandHandler The command handler to add.
       
    71      */
       
    72     IMPORT_C void AddCommandHandlerL(CGlxCommandHandler* aCommandHandler);
       
    73 
       
    74 	/**
       
    75 	 * Enable and set a Title in screen furniture
       
    76 	 * @param aTitleText The text to be displayed
       
    77 	 * @param aAnimate Indicates if the change is to be animated
       
    78 	 */
       
    79     IMPORT_C void SetTitleL(const TDesC& aTitleText);
       
    80 
       
    81 	/**
       
    82 	 * Disable a Title in screen furniture
       
    83 	 * @param aAnimate Indicates if the change is to be animated
       
    84 	 */
       
    85     IMPORT_C void DisableTitle();
       
    86 	
       
    87 	/**
       
    88      * Handles commands
       
    89 	 * @param aCommand The command to respond to
       
    90 	 * @return ETrue iff the command has been handled.
       
    91      */
       
    92     IMPORT_C virtual TInt DoHandleCommandL(TInt aCommand);    
       
    93     
       
    94 
       
    95 protected: // From MCoeView.
       
    96 
       
    97     /** 
       
    98      * See @ref MCoeView. 
       
    99      */
       
   100 	IMPORT_C void ViewActivatedL(const TVwsViewId& aPrevViewId,
       
   101 	                             TUid aCustomMessageId,
       
   102 	                             const TDesC8& aCustomMessage);
       
   103 
       
   104     /** 
       
   105      * See @ref MCoeView
       
   106      */
       
   107 	IMPORT_C void ViewDeactivated();
       
   108 
       
   109 
       
   110 protected: // From MGlxAnimationObserver 
       
   111     IMPORT_C virtual void AnimationComplete(MGlxAnimation* aAnimation); 
       
   112 
       
   113 protected:
       
   114     //From MAknToolbarObserver
       
   115     IMPORT_C void OfferToolbarEventL( TInt aCommand );
       
   116     
       
   117     IMPORT_C void SetToolbarObserver(MAknToolbarObserver* aObserver);
       
   118     
       
   119 protected:
       
   120 	/**
       
   121 	 * IMPORTANT: Call this from the ConstructL of any derived class
       
   122 	 */
       
   123 	IMPORT_C void ViewBaseConstructL();
       
   124 
       
   125 	/**
       
   126 	 * Derived classes should use this to deal with any view-specific commands
       
   127 	 * @param aCommand The command to respond to
       
   128 	 * @return ETrue iff the command has been handled.
       
   129 	 */
       
   130 	IMPORT_C virtual TBool HandleViewCommandL(TInt aCommand);
       
   131 	
       
   132 	/**
       
   133 	 * Derived classes should use this to initialize the menus if required
       
   134 	 * @param aResourceId The menu resource
       
   135 	 * @param aMenuPane The menu pane to edit
       
   136 	 */
       
   137 	IMPORT_C virtual void ViewDynInitMenuPaneL(TInt aResourceId, CEikMenuPane* aMenuPane);
       
   138 	
       
   139 	/**
       
   140 	 * This will be called on derived classes when the view is activated
       
   141      * @param aPrevViewId Specifies the view previously active.
       
   142      * @param aCustomMessageId Specifies the message type.
       
   143      * @param aCustomMessage The activation message.
       
   144 	 */
       
   145 	virtual void DoViewActivateL(const TVwsViewId& aPrevViewId, TUid aCustomMessageId, const TDesC8& aCustomMessage) = 0;
       
   146 	
       
   147 	/**
       
   148 	 * This will be called on derived classes when the view is deactivated
       
   149 	 */
       
   150     virtual void DoViewDeactivate() = 0;
       
   151 
       
   152     /**
       
   153 	 * This is called on derived classes before the options menu
       
   154 	 * is opened. The derived classes should use it to ensure that 
       
   155 	 * all required attributes have been retrieved in order to determine
       
   156 	 * if the command should be displayed on the options menu and.
       
   157 	 */
       
   158     IMPORT_C virtual void FetchAttributesL();    
       
   159 	
       
   160     /**
       
   161    	 * This is called on derived classes before commands are executed.
       
   162    	 * The derived classes should use it to ensure that all the required
       
   163    	 * attributes have been tetrieved in order to execute the command.
       
   164    	 */
       
   165     IMPORT_C virtual void FetchAttributesForCommandL(TInt aCommand);
       
   166     
       
   167 	/**
       
   168      * Report whether the given type of animation is supported by the class
       
   169      * @return ETrue iff the animaiton is implemented
       
   170      */
       
   171     IMPORT_C virtual TBool ViewAnimationSupported(TGlxViewswitchAnimation aType); 
       
   172     
       
   173     /**
       
   174      * Start the given type of view-switch animation
       
   175      * @param aType The type of animation (e.g. Entry / Exit)
       
   176      * @param aDirection The direction of the animation (e.g. Forwards / Backwards)
       
   177      */
       
   178     IMPORT_C virtual void DoViewAnimationL(TGlxViewswitchAnimation aType, TGlxNavigationDirection aDirection);
       
   179     
       
   180     /**
       
   181      * Sets the toolbar state after command execution.
       
   182      * @ return ETrue If item is a system item. Else EFalse 
       
   183      */
       
   184     IMPORT_C virtual void SetToolbarStateL();
       
   185 
       
   186     
       
   187 private:	
       
   188 	// From MEikMenuObserver
       
   189 	IMPORT_C virtual void DynInitMenuPaneL(TInt aResourceId, CEikMenuPane* aMenuPane);
       
   190 	
       
   191 	// From MGlxUiCommandHandler
       
   192 	IMPORT_C void HandleCommandL(TInt aCommand);
       
   193 
       
   194 	// From CAknView
       
   195     IMPORT_C void DoActivateL(const TVwsViewId& aPrevViewId, TUid aCustomMessageId, const TDesC8& aCustomMessage);
       
   196     IMPORT_C void DoDeactivate();
       
   197 
       
   198 private:
       
   199 
       
   200     /**
       
   201      * Initialize a viewswitch animation
       
   202      * @param aType The type of animation to start
       
   203      */
       
   204     void InitAnimationL(TGlxViewswitchAnimation aType); 
       
   205     
       
   206     /**
       
   207      * Cancel the current viewswitch animation, if any
       
   208      */
       
   209     void CancelViewAnimation(); 
       
   210 
       
   211     /**
       
   212      * Called when the view-switch animation is complete or interrupted
       
   213      * @param aType The type of animation (e.g. Entry / Exit)
       
   214      */
       
   215     void ViewAnimationComplete(TGlxViewswitchAnimation aType); 
       
   216     
       
   217     /**
       
   218      * Gets the title pane instance.
       
   219      */
       
   220     CAknTitlePane* GetTitlePaneL();
       
   221 
       
   222 protected:
       
   223 	/**
       
   224 	 * Optionally implemented by sub-classes to prepare command handlers.
       
   225 	 * Called once for every command handler added to the view.
       
   226 	 * @param aCommandHandler command handler added to the view.
       
   227 	 */
       
   228     virtual void DoPrepareCommandHandlerL(CGlxCommandHandler* /*aCommandHandler*/) {};
       
   229 
       
   230 protected:
       
   231 	/// The list of command handlers owned by the view
       
   232 	RPointerArray<CGlxCommandHandler> iCommandHandlerList;    
       
   233 
       
   234 protected:
       
   235 	CGlxUiUtility* iUiUtility; ///< The UiUtility in use
       
   236 	
       
   237 	/// The view animation time
       
   238     TInt iViewAnimationTime; 
       
   239 private:
       
   240     /**
       
   241      * Functions to handle view activate asynchronously
       
   242      */
       
   243     static TBool ViewActivateCallbackL(TAny* aPtr);
       
   244     inline void ViewActivateL();
       
   245 
       
   246 private:
       
   247     /// Resource file offset
       
   248     TInt iViewBaseResourceOffset;
       
   249 
       
   250     /// Ui Utility resource file offset
       
   251     TInt iUiUtilitiesResourceOffset;
       
   252     /// The type of viewswitch animation in progress, if any
       
   253     TGlxViewswitchAnimation iViewAnimationInProgress; 
       
   254     
       
   255     /// Flag to determine if this view is activated synchronously
       
   256     const TBool iSyncActivation;
       
   257 
       
   258     //This is a Kind of Hack to prevent Photos to act on any command's till 
       
   259     //Corresponding view is activated
       
   260     //This Should be fixed with Proper Way
       
   261     TBool iViewActivated;
       
   262 
       
   263     /// View activate attributes for callback
       
   264     TVwsViewId iPrevViewId;
       
   265     TUid iCustomMessageId;
       
   266     HBufC8* iCustomMessage;
       
   267 
       
   268     /// Callback for view activate
       
   269 	CAsyncCallBack* iViewActivateCallback;
       
   270 		
       
   271 	/// Status pane for title
       
   272 	CAknTitlePane* iTitlePane;
       
   273     };
       
   274 
       
   275 
       
   276 #endif // C_GLXVIEWBASE_H