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 "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".
9 * Initial Contributors:
10 * Nokia Corporation - initial contribution.
14 * Description: Interface for controlling stylus specific popup menu.
19 #ifndef CAKNSTYLUSPOPUPMENU_H
20 #define CAKNSTYLUSPOPUPMENU_H
24 #include <coecobs.h> // MCoeControlObserver
25 #include <babitflags.h>
27 class CAknPreviewPopUpController;
28 class CAknStylusPopUpMenuContent;
29 class MEikMenuObserver;
30 class TResourceReader;
33 * Stylus specific popup menu
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
46 NONSHARABLE_CLASS( CAknStylusPopUpMenu ) : public CBase,
47 public MCoeControlObserver
52 EPositionTypeRightTop = 0,
54 EPositionTypeRightBottom,
55 EPositionTypeLeftBottom
58 * Two-phased constructor
60 * @param aObserver Menu observer (not owned) that handles
61 * stylus popup events.
62 * @param aPoint The position where stylus was tapped
63 * @param aPopup Preview popup from which stylus popup
64 * menu was launched, can be NULL.
66 IMPORT_C static CAknStylusPopUpMenu* NewL( MEikMenuObserver* aObserver,
68 CAknPreviewPopUpController* aPopup );
71 * Two-phased constructor
73 * @param aObserver Menu observer (not owned) that handles
74 * stylus popup events.
75 * @param aPoint The position where stylus was tapped
77 IMPORT_C static CAknStylusPopUpMenu* NewL( MEikMenuObserver* aObserver,
78 const TPoint& aPoint );
81 * Two-phased constructor
83 * @param aObserver Menu observer (not owned) that handles
84 * stylus popup events.
85 * @param aPoint The position where stylus was tapped
86 * @param aPopup Preview popup from which stylus popup
87 * menu was launched, can be NULL.
89 IMPORT_C static CAknStylusPopUpMenu* NewLC( MEikMenuObserver* aObserver,
91 CAknPreviewPopUpController* aPopup );
95 ~CAknStylusPopUpMenu();
98 * Adds a menu item. If the menu contains maximum amount of
99 * items, the function will do nothing. Inserted item will be
102 * @param aItem The menu item to be added.
103 * @param aCommandId Item's command id.
105 IMPORT_C void AddMenuItemL( const TDesC& aItem, const TInt aCommandId );
108 * Removes a menu item.
110 * @param aCommandId Command id of the item to be removed.
112 IMPORT_C void RemoveMenuItem( const TInt aCommandId );
115 * Hides / shows a menu item.
117 * @param aCommandId Command id of the item to be hidden / shown.
118 * @param aDimmed ETrue to hide item and EFalse to show item
120 IMPORT_C void SetItemDimmed( const TInt aCommandId, const TBool aDimmed );
123 * Shows the stylus popup menu. If it's already visible,
126 IMPORT_C void ShowMenu();
129 * Sets the position of the stylus popup menu.
130 * Position will be adjusted if the menu doesn't fit on the screen
133 * @param aPoint Position of the left-top corner of the stylus popup menu.
135 IMPORT_C void SetPosition( const TPoint& aPoint );
137 * Sets the position of the stylus popup menu.
138 * Position will be adjusted if the menu doesn't fit on the screen
141 * @param aPoint Position of the stylus popup menu.
142 * @param aPosType Position type e.g. left-top corner or right-top corner
144 IMPORT_C void SetPosition( const TPoint& aPoint, TPositionType aPosType );
147 * Tells the popup menu to recalculate its position. This can be used e.g.
148 * after layout transition.
150 void UpdatePosition();
153 * Removes all menu items.
160 // from base class CCoeControl
163 * Constructs the menu from resource.
165 * @param aReader Resource reader.
167 IMPORT_C void ConstructFromResourceL( TResourceReader& aReader );
169 // from base class MCoeControlObserver
172 * Method to handle events that occur when user selects a menu item.
174 * @param aControl The control that sent the event.
175 * @param aEventType The event type.
177 IMPORT_C void HandleControlEventL( CCoeControl* aControl,
178 TCoeEvent aEventType );
184 * Default constructor
186 * @param aObserver Menu observer (not owned) that handles
187 * stylus popup events.
188 * @param aPoint The position where stylus was tapped
189 * @param aPopup Preview popup from which stylus popup
190 * menu was launched, can be NULL.
192 CAknStylusPopUpMenu( MEikMenuObserver* aObserver, const TPoint& aPoint,
193 CAknPreviewPopUpController* aPopup );
196 * 2nd phase constructor
203 void StartControllerIdleL();
206 * CIdle callback function
208 static TInt ControllerCallBack( TAny* aThis );
211 * Removes the controller
213 void RemoveController();
218 * Screen relative position where stylus was tapped.
223 * Controller for the actual popup.
226 CAknPreviewPopUpController* iController;
232 CAknStylusPopUpMenuContent* iContent;
235 * Observer which will be used to forward selected menu command id.
238 MEikMenuObserver* iMenuObserver;
241 * Preview popup which launches stylus popup menu.
242 * If NULL, menu wasn't launched from a preview popup.
243 * If not NULL, stylus popup menu will close also the preview popup
244 * when an option is selected in the stylus popup menu.
247 CAknPreviewPopUpController* iPreviewPopup;
250 * An idle time active object
253 CIdle* iControllerIdle;
266 * Used to track if object has been deleted while calling client callback.
272 #endif // CAKNSTYLUSPOPUPMENU_H