56
|
1 |
/*
|
|
2 |
* Copyright (c) 2005-2010 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: Interface for controlling stylus specific popup menu.
|
|
15 |
*
|
|
16 |
*/
|
|
17 |
|
|
18 |
|
|
19 |
#ifndef CAKNSTYLUSPOPUPMENU_H
|
|
20 |
#define CAKNSTYLUSPOPUPMENU_H
|
|
21 |
|
|
22 |
|
|
23 |
#include <e32base.h>
|
|
24 |
#include <coecobs.h> // MCoeControlObserver
|
|
25 |
#include <babitflags.h>
|
|
26 |
|
|
27 |
class CAknPreviewPopUpController;
|
|
28 |
class CAknStylusPopUpMenuContent;
|
|
29 |
class MEikMenuObserver;
|
|
30 |
class TResourceReader;
|
|
31 |
|
|
32 |
/**
|
|
33 |
* Stylus specific popup menu
|
|
34 |
*
|
|
35 |
* A floating popup menu which is meant for stylus usage only.
|
|
36 |
* The menu appears near to the tapping position. When an item is
|
|
37 |
* tapped the menu calls its observer's (iMenuObserver) ProcessCommandL.
|
|
38 |
* Typically the observer is application's AppUi. It is then the
|
|
39 |
* observer's responsibility to handle the command appropriately.
|
|
40 |
* The observer is informed with KErrCancel if the menu is closed without
|
|
41 |
* making a selection.
|
|
42 |
*
|
|
43 |
* @lib eikcoctl.lib
|
|
44 |
* @since S60 v5.0
|
|
45 |
*/
|
|
46 |
NONSHARABLE_CLASS( CAknStylusPopUpMenu ) : public CBase,
|
|
47 |
public MCoeControlObserver
|
|
48 |
{
|
|
49 |
public:
|
|
50 |
enum TPositionType
|
|
51 |
{
|
|
52 |
EPositionTypeRightTop = 0,
|
|
53 |
EPositionTypeLeftTop,
|
|
54 |
EPositionTypeRightBottom,
|
|
55 |
EPositionTypeLeftBottom
|
|
56 |
};
|
|
57 |
|
|
58 |
enum TStylusPopupMode
|
|
59 |
{
|
|
60 |
EConsumeKeyEvents = 0x01 // Consumes key events
|
|
61 |
};
|
|
62 |
|
|
63 |
/**
|
|
64 |
* Two-phased constructor
|
|
65 |
*
|
|
66 |
* @param aObserver Menu observer (not owned) that handles
|
|
67 |
* stylus popup events.
|
|
68 |
* @param aPoint The position where stylus was tapped
|
|
69 |
* @param aPopup Preview popup from which stylus popup
|
|
70 |
* menu was launched, can be NULL.
|
|
71 |
*/
|
|
72 |
IMPORT_C static CAknStylusPopUpMenu* NewL( MEikMenuObserver* aObserver,
|
|
73 |
const TPoint& aPoint,
|
|
74 |
CAknPreviewPopUpController* aPopup );
|
|
75 |
|
|
76 |
/**
|
|
77 |
* Two-phased constructor
|
|
78 |
*
|
|
79 |
* @param aObserver Menu observer (not owned) that handles
|
|
80 |
* stylus popup events.
|
|
81 |
* @param aPoint The position where stylus was tapped
|
|
82 |
* @param aPopup Preview popup from which stylus popup
|
|
83 |
* menu was launched, can be NULL.
|
|
84 |
* @param aFlags Optional parameters
|
|
85 |
*/
|
|
86 |
|
|
87 |
static CAknStylusPopUpMenu* NewL( MEikMenuObserver* aObserver,
|
|
88 |
const TPoint& aPoint,
|
|
89 |
CAknPreviewPopUpController* aPopup,
|
|
90 |
const TInt aFlags );
|
|
91 |
|
|
92 |
/**
|
|
93 |
* Two-phased constructor
|
|
94 |
*
|
|
95 |
* @param aObserver Menu observer (not owned) that handles
|
|
96 |
* stylus popup events.
|
|
97 |
* @param aPoint The position where stylus was tapped
|
|
98 |
*/
|
|
99 |
IMPORT_C static CAknStylusPopUpMenu* NewL( MEikMenuObserver* aObserver,
|
|
100 |
const TPoint& aPoint );
|
|
101 |
|
|
102 |
/**
|
|
103 |
* Two-phased constructor
|
|
104 |
*
|
|
105 |
* @param aObserver Menu observer (not owned) that handles
|
|
106 |
* stylus popup events.
|
|
107 |
* @param aPoint The position where stylus was tapped
|
|
108 |
* @param aPopup Preview popup from which stylus popup
|
|
109 |
* menu was launched, can be NULL.
|
|
110 |
*/
|
|
111 |
IMPORT_C static CAknStylusPopUpMenu* NewLC( MEikMenuObserver* aObserver,
|
|
112 |
const TPoint& aPoint,
|
|
113 |
CAknPreviewPopUpController* aPopup );
|
|
114 |
/**
|
|
115 |
* Destructor
|
|
116 |
*/
|
|
117 |
~CAknStylusPopUpMenu();
|
|
118 |
|
|
119 |
/**
|
|
120 |
* Adds a menu item. If the menu contains maximum amount of
|
|
121 |
* items, the function will do nothing. Inserted item will be
|
|
122 |
* placed last.
|
|
123 |
*
|
|
124 |
* @param aItem The menu item to be added.
|
|
125 |
* @param aCommandId Item's command id.
|
|
126 |
*/
|
|
127 |
IMPORT_C void AddMenuItemL( const TDesC& aItem, const TInt aCommandId );
|
|
128 |
|
|
129 |
/**
|
|
130 |
* Removes a menu item.
|
|
131 |
*
|
|
132 |
* @param aCommandId Command id of the item to be removed.
|
|
133 |
*/
|
|
134 |
IMPORT_C void RemoveMenuItem( const TInt aCommandId );
|
|
135 |
|
|
136 |
/**
|
|
137 |
* Hides / shows a menu item.
|
|
138 |
*
|
|
139 |
* @param aCommandId Command id of the item to be hidden / shown.
|
|
140 |
* @param aDimmed ETrue to hide item and EFalse to show item
|
|
141 |
*/
|
|
142 |
IMPORT_C void SetItemDimmed( const TInt aCommandId, const TBool aDimmed );
|
|
143 |
|
|
144 |
/**
|
|
145 |
* Shows the stylus popup menu. If it's already visible,
|
|
146 |
* nothing happens.
|
|
147 |
*/
|
|
148 |
IMPORT_C void ShowMenu();
|
|
149 |
|
|
150 |
/**
|
|
151 |
* Sets the position of the stylus popup menu.
|
|
152 |
* Position will be adjusted if the menu doesn't fit on the screen
|
|
153 |
* properly.
|
|
154 |
*
|
|
155 |
* @param aPoint Position of the left-top corner of the stylus popup menu.
|
|
156 |
*/
|
|
157 |
IMPORT_C void SetPosition( const TPoint& aPoint );
|
|
158 |
/**
|
|
159 |
* Sets the position of the stylus popup menu.
|
|
160 |
* Position will be adjusted if the menu doesn't fit on the screen
|
|
161 |
* properly.
|
|
162 |
*
|
|
163 |
* @param aPoint Position of the stylus popup menu.
|
|
164 |
* @param aPosType Position type e.g. left-top corner or right-top corner
|
|
165 |
*/
|
|
166 |
IMPORT_C void SetPosition( const TPoint& aPoint, TPositionType aPosType );
|
|
167 |
|
|
168 |
/**
|
|
169 |
* Tells the popup menu to recalculate its position. This can be used e.g.
|
|
170 |
* after layout transition.
|
|
171 |
*/
|
|
172 |
void UpdatePosition();
|
|
173 |
|
|
174 |
/**
|
|
175 |
* Removes all menu items.
|
|
176 |
*
|
|
177 |
* @internal
|
|
178 |
* @since s60 v5.2
|
|
179 |
*/
|
|
180 |
void Clear();
|
|
181 |
|
|
182 |
/**
|
|
183 |
* Hides the stylus popup menu.
|
|
184 |
*
|
|
185 |
* @internal
|
|
186 |
* @since S60 v5.2
|
|
187 |
*/
|
|
188 |
void HideMenu();
|
|
189 |
|
|
190 |
// from base class CCoeControl
|
|
191 |
|
|
192 |
/**
|
|
193 |
* Constructs the menu from resource.
|
|
194 |
*
|
|
195 |
* @param aReader Resource reader.
|
|
196 |
*/
|
|
197 |
IMPORT_C void ConstructFromResourceL( TResourceReader& aReader );
|
|
198 |
|
|
199 |
// from base class MCoeControlObserver
|
|
200 |
|
|
201 |
/**
|
|
202 |
* Method to handle events that occur when user selects a menu item.
|
|
203 |
*
|
|
204 |
* @param aControl The control that sent the event.
|
|
205 |
* @param aEventType The event type.
|
|
206 |
*/
|
|
207 |
IMPORT_C void HandleControlEventL( CCoeControl* aControl,
|
|
208 |
TCoeEvent aEventType );
|
|
209 |
|
|
210 |
|
|
211 |
private:
|
|
212 |
|
|
213 |
/**
|
|
214 |
* Default constructor
|
|
215 |
*
|
|
216 |
* @param aObserver Menu observer (not owned) that handles
|
|
217 |
* stylus popup events.
|
|
218 |
* @param aPoint The position where stylus was tapped
|
|
219 |
* @param aPopup Preview popup from which stylus popup
|
|
220 |
* menu was launched, can be NULL.
|
|
221 |
* @param aFlags Optional parameters
|
|
222 |
*/
|
|
223 |
CAknStylusPopUpMenu( MEikMenuObserver* aObserver, const TPoint& aPoint,
|
|
224 |
CAknPreviewPopUpController* aPopup,
|
|
225 |
const TInt aFlags = 0 );
|
|
226 |
|
|
227 |
/**
|
|
228 |
* 2nd phase constructor
|
|
229 |
*/
|
|
230 |
void ConstructL();
|
|
231 |
|
|
232 |
/**
|
|
233 |
* Starts the CIdle
|
|
234 |
*/
|
|
235 |
void StartControllerIdleL();
|
|
236 |
|
|
237 |
/**
|
|
238 |
* CIdle callback function
|
|
239 |
*/
|
|
240 |
static TInt ControllerCallBack( TAny* aThis );
|
|
241 |
|
|
242 |
/**
|
|
243 |
* Removes the controller
|
|
244 |
*/
|
|
245 |
void RemoveController();
|
|
246 |
|
|
247 |
/**
|
|
248 |
* Cleans the internal pointer which is used
|
|
249 |
* to track object deletion.
|
|
250 |
*
|
|
251 |
* @param aParam Pointer to stylus menu object.
|
|
252 |
*/
|
|
253 |
static void CleanLocalRef( TAny* aParam );
|
|
254 |
|
|
255 |
private: // data
|
|
256 |
|
|
257 |
/**
|
|
258 |
* Screen relative position where stylus was tapped.
|
|
259 |
*/
|
|
260 |
TPoint iPosition;
|
|
261 |
|
|
262 |
/**
|
|
263 |
* Controller for the actual popup.
|
|
264 |
* Own.
|
|
265 |
*/
|
|
266 |
CAknPreviewPopUpController* iController;
|
|
267 |
|
|
268 |
/**
|
|
269 |
* Popup's content.
|
|
270 |
* Own.
|
|
271 |
*/
|
|
272 |
CAknStylusPopUpMenuContent* iContent;
|
|
273 |
|
|
274 |
/**
|
|
275 |
* Observer which will be used to forward selected menu command id.
|
|
276 |
* Not own.
|
|
277 |
*/
|
|
278 |
MEikMenuObserver* iMenuObserver;
|
|
279 |
|
|
280 |
/**
|
|
281 |
* Preview popup which launches stylus popup menu.
|
|
282 |
* If NULL, menu wasn't launched from a preview popup.
|
|
283 |
* If not NULL, stylus popup menu will close also the preview popup
|
|
284 |
* when an option is selected in the stylus popup menu.
|
|
285 |
* Not own.
|
|
286 |
*/
|
|
287 |
CAknPreviewPopUpController* iPreviewPopup;
|
|
288 |
|
|
289 |
/**
|
|
290 |
* An idle time active object
|
|
291 |
* Own
|
|
292 |
*/
|
|
293 |
CIdle* iControllerIdle;
|
|
294 |
|
|
295 |
/**
|
|
296 |
* Position type
|
|
297 |
*/
|
|
298 |
TInt iPositionType;
|
|
299 |
|
|
300 |
/**
|
|
301 |
* Internal flags.
|
|
302 |
*/
|
|
303 |
TBitFlags iFlags;
|
|
304 |
|
|
305 |
/**
|
|
306 |
* Used to track if object has been deleted while calling client callback.
|
|
307 |
*/
|
|
308 |
TBool* iIsDeleted;
|
|
309 |
|
|
310 |
/**
|
|
311 |
* Mode flags.
|
|
312 |
*/
|
|
313 |
TInt iModeFlags;
|
|
314 |
};
|
|
315 |
|
|
316 |
|
|
317 |
#endif // CAKNSTYLUSPOPUPMENU_H
|