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