classicui_pub/information_preview_popup_api/inc/AknPreviewPopUpController.h
branchRCL_3
changeset 56 d48ab3b357f1
child 72 a5e7a4f63858
equal deleted inserted replaced
55:aecbbf00d063 56:d48ab3b357f1
       
     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             EConsumeKeys   = 0x0080  // popup consumes key events
       
    66     };
       
    67             
       
    68         enum TAknPreviewPopUpContentSize
       
    69             {
       
    70             ESmall,
       
    71             ELarge
       
    72             };
       
    73             
       
    74     public: // Constructors and destructor
       
    75 
       
    76         /**
       
    77         * Two-phased constructor. This version should be used if the content
       
    78         * is created asynchronously.
       
    79         * @param aContent Reference to the content of the preview popup.
       
    80         * @param aContentProvider Reference to the content provider of the popup.
       
    81         */
       
    82         IMPORT_C static CAknPreviewPopUpController* NewL( CCoeControl& aContent,
       
    83             MAknPreviewPopUpContentProvider& aContentProvider );
       
    84 
       
    85         /**
       
    86         * Two-phased constructor. This version should be used if the content is
       
    87         * created synchronously i.e. it's ready when the popup is about to be
       
    88         * shown. This is also the normal use case.
       
    89         * @param aContent Reference to the content of the preview popup.
       
    90         */
       
    91         IMPORT_C static CAknPreviewPopUpController* NewL( CCoeControl& aContent );
       
    92         
       
    93         /**
       
    94         * Two-phased constructor. This version should be used if the content
       
    95         * is created asynchronously.
       
    96         * @param aContent Reference to the content of the preview popup.
       
    97         * @param aContentProvider Reference to the content provider of the popup.
       
    98         * @param aStyle Defines the used layout and behavior flags.
       
    99         */
       
   100         IMPORT_C static CAknPreviewPopUpController* NewL( CCoeControl& aContent,
       
   101             MAknPreviewPopUpContentProvider& aContentProvider,
       
   102             const TInt aStyle );
       
   103 
       
   104         /**
       
   105         * Two-phased constructor. This version should be used if the content is
       
   106         * created synchronously i.e. it's ready when the popup is about to be
       
   107         * shown. This is also the normal use case.
       
   108         * @param aContent Reference to the content of the preview popup.
       
   109         * @param aStyle Defines the used layout and behavior flags.
       
   110         */
       
   111         IMPORT_C static CAknPreviewPopUpController* NewL( CCoeControl& aContent,
       
   112             const TInt aStyle );
       
   113             
       
   114   	    /**
       
   115         * Destructor.
       
   116         */
       
   117         ~CAknPreviewPopUpController();
       
   118 
       
   119     public: // New functions
       
   120         
       
   121         /**
       
   122         * This static function can be used to query the logical size of the
       
   123         * screen when drawing the content of the popup. When ELarge is returned
       
   124         * more detailed information (e.g. a picture) can be shown whereas ESmall
       
   125         * suggests that the available screen area is more limited and simpler
       
   126         * content should be used.
       
   127         * @return Logical size of the screen.
       
   128         */
       
   129         IMPORT_C static TAknPreviewPopUpContentSize ContentSizeInLayout();
       
   130 
       
   131         /**
       
   132         * Sets the delay used before showing the preview popup. The default 
       
   133         * delay is one second.
       
   134         * @param aDelay Delay in microseconds.
       
   135         */
       
   136         IMPORT_C void SetPopUpShowDelay( const TTimeIntervalMicroSeconds32& aDelay );
       
   137         
       
   138         /**
       
   139         * Sets the delay used before hiding the preview popup. The default
       
   140         * delay is three seconds.
       
   141         * @param aDelay Delay in microseconds.
       
   142         */
       
   143         IMPORT_C void SetPopUpHideDelay( const TTimeIntervalMicroSeconds32& aDelay );
       
   144         
       
   145         /**
       
   146         * Sets the preview popup visible after specified delay. If the popup
       
   147         * is already visible it is hidden immediately and shown again after the
       
   148         * showing delay. Popup is automatically hidden after its hiding delay
       
   149         * unless the delay is zero in which case the popup is shown infinitely.
       
   150         */
       
   151         IMPORT_C void ShowPopUp();
       
   152         
       
   153         /**
       
   154         * Hides the popup immediately.
       
   155         */
       
   156         IMPORT_C void HidePopUp();
       
   157         
       
   158         /**
       
   159         * If application wishes to build preview popup's content asynchronously
       
   160         * the content class should be derived from MAknPreviewPopUpContentProvider
       
   161         * in addition to CCoeControl. This function must be called by the content
       
   162         * object when it has finished its asynchronous building operation.
       
   163         */
       
   164         IMPORT_C void ContentReady();
       
   165         
       
   166         /**
       
   167         * Sets the position of preview popup. Popup's size is determined by the
       
   168         * size of its content. The popup is placed left and down from the given 
       
   169         * point. If fixed mode is used then this function has no effect.
       
   170         * @param aPoint Popup's position.
       
   171         */
       
   172         IMPORT_C void SetPosition( const TPoint& aPoint );
       
   173 
       
   174         /**
       
   175         * Sets the position of the preview popup so that it is aligned with the
       
   176         * given rectangle as specified in the LAF data. This is intented to be
       
   177         * used in conjunction with lists and grids if the application wishes to
       
   178         * implement a popup that follows lists/grids item highlight.
       
   179         * @param aHighlightRect Screen-relative rectangle used to calculate 
       
   180         * popup's position.
       
   181         */
       
   182         IMPORT_C void SetPositionByHighlight( const TRect& aHighlightRect );
       
   183 
       
   184         /**
       
   185         * Adds the observer to the list of observers. Observers in the list are
       
   186         * notified of events in preview popup.
       
   187         * @param aObserver Observer.
       
   188         */
       
   189         IMPORT_C void AddObserverL( const MAknPreviewPopUpObserver& aObserver );
       
   190         
       
   191         /**
       
   192         * Removes the given observer from the observer list.
       
   193         * @param aObserver Observer.
       
   194         */
       
   195         IMPORT_C void RemoveObserver( const MAknPreviewPopUpObserver& aObserver );
       
   196         
       
   197         /**
       
   198         * Updates popup's size to reflect a change in content's size.
       
   199         * Should be called if the size of the content is changed dynamically.
       
   200         */
       
   201         IMPORT_C void UpdateContentSize();
       
   202         
       
   203         /**
       
   204         * Returns the popup's size.
       
   205         */
       
   206         IMPORT_C TSize Size() const;
       
   207         
       
   208         /**
       
   209         * Sets optional heading text. If heading text is already set the
       
   210         * current text is replaced. When set also a closing icon is shown if 
       
   211         * the currently active layout supports stylus.
       
   212         * @param aText Heading text.
       
   213         */
       
   214         IMPORT_C void SetHeadingTextL( const TDesC& aText );
       
   215         
       
   216         /**
       
   217         * Notifies observers about the specified preview popup event.
       
   218         * @param aEvent Preview popup event.
       
   219         */
       
   220         void NotifyObservers( MAknPreviewPopUpObserver::TPreviewPopUpEvent aEvent );
       
   221       
       
   222       	/**
       
   223       	 * Resets the popup timeout.
       
   224       	 */
       
   225       	IMPORT_C void ResetTimer();
       
   226       	
       
   227     protected: // Functions from base classes
       
   228 	
       
   229 	    /**
       
   230 	    * From CTimer. Cancels an outstanding asynchronous request.
       
   231 	    */
       
   232         void DoCancel();
       
   233         
       
   234         /**
       
   235         * From CActive. Handles active object's request completion event.
       
   236         */
       
   237         void RunL();
       
   238         
       
   239         /**
       
   240         * From CActive. Handles leaves that occur while RunL is executed.
       
   241         * @param aError Leave code.
       
   242         * @return Always KErrNone.
       
   243         */
       
   244         TInt RunError( TInt aError );
       
   245 
       
   246     private: // Constructors
       
   247 
       
   248         /**
       
   249         * C++ default constructor.
       
   250         * @param aContentProvider Pointer to the content provider of the popup.
       
   251         */   
       
   252         CAknPreviewPopUpController( 
       
   253             MAknPreviewPopUpContentProvider* aContentProvider );
       
   254 
       
   255       	/**
       
   256       	* Symbian 2nd phase constructor.
       
   257       	* @param aContent Reference to the content of the preview popup.
       
   258       	* @param aStyle Defines the layout and style of the preview popup.
       
   259       	*/
       
   260         void ConstructL( CCoeControl& aContent, 
       
   261                          const TInt aStyle );
       
   262 
       
   263     private: // Data
       
   264   	
       
   265   	    enum TPreviewState
       
   266   	        {
       
   267   	        EShowing,
       
   268   	        EHiding,
       
   269   	        EBuildingContent
       
   270   	        };
       
   271   	        
       
   272         // state of preview popup controller
       
   273         TPreviewState iState;
       
   274         
       
   275   	    // interface for asynchronous content building
       
   276         MAknPreviewPopUpContentProvider* iContentProvider; // Not owned
       
   277         
       
   278         // pointer to preview popup.
       
   279         CAknPreviewPopUp* iPopUp;
       
   280         
       
   281         // delay used before showing the preview popup
       
   282         TTimeIntervalMicroSeconds32 iPopUpShowDelay;
       
   283         
       
   284         // delay used before hiding the preview popup
       
   285         TTimeIntervalMicroSeconds32 iPopUpHideDelay;
       
   286         
       
   287         // array containing pointers to registered observers
       
   288         RPointerArray<MAknPreviewPopUpObserver> iObservers;
       
   289         
       
   290         // True if timer is being resetted and the DoCancel should not hide the popup
       
   291         TBool iResetting;
       
   292     };
       
   293 
       
   294 #endif // AKNPREVIEWPOPUPCONTROLLER_H
       
   295 
       
   296 //  End of File