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