williamr@2: /* williamr@2: * Copyright (c) 2005, 2006 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: The interface of the info pop-up note williamr@2: * williamr@2: */ williamr@2: williamr@2: williamr@2: // ------------------------------------------------------------------------ williamr@2: // How to use this info popup component (basic case): williamr@2: // williamr@2: // williamr@2: // #include williamr@2: // CAknInfoPopupNoteController* iPopupController; williamr@2: // ... williamr@2: // iPopupController = CAknInfoPopupNoteController::NewL(); williamr@2: // ... williamr@2: // iPopupController->SetTextL( strTestText ); williamr@2: // iPopupController->ShowInfoPopupNote(); williamr@2: // ... williamr@2: // delete iPopupController; williamr@2: // ------------------------------------------------------------------------ williamr@2: williamr@2: williamr@2: #ifndef CAKNINFOPOPUPNOTECONTROLLER_H williamr@2: #define CAKNINFOPOPUPNOTECONTROLLER_H williamr@2: williamr@2: // INCLUDES williamr@2: #include williamr@2: #include williamr@2: #include "avkon.hrh" williamr@2: williamr@2: // FORWARD DECLARATIONS williamr@2: class CAknInfoPopupNote; williamr@2: class CAknInfoPopupNoteController; williamr@2: williamr@2: // CLASS DECLARATION williamr@2: williamr@2: /** williamr@2: * Observer class for notifying popup's showing and hiding. williamr@2: * williamr@2: * @lib avkon.lib williamr@2: * @since Series 60 3.0 williamr@2: */ williamr@2: class MAknInfoPopupNoteObserver williamr@2: { williamr@2: public: williamr@2: williamr@2: enum TAknInfoPopupNoteEvent williamr@2: { williamr@2: EInfoPopupNoteShown, williamr@2: EInfoPopupNoteHidden williamr@2: }; williamr@2: williamr@2: /** williamr@2: * Handles events reported from info popup note. williamr@2: * @param aController The controller that controls the note, from williamr@2: * where the event originates. williamr@2: * @param aEvent The event. williamr@2: */ williamr@2: virtual void HandleInfoPopupNoteEvent( williamr@2: CAknInfoPopupNoteController* aController, williamr@2: TAknInfoPopupNoteEvent aEvent ) = 0; williamr@2: }; williamr@2: williamr@2: williamr@2: /** williamr@2: * The controller part of popup. williamr@2: * It is active object, and uses timer to show popup after specified williamr@2: * time interval (default 1 sec.) and popup hides automaticly williamr@2: * after an other period (default 10 sec.). williamr@2: * williamr@2: * @lib avkon.lib williamr@2: * @since Series 60 3.0 williamr@2: */ williamr@2: class CAknInfoPopupNoteController : public CTimer williamr@2: { williamr@2: public: williamr@2: /** williamr@2: * The tone played before the dialog is shown. williamr@2: * Application specific tones may be played by casting the application williamr@2: * defined Sound ID (SID), to TTone williamr@2: */ williamr@2: enum TTone williamr@2: { williamr@2: /** No tone is played. */ williamr@2: ENoTone = 0, williamr@2: /** A confirmation tone is played. */ williamr@2: EConfirmationTone = EAvkonSIDConfirmationTone, williamr@2: /** A warning tone is played. */ williamr@2: EWarningTone = EAvkonSIDWarningTone, williamr@2: /** An error tone is played. */ williamr@2: EErrorTone = EAvkonSIDErrorTone williamr@2: }; williamr@2: williamr@2: public: // Constructors and destructor williamr@2: williamr@2: /** williamr@2: * Two-phased constructor. williamr@2: */ williamr@2: IMPORT_C static CAknInfoPopupNoteController* NewL(); williamr@2: williamr@2: /** williamr@2: * Destructor. williamr@2: */ williamr@2: virtual ~CAknInfoPopupNoteController(); williamr@2: williamr@2: public: // New functions williamr@2: williamr@2: /** williamr@2: * Set time delay period before popup is shown (in milliseconds). williamr@2: * (if this isn't set, default delay time before show is 1 sec. ) williamr@2: * @param aMilliSeconds Wanted delay time in milliseconds. williamr@2: */ williamr@2: IMPORT_C void SetTimeDelayBeforeShow( TInt aMilliSeconds ); williamr@2: williamr@2: /** williamr@2: * Set time period how long popup is in view (in milliseconds). williamr@2: * (if this isn't set, default show time is 10 sec. ) williamr@2: * @param aMilliSeconds Wanted show time in milliseconds. williamr@2: * if set to 0, popup is shown until HideInfoPopupNote is called williamr@2: */ williamr@2: IMPORT_C void SetTimePopupInView( TInt aMilliSeconds ); williamr@2: williamr@2: /** williamr@2: * Set text to show in popup. If given text is too long for popup, williamr@2: * it is truncated. williamr@2: * @param aText Text to show in popup. williamr@2: */ williamr@2: IMPORT_C void SetTextL( const TDesC& aText ); williamr@2: williamr@2: /** williamr@2: * Show popup after delay time (hide possible previous popup immediately) williamr@2: * and hide popup again after setted time. williamr@2: */ williamr@2: IMPORT_C void ShowInfoPopupNote(); williamr@2: williamr@2: /** williamr@2: * Hide popup immediately. williamr@2: */ williamr@2: IMPORT_C void HideInfoPopupNote(); williamr@2: williamr@2: /** williamr@2: * Adds an observer for the pop-up. williamr@2: * @param aObserver The observer to be added. williamr@2: */ williamr@2: IMPORT_C void AddObserverL( const MAknInfoPopupNoteObserver& aObserver ); williamr@2: williamr@2: /** williamr@2: * Removes an observer from the pop-up. williamr@2: * @param aObserver The observer to be removed. williamr@2: */ williamr@2: IMPORT_C void RemoveObserver( const MAknInfoPopupNoteObserver& aObserver ); williamr@2: williamr@2: /** williamr@2: * Sets the position and alignment of the info pop-up note. williamr@2: * @since 3.1 williamr@2: * @param aPosition The position, where pop-up note is displayed. williamr@2: * @param aAlignment Specifies the part of pop-up note that will be aligned williamr@2: * with the given position. williamr@2: */ williamr@2: IMPORT_C void SetPositionAndAlignment( const TPoint& aPosition, williamr@2: const TGulAlignmentValue& aAlignment ); williamr@2: williamr@2: /** williamr@2: * Sets the position of the info pop-up note so that it is aligned with the williamr@2: * given rectangle as specified in the LAF data. This is intented to be williamr@2: * used in conjunction with lists and grids if the application wishes to williamr@2: * implement a pop-up that follows lists/grids item highlight. williamr@2: * @since 3.1 williamr@2: * @param aHighlightRect Screen-relative rectangle used to calculate williamr@2: * pop-up's position. williamr@2: */ williamr@2: IMPORT_C void SetPositionByHighlight( const TRect& aHighlightRect ); williamr@2: williamr@2: /** williamr@2: * Restores the info pop-up note's default position discarding previously williamr@2: * set values to position and alignment. williamr@2: * @since 3.1 williamr@2: */ williamr@2: IMPORT_C void RestoreDefaultPosition(); williamr@2: williamr@2: /** williamr@2: * Sets the tooltip mode. When tooltip mode is on, info pop-up note is williamr@2: * displayed with only one line of text, and the width of the pop-up note williamr@2: * depends on the text length. williamr@2: * @since 3.1 williamr@2: * @param aTooltipMode ETrue to set tooltip mode on, EFalse to set it off. williamr@2: */ williamr@2: IMPORT_C void SetTooltipModeL( const TBool aTooltipMode ); williamr@2: williamr@2: /** williamr@2: * Notifies the observers of the info popup note of an event. williamr@2: * @param aEvent The event, of which the observers are notified. williamr@2: */ williamr@2: void NotifyObservers( MAknInfoPopupNoteObserver::TAknInfoPopupNoteEvent aEvent ); williamr@2: williamr@2: /** williamr@2: * Set the tone to be played when the info popup note is shown williamr@2: * @param aTone The tone williamr@2: */ williamr@2: IMPORT_C void SetTone( const TTone& aTone ); williamr@2: williamr@2: /** williamr@2: * Whether info popup note will be automatically hidden williamr@2: * or not when app ui is faded (true by default) williamr@2: * @since 3.1 williamr@2: * @param aHide ETrue when hidden, EFalse when shown or controlled externally williamr@2: */ williamr@2: IMPORT_C void HideWhenAppFaded( const TBool aHide ); williamr@2: williamr@2: protected: williamr@2: williamr@2: /** williamr@2: * From CTimer. Cancels an outstanding asynchronous request. williamr@2: */ williamr@2: void DoCancel(); williamr@2: williamr@2: private: // From CActive williamr@2: williamr@2: /** williamr@2: * Show popup. Called by system framework. williamr@2: */ williamr@2: void RunL(); williamr@2: williamr@2: private: williamr@2: williamr@2: /** williamr@2: * C++ default constructor. williamr@2: */ williamr@2: CAknInfoPopupNoteController(); williamr@2: williamr@2: /** williamr@2: * By default Symbian 2nd phase constructor is private. williamr@2: */ williamr@2: void ConstructL(); williamr@2: williamr@2: /** williamr@2: * Play the tone. williamr@2: */ williamr@2: void PlayTone(); williamr@2: williamr@2: private: // Data williamr@2: williamr@2: enum TInfoPopupNoteState williamr@2: { williamr@2: EHidden, williamr@2: EWaitingToShow, williamr@2: EShowing williamr@2: }; williamr@2: williamr@2: TInfoPopupNoteState iState; williamr@2: williamr@2: // Own. View object for popup's model-view-controller williamr@2: CAknInfoPopupNote* iPopup; williamr@2: williamr@2: // Array containing the observers of popup. williamr@2: RPointerArray iObservers; williamr@2: williamr@2: // Delay before popup show williamr@2: TInt iTimeDelayBeforeShow; // in microseconds williamr@2: williamr@2: // How long popup is shown williamr@2: TInt iTimeInView; // in microseconds williamr@2: williamr@2: // Specifies the tone williamr@2: TTone iTone; williamr@2: }; williamr@2: williamr@2: #endif // CAKNINFOPOPUPNOTECONTROLLER_H williamr@2: williamr@2: williamr@2: // End of File