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