epoc32/include/mw/aknstyluspopupmenu.h
author William Roberts <williamr@symbian.org>
Wed, 31 Mar 2010 12:33:34 +0100
branchSymbian3
changeset 4 837f303aceeb
parent 2 2fe1408b6811
permissions -rw-r--r--
Current Symbian^3 public API header files (from PDK 3.0.h)
This is the epoc32/include tree with the "platform" subtrees removed, and
all but a selected few mbg and rsg files removed.
     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 "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      * Two-phased constructor
    59      *
    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.
    65      */
    66     IMPORT_C static CAknStylusPopUpMenu* NewL( MEikMenuObserver* aObserver, 
    67                                          const TPoint& aPoint,
    68                                          CAknPreviewPopUpController* aPopup );
    69     
    70     /**
    71      * Two-phased constructor
    72      *
    73      * @param aObserver Menu observer (not owned) that handles 
    74      *                  stylus popup events.
    75      * @param aPoint The position where stylus was tapped
    76      */
    77     IMPORT_C static CAknStylusPopUpMenu* NewL( MEikMenuObserver* aObserver, 
    78                                          const TPoint& aPoint );
    79 
    80     /**
    81      * Two-phased constructor
    82      *
    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.
    88      */
    89     IMPORT_C static CAknStylusPopUpMenu* NewLC( MEikMenuObserver* aObserver, 
    90                                          const TPoint& aPoint,
    91                                          CAknPreviewPopUpController* aPopup );
    92     /**
    93      * Destructor
    94      */    
    95     ~CAknStylusPopUpMenu();
    96     
    97     /**
    98      * Adds a menu item. If the menu contains maximum amount of
    99      * items, the function will do nothing. Inserted item will be
   100      * placed last.
   101      *
   102      * @param aItem The menu item to be added.
   103      * @param aCommandId Item's command id.
   104      */
   105     IMPORT_C void AddMenuItemL( const TDesC& aItem, const TInt aCommandId );
   106     
   107     /**
   108      * Removes a menu item.
   109      *
   110      * @param aCommandId Command id of the item to be removed.
   111      */
   112     IMPORT_C void RemoveMenuItem( const TInt aCommandId );
   113 
   114     /**
   115      * Hides / shows a menu item.
   116      *
   117      * @param aCommandId Command id of the item to be hidden / shown.
   118      * @param aDimmed ETrue to hide item and EFalse to show item
   119      */
   120     IMPORT_C void SetItemDimmed( const TInt aCommandId, const TBool aDimmed );
   121 
   122     /**
   123      * Shows the stylus popup menu. If it's already visible,
   124      * nothing happens.
   125      */
   126     IMPORT_C void ShowMenu();
   127         
   128     /**
   129      * Sets the position of the stylus popup menu. 
   130      * Position will be adjusted if the menu doesn't fit on the screen
   131      * properly.
   132      *
   133      * @param aPoint Position of the left-top corner of the stylus popup menu.
   134      */
   135     IMPORT_C void SetPosition( const TPoint& aPoint );    
   136     /**
   137      * Sets the position of the stylus popup menu. 
   138      * Position will be adjusted if the menu doesn't fit on the screen
   139      * properly.
   140      *
   141      * @param aPoint Position of the stylus popup menu.
   142      * @param aPosType  Position type e.g. left-top corner or right-top corner  
   143      */
   144     IMPORT_C void SetPosition( const TPoint& aPoint, TPositionType aPosType );    
   145 
   146     /**
   147      * Tells the popup menu to recalculate its position. This can be used e.g.
   148      * after layout transition.
   149      */
   150     void UpdatePosition();
   151 
   152     /**
   153      * Removes all menu items.
   154      * 
   155      * @internal
   156      * @since s60 v5.2
   157      */
   158     void Clear();
   159 
   160 // from base class CCoeControl
   161 
   162     /**
   163      * Constructs the menu from resource.
   164      *
   165      * @param aReader Resource reader.
   166      */
   167     IMPORT_C void ConstructFromResourceL( TResourceReader& aReader );
   168 
   169 // from base class MCoeControlObserver
   170     
   171     /**
   172      * Method to handle events that occur when user selects a menu item.
   173      *
   174      * @param aControl The control that sent the event.
   175      * @param aEventType The event type.
   176      */
   177     IMPORT_C void HandleControlEventL( CCoeControl* aControl,
   178                                        TCoeEvent aEventType );
   179 
   180 
   181 private:
   182 
   183     /**
   184      * Default constructor
   185      *
   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.
   191      */
   192     CAknStylusPopUpMenu( MEikMenuObserver* aObserver, const TPoint& aPoint,
   193                          CAknPreviewPopUpController* aPopup );
   194 
   195     /**
   196      * 2nd phase constructor
   197      */
   198     void ConstructL();
   199 
   200     /**
   201      * Starts the CIdle
   202      */
   203     void StartControllerIdleL();
   204     
   205     /**
   206      * CIdle callback function 
   207      */
   208     static TInt ControllerCallBack( TAny* aThis );
   209     
   210     /**
   211      * Removes the controller
   212      */
   213     void RemoveController();
   214     
   215 private: // data
   216 
   217     /**
   218      * Screen relative position where stylus was tapped.
   219      */
   220     TPoint iPosition;
   221     
   222     /**
   223      * Controller for the actual popup.
   224      * Own.
   225      */
   226     CAknPreviewPopUpController* iController;
   227     
   228     /**
   229      * Popup's content.
   230      * Own.
   231      */
   232     CAknStylusPopUpMenuContent* iContent;
   233     
   234     /**
   235      * Observer which will be used to forward selected menu command id.
   236      * Not own.
   237      */
   238     MEikMenuObserver* iMenuObserver;
   239     
   240     /**
   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.
   245      * Not own.
   246      */
   247     CAknPreviewPopUpController* iPreviewPopup;
   248     
   249     /**
   250      * An idle time active object 
   251      * Own
   252      */
   253     CIdle* iControllerIdle;
   254     
   255     /**
   256      * Position type
   257      */
   258     TInt iPositionType;
   259 
   260     /**
   261      * Internal flags.
   262      */
   263     TBitFlags iFlags;
   264     
   265     /**
   266      * Used to track if object has been deleted while calling client callback.
   267      */
   268     TBool* iIsDeleted;
   269     };
   270 
   271 
   272 #endif // CAKNSTYLUSPOPUPMENU_H