2 * Copyright (c) 2005-2009 Nokia Corporation and/or its subsidiary(-ies).
4 * This component and the accompanying materials are made available
5 * 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
6 * which accompanies this distribution, and is available
7 * at the URL "http://www.symbianfoundation.org/legal/licencesv10.html".
9 * Initial Contributors:
10 * Nokia Corporation - initial contribution.
14 * Description: Preview popup controller.
19 #ifndef AKNPREVIEWPOPUPCONTROLLER_H
20 #define AKNPREVIEWPOPUPCONTROLLER_H
26 #include <aknpreviewpopupobserver.h>
28 // FORWARD DECLARATIONS
29 class MAknPreviewPopUpContentProvider;
30 class CAknPreviewPopUp;
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
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.
53 NONSHARABLE_CLASS( CAknPreviewPopUpController ) : public CTimer
55 public: // Type definitions
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
67 enum TAknPreviewPopUpContentSize
73 public: // Constructors and destructor
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.
81 IMPORT_C static CAknPreviewPopUpController* NewL( CCoeControl& aContent,
82 MAknPreviewPopUpContentProvider& aContentProvider );
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.
90 IMPORT_C static CAknPreviewPopUpController* NewL( CCoeControl& aContent );
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.
99 IMPORT_C static CAknPreviewPopUpController* NewL( CCoeControl& aContent,
100 MAknPreviewPopUpContentProvider& aContentProvider,
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.
110 IMPORT_C static CAknPreviewPopUpController* NewL( CCoeControl& aContent,
116 ~CAknPreviewPopUpController();
118 public: // New functions
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.
128 IMPORT_C static TAknPreviewPopUpContentSize ContentSizeInLayout();
131 * Sets the delay used before showing the preview popup. The default
132 * delay is one second.
133 * @param aDelay Delay in microseconds.
135 IMPORT_C void SetPopUpShowDelay( const TTimeIntervalMicroSeconds32& aDelay );
138 * Sets the delay used before hiding the preview popup. The default
139 * delay is three seconds.
140 * @param aDelay Delay in microseconds.
142 IMPORT_C void SetPopUpHideDelay( const TTimeIntervalMicroSeconds32& aDelay );
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.
150 IMPORT_C void ShowPopUp();
153 * Hides the popup immediately.
155 IMPORT_C void HidePopUp();
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.
163 IMPORT_C void ContentReady();
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.
171 IMPORT_C void SetPosition( const TPoint& aPoint );
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
181 IMPORT_C void SetPositionByHighlight( const TRect& aHighlightRect );
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.
188 IMPORT_C void AddObserverL( const MAknPreviewPopUpObserver& aObserver );
191 * Removes the given observer from the observer list.
192 * @param aObserver Observer.
194 IMPORT_C void RemoveObserver( const MAknPreviewPopUpObserver& aObserver );
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.
200 IMPORT_C void UpdateContentSize();
203 * Returns the popup's size.
205 IMPORT_C TSize Size() const;
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.
213 IMPORT_C void SetHeadingTextL( const TDesC& aText );
216 * Notifies observers about the specified preview popup event.
217 * @param aEvent Preview popup event.
219 void NotifyObservers( MAknPreviewPopUpObserver::TPreviewPopUpEvent aEvent );
222 * Resets the popup timeout.
224 IMPORT_C void ResetTimer();
226 protected: // Functions from base classes
229 * From CTimer. Cancels an outstanding asynchronous request.
234 * From CActive. Handles active object's request completion event.
239 * From CActive. Handles leaves that occur while RunL is executed.
240 * @param aError Leave code.
241 * @return Always KErrNone.
243 TInt RunError( TInt aError );
245 private: // Constructors
248 * C++ default constructor.
249 * @param aContentProvider Pointer to the content provider of the popup.
251 CAknPreviewPopUpController(
252 MAknPreviewPopUpContentProvider* aContentProvider );
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.
259 void ConstructL( CCoeControl& aContent,
271 // state of preview popup controller
272 TPreviewState iState;
274 // interface for asynchronous content building
275 MAknPreviewPopUpContentProvider* iContentProvider; // Not owned
277 // pointer to preview popup.
278 CAknPreviewPopUp* iPopUp;
280 // delay used before showing the preview popup
281 TTimeIntervalMicroSeconds32 iPopUpShowDelay;
283 // delay used before hiding the preview popup
284 TTimeIntervalMicroSeconds32 iPopUpHideDelay;
286 // array containing pointers to registered observers
287 RPointerArray<MAknPreviewPopUpObserver> iObservers;
289 // True if timer is being resetted and the DoCancel should not hide the popup
293 #endif // AKNPREVIEWPOPUPCONTROLLER_H