williamr@2: /*
williamr@2: * Copyright (c) 2002 Nokia Corporation and/or its subsidiary(-ies).
williamr@2: * All rights reserved.
williamr@2: * This component and the accompanying materials are made available
williamr@2: * under the terms of the License "Symbian Foundation License v1.0" to Symbian Foundation members and "Symbian Foundation End User License Agreement v1.0" to non-members
williamr@2: * which accompanies this distribution, and is available
williamr@2: * at the URL "http://www.symbianfoundation.org/legal/licencesv10.html".
williamr@2: *
williamr@2: * Initial Contributors:
williamr@2: * Nokia Corporation - initial contribution.
williamr@2: *
williamr@2: * Contributors:
williamr@2: *
williamr@2: * Description:  Base class for view architecture-based applications.
williamr@2: *
williamr@2: */
williamr@2: 
williamr@2: #ifndef __AKNVIEWAPPUI_H__
williamr@2: #define __AKNVIEWAPPUI_H__
williamr@2: 
williamr@2: // INCLUDES
williamr@2: #include <aknappui.h>
williamr@2: 
williamr@2: // FORWARD DECLARATIONS
williamr@2: class CAknView;
williamr@2: class CAknViewShutter;
williamr@2: class CAknLocalScreenClearer;
williamr@2: class CAknViewAppUiExtension;
williamr@2: class CAknViewNavigator;
williamr@2: 
williamr@2: // MACROS
williamr@2: #define iAvkonViewAppUi ((CAknViewAppUi*)CEikonEnv::Static()->EikAppUi())
williamr@2: 
williamr@2: // CLASS DECLARATION
williamr@2: 
williamr@2: /**
williamr@2: *  Base class for view architecture-based applications.
williamr@2: *
williamr@2: *  @since Series 60 0.9
williamr@2: */
williamr@2: class CAknViewAppUi : public CAknAppUi
williamr@2:     {
williamr@2: public:
williamr@2: 	NONSHARABLE_CLASS(CViewActivationItem) : public CBase
williamr@2: 		{
williamr@2: 	public:
williamr@2: 
williamr@2:         /**
williamr@2:         * Two-phased constructor.
williamr@2:         * @param aNewView Application view.
williamr@2:         * @param aCustomMessageId Message ID.
williamr@2:         * @param aCustomMessage Message contents.
williamr@2:         * @param aPrevViewId The UID of the previously active view.
williamr@2:         * @return Pointer to new @c CViewActivationItem object.
williamr@2:         */
williamr@2: 		static CViewActivationItem* NewLC(CAknView* aNewView, 
williamr@2: 		                                  TUid aCustomMessageId, 
williamr@2: 		                                  const TDesC8& aCustomMessage, 
williamr@2: 		                                  const TVwsViewId& aPrevViewId);
williamr@2: 		
williamr@2: 		/**
williamr@2:         * Destructor.
williamr@2:         */
williamr@2: 		~CViewActivationItem();
williamr@2: 	private:
williamr@2: 		CViewActivationItem(CAknView* aNewView, 
williamr@2: 		                    TUid aCustomMessageId,
williamr@2: 		                    const TVwsViewId& aPrevViewId);
williamr@2: 		                    
williamr@2: 		void ConstructL(const TDesC8& aCustomMessage);
williamr@2: 	public:
williamr@2: 		
williamr@2: 		// Application view.
williamr@2: 		CAknView* iNewView;
williamr@2: 		
williamr@2: 		// Message ID.
williamr@2: 		TUid iCustomMessageId;
williamr@2: 		
williamr@2: 		// Message contents.
williamr@2: 		HBufC8* iCustomMessage;
williamr@2: 		
williamr@2: 		// The UID of the previously active view.
williamr@2: 		TVwsViewId iPrevViewId;
williamr@2: 		};
williamr@2: 
williamr@2:         /**
williamr@2:         * Container class used to hold information about one split view.
williamr@2:         */
williamr@2:         NONSHARABLE_CLASS(TAknSplitViewContainer)
williamr@2:             {
williamr@2:             public:
williamr@2:                 /**
williamr@2:                 * Checks is a view is part of the split view.
williamr@2:                 * @param aViewId UID of the view to be checked.
williamr@2:                 * @return ETrue if the given view belongs to the split view.
williamr@2:                 */
williamr@2:                 TBool IsPartOf( const TUid aViewId );
williamr@2: 
williamr@2:             public:
williamr@2:                 // view uids
williamr@2:                 TUid iViewIds[2];
williamr@2:                 // ETrue if a view's activation failed
williamr@2:                 TBool iFailed[2];
williamr@2:                 // drawing areas
williamr@2:                 TRect iViewRect[2];
williamr@2:                 // the size of the leftmost view
williamr@2:                 TInt iLeftViewSize;
williamr@2:             };
williamr@2: 
williamr@2:     	typedef CArrayPtrFlat<CViewActivationItem> CAknViewActivationQueue;
williamr@2:     	typedef CArrayPtrFlat<CAknView> CAknViews;
williamr@2: 
williamr@2: public:
williamr@2: 
williamr@2:     /**
williamr@2:     * Initialises this app UI with standard values.
williamr@2:     * @param aAppUiFlags Application user interface flags.
williamr@2:     */
williamr@2: 	IMPORT_C void BaseConstructL(TInt aAppUiFlags=EStandardApp);
williamr@2: 	
williamr@2: 	/**
williamr@2:     * Destructor.
williamr@2:     */
williamr@2: 	IMPORT_C virtual ~CAknViewAppUi();
williamr@2:     
williamr@2:     /**
williamr@2:     * Activates a specified application view, without passing any message.
williamr@2:     * The function leaves if activation of the view fails.
williamr@2:     * @param aViewId Identifier of the view to activate.
williamr@2:     */
williamr@2: 	IMPORT_C void ActivateLocalViewL(TUid aViewId);
williamr@2: 
williamr@2:     /**
williamr@2:     * Activates a specified application view, then passes the message text 
williamr@2:     * descriptor aCustomMessage for a message of type aCustomMessageId.
williamr@2:     * The function leaves if activation of the view fails.
williamr@2:     * @param aViewId Identifier of the view to activate.
williamr@2:     * @param aCustomMessageId Specifies the message type.
williamr@2:     * @param aCustomMessage The message passed to the activated view.
williamr@2:     */
williamr@2: 	IMPORT_C void ActivateLocalViewL(TUid aViewId, 
williamr@2: 	                                 TUid aCustomMessageId,
williamr@2: 	                                 const TDesC8& aCustomMessage);
williamr@2: 	
williamr@2: 	/**
williamr@2:     * Gets a pointer to specified application view.
williamr@2:     * @param aView ID of the application view.
williamr@2:     * @return Pointer to application view object, 
williamr@2:     * NULL if aView doesn't exists.
williamr@2:     */
williamr@2: 	IMPORT_C CAknView* View(TUid aView) const;
williamr@2: 	
williamr@2: 	/**
williamr@2:     * Registers and adds the view to the app UI. 
williamr@2:     * This function calls @c CCoeAppUi::RegisterViewL.
williamr@2:     * @param aView The view to be registered and added.
williamr@2:     */
williamr@2: 	IMPORT_C void AddViewL(CAknView* aView);	// takes ownership of aView
williamr@2: 
williamr@2: 	/**
williamr@2:     * Removes and deregisteres the view from the app UI. 
williamr@2:     * This function calls @c CCoeAppUi::DeregisterView.
williamr@2:     * @param aViewId The view to be deregistered and removed.
williamr@2:     */
williamr@2: 	IMPORT_C void RemoveView(TUid aViewId);
williamr@2:     
williamr@2:     /**
williamr@2:     * Processes user commands.
williamr@2:     * @param aCommand A command ID.
williamr@2:     */
williamr@2: 	IMPORT_C void ProcessCommandL(TInt aCommand);
williamr@2: 	
williamr@2: 	/**
williamr@2:     * Stops displaying the application’s menu bar.
williamr@2:     */
williamr@2: 	IMPORT_C void StopDisplayingMenuBar();
williamr@2: 
williamr@2: 	// Avkon view architecture system. Internal use only.
williamr@2: 	void ViewActivatedL(CAknView* aView, 
williamr@2: 	                    const TVwsViewId& aPrevViewId,
williamr@2: 	                    TUid aCustomMessageId,
williamr@2: 	                    const TDesC8& aCustomMessage);
williamr@2: 	
williamr@2: 	void ViewDeactivated(CAknView* aView);
williamr@2: 
williamr@2:     /**
williamr@2:     * Combines two views. If either of the views belongs to another view combination
williamr@2:     * then that combination is removed.
williamr@2:     * @since Series 60 5.0
williamr@2:     * @param aView1Id UID of the first (leftmost) view.
williamr@2:     * @param aView2Id UID of the second view.
williamr@2:     * @param aLeftViewSize Size of the first view (in percentages).
williamr@2:     */
williamr@2:     IMPORT_C void SetSplitViewL( const TUid aView1Id, const TUid aView2Id, const TInt aLeftViewSize );
williamr@2: 
williamr@2:     /**
williamr@2:     * Removes a view combination containing the given view UID. If the view
williamr@2:     * with the given UID is currently visible then the screen is switched to
williamr@2:     * single view and the the given view stays active.
williamr@2:     * @since Series 60 5.0
williamr@2:     * @param aViewId UID of a view combination.
williamr@2:     */
williamr@2:     IMPORT_C void RemoveSplitViewL( const TUid aViewId );
williamr@2:     	
williamr@2:     /**
williamr@2:     * Checks if split view is in use.
williamr@2:     * @since Series 60 5.0
williamr@2:     * @return ETrue if a split view is active.
williamr@2:     */
williamr@2:     IMPORT_C TBool SplitViewActive() const;
williamr@2:     	
williamr@2:     /**
williamr@2:     * Returns the currently focused view.
williamr@2:     * @since Series 60 5.0
williamr@2:     * @return UID of the currently focused view.
williamr@2:     */
williamr@2:     IMPORT_C TUid FocusedView() const;
williamr@2:     	
williamr@2:     /**
williamr@2:     * Checks if the given view is visible on the screen.
williamr@2:     * @since Series 60 5.0
williamr@2:     * @param aViewId View to be checked.
williamr@2:     * @return ETrue if the given view is visible.	
williamr@2:     */
williamr@2:     IMPORT_C TBool ViewShown( const TUid aViewId ) const;
williamr@2:     
williamr@2:     /**
williamr@2:     * Enables/disables local screen clearer.
williamr@2:     * Local screen clearer is used in the view based applications
williamr@2:     * to clear the application window if/when the view itself fails
williamr@2:     * to do this. By default, the clearer is used.
williamr@2:     * This function must be called before the BaseConstructL() to
williamr@2:     * prevent the screen clearer on application start up.
williamr@2:     *
williamr@2:     * @since 3.2 
williamr@2:     * @param aEnable ETrue enables local screen clearer.
williamr@2:     *                EFalse disables local screen clearer.
williamr@2:     */
williamr@2:     IMPORT_C void EnableLocalScreenClearer( TBool aEnable = ETrue );
williamr@2:     	
williamr@2:     /**
williamr@2:     * Returns view's rectangle.
williamr@2:     * @since Series 60 5.0
williamr@2:     * @param aViewId UID of the view whose rectangle should be returned.
williamr@2:     * @param Given view's drawing area.
williamr@2:     */
williamr@2:     TRect ViewRect( const TUid aViewId ) const;
williamr@2:     	
williamr@2:     /**
williamr@2:     * Handles keyboard initiated navigation between visible split views.
williamr@2:     * @since Series 60 5.0
williamr@2:     * @param aKeyEvent Keyboard event.
williamr@2:     * @param EKeyWasConsumed if view focus was changed.
williamr@2:     */
williamr@2:     TKeyResponse HandleViewNavigationL( const TKeyEvent& aKeyEvent );
williamr@2:     	
williamr@2: protected:
williamr@2: 	
williamr@2: 	/**
williamr@2:     * From @c MEikStatusPaneObserver. Handles a change in the position or
williamr@2:     * size of the screen area occupied by the status pane.
williamr@2:     */
williamr@2: 	IMPORT_C void HandleStatusPaneSizeChange();
williamr@2: 
williamr@2: 	/**
williamr@2:     * From @c CCoeAppUi. Handles changes in keyboard focus when
williamr@2:     * an application switches to foreground.
williamr@2:     * @param aForeground @c ETrue if the application is in the foreground,
williamr@2:     * otherwise @c EFalse.
williamr@2:     */
williamr@2: 	IMPORT_C void HandleForegroundEventL(TBool aForeground);
williamr@2: 
williamr@2:     /**
williamr@2:     * From AknAppUi. Handles pointer-initiated view switch. Currently this
williamr@2:     * function does nothing but calls base class function.
williamr@2:     * @since Series 60 3.0
williamr@2:     * @param aEvent Window server event.
williamr@2:     * @param aDestination Pointer to the control which the event is targeted to.
williamr@2:     */
williamr@2:     IMPORT_C void HandleWsEventL( const TWsEvent& aEvent, CCoeControl* aDestination );
williamr@2:     	
williamr@2: private:
williamr@2: 	static TInt ActivationCallBack(TAny* aThis);
williamr@2: 	void ActivationTick();
williamr@2: 	void QueueActivationTick();
williamr@2: 
williamr@2:     /**
williamr@2:     * Asserts that extension object has been created.
williamr@2:     * @return Extension object.
williamr@2:     */
williamr@2:     CAknViewAppUiExtension* Extension() const;
williamr@2: 
williamr@2:     /**
williamr@2:     * Activates views in split view.
williamr@2:     * @since Series 60 5.0
williamr@2:     * @param View under activation.
williamr@2:     */
williamr@2:     void ActivateSplitViewL( CViewActivationItem* aItem );
williamr@2:     	
williamr@2:     /**
williamr@2:     * If the given view is part of a split view then returns that split view,
williamr@2:     * @since Series 60 5.0
williamr@2:     * @param aViewId UID of a view that belongs to a split view.
williamr@2:     * @return Pointer to a correct split view or NULL if no corresponding split view was found.
williamr@2:     */
williamr@2:     TAknSplitViewContainer* SplitView( const TUid aViewId ) const;
williamr@2:     	
williamr@2: protected:
williamr@2: 	
williamr@2:     // Application view.
williamr@2:     CAknView* iView;
williamr@2: 	
williamr@2:     // Application views.
williamr@2:     CAknViews* iViews;
williamr@2: 
williamr@2: private:
williamr@2:     CAknViewShutter* iShutter;
williamr@2:     CAknLocalScreenClearer* iClearer;
williamr@2:     CAknViewActivationQueue* iActivationQueue;
williamr@2:     CIdle* iActivationTick;
williamr@2:     // extension class
williamr@2:     CAknViewAppUiExtension* iExtension;
williamr@2:     };
williamr@2: 
williamr@2: #endif // __AKNVIEWAPPUI_H__