epoc32/include/mw/aknpreviewpopupcontroller.h
author William Roberts <williamr@symbian.org>
Wed, 31 Mar 2010 12:33:34 +0100
branchSymbian3
changeset 4 837f303aceeb
parent 2 2fe1408b6811
permissions -rw-r--r--
Current Symbian^3 public API header files (from PDK 3.0.h)
This is the epoc32/include tree with the "platform" subtrees removed, and
all but a selected few mbg and rsg files removed.
     1 /*
     2 * Copyright (c) 2005-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:  Preview popup controller.
    15 *
    16 */
    17 
    18 
    19 #ifndef AKNPREVIEWPOPUPCONTROLLER_H
    20 #define AKNPREVIEWPOPUPCONTROLLER_H
    21 
    22 // INCLUDES
    23 #include <e32base.h>
    24 #include <e32std.h>
    25 #include <coecntrl.h>
    26 #include <AknPreviewPopUpObserver.h>
    27 
    28 // FORWARD DECLARATIONS
    29 class MAknPreviewPopUpContentProvider;
    30 class CAknPreviewPopUp;
    31 
    32 // CLASS DECLARATION
    33 
    34 /**
    35 *  Class for controlling the preview popup component.
    36 *  Preview popup is a popup that can be used to show some extra information
    37 *  about e.g. a highlighted list item. It cannot get keyboard focus. Popup is
    38 *  shown after a default timeout of one second and hidden on key press or when
    39 *  it has been visible for ten seconds. These timeouts can be changed via this
    40 *  API.
    41 *
    42 *  Preview popup itself provides only timing services and an empty popup window
    43 *  whose frames and background are drawn with the current skin. It is client
    44 *  application's responsibility to provide the actual content. This can be any
    45 *  object derived from CCoeControl. When the popup is shown it asks content's
    46 *  size using CCoeControl::MinimumSize and sizes itself so that the whole
    47 *  content fits into the popup. Content can also be created asynchronously if
    48 *  it takes considerable amount of time.
    49 *
    50 *  @lib avkon.lib
    51 *  @since S60 3.2
    52 */
    53 NONSHARABLE_CLASS( CAknPreviewPopUpController ) : public CTimer
    54     {
    55     public: // Type definitions
    56         enum TAknPreviewStyle
    57             {
    58             ELayoutDefault = 0x0001, // default graphics are used
    59             ELayoutSubMenu = 0x0002, // submenu graphics are used
    60             EPermanentMode = 0x0004, // popup stays visible infinitely
    61             EFixedMode     = 0x0008, // fixed position and size are used
    62             EExcludeFrames = 0x0010, // frames and heading area are excluded in fixed mode
    63             EAutoMirror    = 0x0020, // opening direction is automatically mirrored in left-to-right layouts
    64             EDontClose     = 0x0040  // popup not closed when pointer up received outside popup 
    65     };
    66             
    67         enum TAknPreviewPopUpContentSize
    68             {
    69             ESmall,
    70             ELarge
    71             };
    72             
    73     public: // Constructors and destructor
    74 
    75         /**
    76         * Two-phased constructor. This version should be used if the content
    77         * is created asynchronously.
    78         * @param aContent Reference to the content of the preview popup.
    79         * @param aContentProvider Reference to the content provider of the popup.
    80         */
    81         IMPORT_C static CAknPreviewPopUpController* NewL( CCoeControl& aContent,
    82             MAknPreviewPopUpContentProvider& aContentProvider );
    83 
    84         /**
    85         * Two-phased constructor. This version should be used if the content is
    86         * created synchronously i.e. it's ready when the popup is about to be
    87         * shown. This is also the normal use case.
    88         * @param aContent Reference to the content of the preview popup.
    89         */
    90         IMPORT_C static CAknPreviewPopUpController* NewL( CCoeControl& aContent );
    91         
    92         /**
    93         * Two-phased constructor. This version should be used if the content
    94         * is created asynchronously.
    95         * @param aContent Reference to the content of the preview popup.
    96         * @param aContentProvider Reference to the content provider of the popup.
    97         * @param aStyle Defines the used layout and behavior flags.
    98         */
    99         IMPORT_C static CAknPreviewPopUpController* NewL( CCoeControl& aContent,
   100             MAknPreviewPopUpContentProvider& aContentProvider,
   101             const TInt aStyle );
   102 
   103         /**
   104         * Two-phased constructor. This version should be used if the content is
   105         * created synchronously i.e. it's ready when the popup is about to be
   106         * shown. This is also the normal use case.
   107         * @param aContent Reference to the content of the preview popup.
   108         * @param aStyle Defines the used layout and behavior flags.
   109         */
   110         IMPORT_C static CAknPreviewPopUpController* NewL( CCoeControl& aContent,
   111             const TInt aStyle );
   112             
   113   	    /**
   114         * Destructor.
   115         */
   116         ~CAknPreviewPopUpController();
   117 
   118     public: // New functions
   119         
   120         /**
   121         * This static function can be used to query the logical size of the
   122         * screen when drawing the content of the popup. When ELarge is returned
   123         * more detailed information (e.g. a picture) can be shown whereas ESmall
   124         * suggests that the available screen area is more limited and simpler
   125         * content should be used.
   126         * @return Logical size of the screen.
   127         */
   128         IMPORT_C static TAknPreviewPopUpContentSize ContentSizeInLayout();
   129 
   130         /**
   131         * Sets the delay used before showing the preview popup. The default 
   132         * delay is one second.
   133         * @param aDelay Delay in microseconds.
   134         */
   135         IMPORT_C void SetPopUpShowDelay( const TTimeIntervalMicroSeconds32& aDelay );
   136         
   137         /**
   138         * Sets the delay used before hiding the preview popup. The default
   139         * delay is three seconds.
   140         * @param aDelay Delay in microseconds.
   141         */
   142         IMPORT_C void SetPopUpHideDelay( const TTimeIntervalMicroSeconds32& aDelay );
   143         
   144         /**
   145         * Sets the preview popup visible after specified delay. If the popup
   146         * is already visible it is hidden immediately and shown again after the
   147         * showing delay. Popup is automatically hidden after its hiding delay
   148         * unless the delay is zero in which case the popup is shown infinitely.
   149         */
   150         IMPORT_C void ShowPopUp();
   151         
   152         /**
   153         * Hides the popup immediately.
   154         */
   155         IMPORT_C void HidePopUp();
   156         
   157         /**
   158         * If application wishes to build preview popup's content asynchronously
   159         * the content class should be derived from MAknPreviewPopUpContentProvider
   160         * in addition to CCoeControl. This function must be called by the content
   161         * object when it has finished its asynchronous building operation.
   162         */
   163         IMPORT_C void ContentReady();
   164         
   165         /**
   166         * Sets the position of preview popup. Popup's size is determined by the
   167         * size of its content. The popup is placed left and down from the given 
   168         * point. If fixed mode is used then this function has no effect.
   169         * @param aPoint Popup's position.
   170         */
   171         IMPORT_C void SetPosition( const TPoint& aPoint );
   172 
   173         /**
   174         * Sets the position of the preview popup so that it is aligned with the
   175         * given rectangle as specified in the LAF data. This is intented to be
   176         * used in conjunction with lists and grids if the application wishes to
   177         * implement a popup that follows lists/grids item highlight.
   178         * @param aHighlightRect Screen-relative rectangle used to calculate 
   179         * popup's position.
   180         */
   181         IMPORT_C void SetPositionByHighlight( const TRect& aHighlightRect );
   182 
   183         /**
   184         * Adds the observer to the list of observers. Observers in the list are
   185         * notified of events in preview popup.
   186         * @param aObserver Observer.
   187         */
   188         IMPORT_C void AddObserverL( const MAknPreviewPopUpObserver& aObserver );
   189         
   190         /**
   191         * Removes the given observer from the observer list.
   192         * @param aObserver Observer.
   193         */
   194         IMPORT_C void RemoveObserver( const MAknPreviewPopUpObserver& aObserver );
   195         
   196         /**
   197         * Updates popup's size to reflect a change in content's size.
   198         * Should be called if the size of the content is changed dynamically.
   199         */
   200         IMPORT_C void UpdateContentSize();
   201         
   202         /**
   203         * Returns the popup's size.
   204         */
   205         IMPORT_C TSize Size() const;
   206         
   207         /**
   208         * Sets optional heading text. If heading text is already set the
   209         * current text is replaced. When set also a closing icon is shown if 
   210         * the currently active layout supports stylus.
   211         * @param aText Heading text.
   212         */
   213         IMPORT_C void SetHeadingTextL( const TDesC& aText );
   214         
   215         /**
   216         * Notifies observers about the specified preview popup event.
   217         * @param aEvent Preview popup event.
   218         */
   219         void NotifyObservers( MAknPreviewPopUpObserver::TPreviewPopUpEvent aEvent );
   220       
   221       	/**
   222       	 * Resets the popup timeout.
   223       	 */
   224       	IMPORT_C void ResetTimer();
   225       	
   226     protected: // Functions from base classes
   227 	
   228 	    /**
   229 	    * From CTimer. Cancels an outstanding asynchronous request.
   230 	    */
   231         void DoCancel();
   232         
   233         /**
   234         * From CActive. Handles active object's request completion event.
   235         */
   236         void RunL();
   237         
   238         /**
   239         * From CActive. Handles leaves that occur while RunL is executed.
   240         * @param aError Leave code.
   241         * @return Always KErrNone.
   242         */
   243         TInt RunError( TInt aError );
   244 
   245     private: // Constructors
   246 
   247         /**
   248         * C++ default constructor.
   249         * @param aContentProvider Pointer to the content provider of the popup.
   250         */   
   251         CAknPreviewPopUpController( 
   252             MAknPreviewPopUpContentProvider* aContentProvider );
   253 
   254       	/**
   255       	* Symbian 2nd phase constructor.
   256       	* @param aContent Reference to the content of the preview popup.
   257       	* @param aStyle Defines the layout and style of the preview popup.
   258       	*/
   259         void ConstructL( CCoeControl& aContent, 
   260                          const TInt aStyle );
   261 
   262     private: // Data
   263   	
   264   	    enum TPreviewState
   265   	        {
   266   	        EShowing,
   267   	        EHiding,
   268   	        EBuildingContent
   269   	        };
   270   	        
   271         // state of preview popup controller
   272         TPreviewState iState;
   273         
   274   	    // interface for asynchronous content building
   275         MAknPreviewPopUpContentProvider* iContentProvider; // Not owned
   276         
   277         // pointer to preview popup.
   278         CAknPreviewPopUp* iPopUp;
   279         
   280         // delay used before showing the preview popup
   281         TTimeIntervalMicroSeconds32 iPopUpShowDelay;
   282         
   283         // delay used before hiding the preview popup
   284         TTimeIntervalMicroSeconds32 iPopUpHideDelay;
   285         
   286         // array containing pointers to registered observers
   287         RPointerArray<MAknPreviewPopUpObserver> iObservers;
   288         
   289         // True if timer is being resetted and the DoCancel should not hide the popup
   290         TBool iResetting;
   291     };
   292 
   293 #endif // AKNPREVIEWPOPUPCONTROLLER_H
   294 
   295 //  End of File