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: Interface for controlling stylus specific popup menu.
|
williamr@2
|
15 |
*
|
williamr@2
|
16 |
*/
|
williamr@2
|
17 |
|
williamr@2
|
18 |
|
williamr@2
|
19 |
#ifndef CAKNSTYLUSPOPUPMENU_H
|
williamr@2
|
20 |
#define CAKNSTYLUSPOPUPMENU_H
|
williamr@2
|
21 |
|
williamr@2
|
22 |
|
williamr@2
|
23 |
#include <e32base.h>
|
williamr@2
|
24 |
#include <coecobs.h> // MCoeControlObserver
|
williamr@2
|
25 |
|
williamr@2
|
26 |
class CAknPreviewPopUpController;
|
williamr@2
|
27 |
class CAknStylusPopUpMenuContent;
|
williamr@2
|
28 |
class MEikMenuObserver;
|
williamr@2
|
29 |
class TResourceReader;
|
williamr@2
|
30 |
|
williamr@2
|
31 |
/**
|
williamr@2
|
32 |
* Stylus specific popup menu
|
williamr@2
|
33 |
*
|
williamr@2
|
34 |
* A floating popup menu which is meant for stylus usage only.
|
williamr@2
|
35 |
* The menu appears near to the tapping position. When an item is
|
williamr@2
|
36 |
* tapped the menu calls its observer's (iMenuObserver) ProcessCommandL.
|
williamr@2
|
37 |
* Typically the observer is application's AppUi. It is then the
|
williamr@2
|
38 |
* observer's responsibility to handle the command appropriately.
|
williamr@2
|
39 |
* The observer is informed with KErrCancel if the menu is closed without
|
williamr@2
|
40 |
* making a selection.
|
williamr@2
|
41 |
*
|
williamr@2
|
42 |
* @lib eikcoctl.lib
|
williamr@2
|
43 |
* @since S60 v5.0
|
williamr@2
|
44 |
*/
|
williamr@2
|
45 |
NONSHARABLE_CLASS( CAknStylusPopUpMenu ) : public CBase,
|
williamr@2
|
46 |
public MCoeControlObserver
|
williamr@2
|
47 |
{
|
williamr@2
|
48 |
public:
|
williamr@2
|
49 |
enum TPositionType
|
williamr@2
|
50 |
{
|
williamr@2
|
51 |
EPositionTypeRightTop = 0,
|
williamr@2
|
52 |
EPositionTypeLeftTop,
|
williamr@2
|
53 |
EPositionTypeRightBottom,
|
williamr@2
|
54 |
EPositionTypeLeftBottom
|
williamr@2
|
55 |
};
|
williamr@2
|
56 |
/**
|
williamr@2
|
57 |
* Two-phased constructor
|
williamr@2
|
58 |
*
|
williamr@2
|
59 |
* @param aObserver Menu observer (not owned) that handles
|
williamr@2
|
60 |
* stylus popup events.
|
williamr@2
|
61 |
* @param aPoint The position where stylus was tapped
|
williamr@2
|
62 |
* @param aPopup Preview popup from which stylus popup
|
williamr@2
|
63 |
* menu was launched, can be NULL.
|
williamr@2
|
64 |
*/
|
williamr@2
|
65 |
IMPORT_C static CAknStylusPopUpMenu* NewL( MEikMenuObserver* aObserver,
|
williamr@2
|
66 |
const TPoint& aPoint,
|
williamr@2
|
67 |
CAknPreviewPopUpController* aPopup );
|
williamr@2
|
68 |
|
williamr@2
|
69 |
/**
|
williamr@2
|
70 |
* Two-phased constructor
|
williamr@2
|
71 |
*
|
williamr@2
|
72 |
* @param aObserver Menu observer (not owned) that handles
|
williamr@2
|
73 |
* stylus popup events.
|
williamr@2
|
74 |
* @param aPoint The position where stylus was tapped
|
williamr@2
|
75 |
*/
|
williamr@2
|
76 |
IMPORT_C static CAknStylusPopUpMenu* NewL( MEikMenuObserver* aObserver,
|
williamr@2
|
77 |
const TPoint& aPoint );
|
williamr@2
|
78 |
|
williamr@2
|
79 |
/**
|
williamr@2
|
80 |
* Two-phased constructor
|
williamr@2
|
81 |
*
|
williamr@2
|
82 |
* @param aObserver Menu observer (not owned) that handles
|
williamr@2
|
83 |
* stylus popup events.
|
williamr@2
|
84 |
* @param aPoint The position where stylus was tapped
|
williamr@2
|
85 |
* @param aPopup Preview popup from which stylus popup
|
williamr@2
|
86 |
* menu was launched, can be NULL.
|
williamr@2
|
87 |
*/
|
williamr@2
|
88 |
IMPORT_C static CAknStylusPopUpMenu* NewLC( MEikMenuObserver* aObserver,
|
williamr@2
|
89 |
const TPoint& aPoint,
|
williamr@2
|
90 |
CAknPreviewPopUpController* aPopup );
|
williamr@2
|
91 |
/**
|
williamr@2
|
92 |
* Destructor
|
williamr@2
|
93 |
*/
|
williamr@2
|
94 |
~CAknStylusPopUpMenu();
|
williamr@2
|
95 |
|
williamr@2
|
96 |
/**
|
williamr@2
|
97 |
* Adds a menu item. If the menu contains maximum amount of
|
williamr@2
|
98 |
* items, the function will do nothing. Inserted item will be
|
williamr@2
|
99 |
* placed last.
|
williamr@2
|
100 |
*
|
williamr@2
|
101 |
* @param aItem The menu item to be added.
|
williamr@2
|
102 |
* @param aCommandId Item's command id.
|
williamr@2
|
103 |
*/
|
williamr@2
|
104 |
IMPORT_C void AddMenuItemL( const TDesC& aItem, const TInt aCommandId );
|
williamr@2
|
105 |
|
williamr@2
|
106 |
/**
|
williamr@2
|
107 |
* Removes a menu item.
|
williamr@2
|
108 |
*
|
williamr@2
|
109 |
* @param aCommandId Command id of the item to be removed.
|
williamr@2
|
110 |
*/
|
williamr@2
|
111 |
IMPORT_C void RemoveMenuItem( const TInt aCommandId );
|
williamr@2
|
112 |
|
williamr@2
|
113 |
/**
|
williamr@2
|
114 |
* Hides / shows a menu item.
|
williamr@2
|
115 |
*
|
williamr@2
|
116 |
* @param aCommandId Command id of the item to be hidden / shown.
|
williamr@2
|
117 |
* @param aDimmed ETrue to hide item and EFalse to show item
|
williamr@2
|
118 |
*/
|
williamr@2
|
119 |
IMPORT_C void SetItemDimmed( const TInt aCommandId, const TBool aDimmed );
|
williamr@2
|
120 |
|
williamr@2
|
121 |
/**
|
williamr@2
|
122 |
* Shows the stylus popup menu. If it's already visible,
|
williamr@2
|
123 |
* nothing happens.
|
williamr@2
|
124 |
*/
|
williamr@2
|
125 |
IMPORT_C void ShowMenu();
|
williamr@2
|
126 |
|
williamr@2
|
127 |
/**
|
williamr@2
|
128 |
* Sets the position of the stylus popup menu.
|
williamr@2
|
129 |
* Position will be adjusted if the menu doesn't fit on the screen
|
williamr@2
|
130 |
* properly.
|
williamr@2
|
131 |
*
|
williamr@2
|
132 |
* @param aPoint Position of the left-top corner of the stylus popup menu.
|
williamr@2
|
133 |
*/
|
williamr@2
|
134 |
IMPORT_C void SetPosition( const TPoint& aPoint );
|
williamr@2
|
135 |
/**
|
williamr@2
|
136 |
* Sets the position of the stylus popup menu.
|
williamr@2
|
137 |
* Position will be adjusted if the menu doesn't fit on the screen
|
williamr@2
|
138 |
* properly.
|
williamr@2
|
139 |
*
|
williamr@2
|
140 |
* @param aPoint Position of the stylus popup menu.
|
williamr@2
|
141 |
* @param aPosType Position type e.g. left-top corner or right-top corner
|
williamr@2
|
142 |
*/
|
williamr@2
|
143 |
IMPORT_C void SetPosition( const TPoint& aPoint, TPositionType aPosType );
|
williamr@2
|
144 |
|
williamr@2
|
145 |
/**
|
williamr@2
|
146 |
* Tells the popup menu to recalculate its position. This can be used e.g.
|
williamr@2
|
147 |
* after layout transition.
|
williamr@2
|
148 |
*/
|
williamr@2
|
149 |
void UpdatePosition();
|
williamr@2
|
150 |
// from base class CCoeControl
|
williamr@2
|
151 |
|
williamr@2
|
152 |
/**
|
williamr@2
|
153 |
* Constructs the menu from resource.
|
williamr@2
|
154 |
*
|
williamr@2
|
155 |
* @param aReader Resource reader.
|
williamr@2
|
156 |
*/
|
williamr@2
|
157 |
IMPORT_C void ConstructFromResourceL( TResourceReader& aReader );
|
williamr@2
|
158 |
|
williamr@2
|
159 |
// from base class MCoeControlObserver
|
williamr@2
|
160 |
|
williamr@2
|
161 |
/**
|
williamr@2
|
162 |
* Method to handle events that occur when user selects a menu item.
|
williamr@2
|
163 |
*
|
williamr@2
|
164 |
* @param aControl The control that sent the event.
|
williamr@2
|
165 |
* @param aEventType The event type.
|
williamr@2
|
166 |
*/
|
williamr@2
|
167 |
IMPORT_C void HandleControlEventL( CCoeControl* aControl,
|
williamr@2
|
168 |
TCoeEvent aEventType );
|
williamr@2
|
169 |
|
williamr@2
|
170 |
public:
|
williamr@2
|
171 |
|
williamr@2
|
172 |
/**
|
williamr@2
|
173 |
* Resets timer that hides popup.
|
williamr@2
|
174 |
*/
|
williamr@2
|
175 |
void ResetTimer();
|
williamr@2
|
176 |
|
williamr@2
|
177 |
private:
|
williamr@2
|
178 |
|
williamr@2
|
179 |
/**
|
williamr@2
|
180 |
* Default constructor
|
williamr@2
|
181 |
*
|
williamr@2
|
182 |
* @param aObserver Menu observer (not owned) that handles
|
williamr@2
|
183 |
* stylus popup events.
|
williamr@2
|
184 |
* @param aPoint The position where stylus was tapped
|
williamr@2
|
185 |
* @param aPopup Preview popup from which stylus popup
|
williamr@2
|
186 |
* menu was launched, can be NULL.
|
williamr@2
|
187 |
*/
|
williamr@2
|
188 |
CAknStylusPopUpMenu( MEikMenuObserver* aObserver, const TPoint& aPoint,
|
williamr@2
|
189 |
CAknPreviewPopUpController* aPopup );
|
williamr@2
|
190 |
|
williamr@2
|
191 |
/**
|
williamr@2
|
192 |
* 2nd phase constructor
|
williamr@2
|
193 |
*/
|
williamr@2
|
194 |
void ConstructL();
|
williamr@2
|
195 |
|
williamr@2
|
196 |
private: // data
|
williamr@2
|
197 |
|
williamr@2
|
198 |
/**
|
williamr@2
|
199 |
* Screen relative position where stylus was tapped.
|
williamr@2
|
200 |
*/
|
williamr@2
|
201 |
TPoint iPosition;
|
williamr@2
|
202 |
|
williamr@2
|
203 |
/**
|
williamr@2
|
204 |
* Controller for the actual popup.
|
williamr@2
|
205 |
* Own.
|
williamr@2
|
206 |
*/
|
williamr@2
|
207 |
CAknPreviewPopUpController* iController;
|
williamr@2
|
208 |
|
williamr@2
|
209 |
/**
|
williamr@2
|
210 |
* Popup's content.
|
williamr@2
|
211 |
* Own.
|
williamr@2
|
212 |
*/
|
williamr@2
|
213 |
CAknStylusPopUpMenuContent* iContent;
|
williamr@2
|
214 |
|
williamr@2
|
215 |
/**
|
williamr@2
|
216 |
* Observer which will be used to forward selected menu command id.
|
williamr@2
|
217 |
* Not own.
|
williamr@2
|
218 |
*/
|
williamr@2
|
219 |
MEikMenuObserver* iMenuObserver;
|
williamr@2
|
220 |
|
williamr@2
|
221 |
/**
|
williamr@2
|
222 |
* Preview popup which launches stylus popup menu.
|
williamr@2
|
223 |
* If NULL, menu wasn't launched from a preview popup.
|
williamr@2
|
224 |
* If not NULL, stylus popup menu will close also the preview popup
|
williamr@2
|
225 |
* when an option is selected in the stylus popup menu.
|
williamr@2
|
226 |
* Not own.
|
williamr@2
|
227 |
*/
|
williamr@2
|
228 |
CAknPreviewPopUpController* iPreviewPopup;
|
williamr@2
|
229 |
|
williamr@2
|
230 |
};
|
williamr@2
|
231 |
|
williamr@2
|
232 |
|
williamr@2
|
233 |
#endif // CAKNSTYLUSPOPUPMENU_H
|