idlehomescreen/nativeuicontroller/inc/aistyluspopupmenu.h
changeset 0 f72a12da539e
equal deleted inserted replaced
-1:000000000000 0:f72a12da539e
       
     1 /*
       
     2 * Copyright (c) 2005 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>
       
    25 
       
    26 class CAknPreviewPopUpController;
       
    27 class CAiStylusPopUpMenuContent;
       
    28 class MEikMenuObserver;
       
    29 
       
    30 /**
       
    31  *  Stylus specific popup menu
       
    32  *
       
    33  *  A floating popup menu which is meant for stylus usage only.
       
    34  *  The menu appears near to the tapping position. When an item is 
       
    35  *  tapped the menu calls its observer's (iMenuObserver) HandleCommandL.
       
    36  *  Typically the observer is application's AppUi. It is then the
       
    37  *  observer's responsibility to handle the command appropriately.
       
    38  *
       
    39  *  @lib eikcoctl.lib
       
    40  *  @since S60 v4.0
       
    41  */
       
    42 NONSHARABLE_CLASS( CAiStylusPopUpMenu ) : public CBase, 
       
    43                                            public MCoeControlObserver
       
    44     {
       
    45 public:
       
    46 
       
    47     /**
       
    48      * Two-phased constructor
       
    49      *
       
    50      * @param aObserver Menu observer (not owned) that handles 
       
    51      *                  stylus popup events.
       
    52      * @param aPoint The position where stylus was tapped
       
    53      * @param aPopup Preview popup from which stylus popup
       
    54      *               menu was launched, can be NULL.
       
    55      */
       
    56     static CAiStylusPopUpMenu* NewL( MEikMenuObserver* aObserver, 
       
    57                                          const TPoint& aPoint,
       
    58                                          CAknPreviewPopUpController* aPopup );
       
    59     
       
    60     /**
       
    61      * Two-phased constructor
       
    62      *
       
    63      * @param aObserver Menu observer (not owned) that handles 
       
    64      *                  stylus popup events.
       
    65      * @param aPoint The position where stylus was tapped
       
    66      */
       
    67     static CAiStylusPopUpMenu* NewL( MEikMenuObserver* aObserver, 
       
    68                                          const TPoint& aPoint );
       
    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      * @param aPopup Preview popup from which stylus popup
       
    77      *               menu was launched, can be NULL.
       
    78      */
       
    79     static CAiStylusPopUpMenu* NewLC( MEikMenuObserver* aObserver, 
       
    80                                          const TPoint& aPoint,
       
    81                                          CAknPreviewPopUpController* aPopup );
       
    82     
       
    83     ~CAiStylusPopUpMenu();
       
    84     
       
    85     /**
       
    86      * Adds a menu item. If the menu contains maximum amount of
       
    87      * items, the function will do nothing. Inserted item will be
       
    88      * placed last.
       
    89      *
       
    90      * @param aItem The menu item to be added.
       
    91      * @param aCommandId Item's command id.
       
    92      */
       
    93     void AddMenuItemL( const TDesC& aItem, const TInt aCommandId );
       
    94     
       
    95     /**
       
    96      * Removes a menu item.
       
    97      *
       
    98      * @param aCommandId Command id of the item to be removed.
       
    99      */
       
   100     void RemoveMenuItem( const TInt aCommandId );
       
   101 
       
   102     /**
       
   103      * Hides / shows a menu item.
       
   104      *
       
   105      * @param aCommandId Command id of the item to be hidden / shown.
       
   106      * @param aDimmed ETrue to hide item and EFalse to show item
       
   107      */
       
   108     void SetItemDimmed( const TInt aCommandId, const TBool aDimmed );
       
   109 
       
   110     /**
       
   111      * Shows the stylus popup menu. If it's already visible,
       
   112      * nothing happens.
       
   113      */
       
   114     void ShowMenu();
       
   115         
       
   116     /**
       
   117      * Sets the position of the stylus popup menu. 
       
   118      * Position will be adjusted if the menu doesn't fit on the screen
       
   119      * properly.
       
   120      *
       
   121      * @param aPoint Position of the stylus popup menu's top-left corner.
       
   122      */
       
   123     void SetPosition( const TPoint& aPoint );    
       
   124     
       
   125 // from base class CCoeControl
       
   126 
       
   127     /**
       
   128      * Constructs the menu from resource.
       
   129      *
       
   130      * @param aReader Resource reader.
       
   131      */
       
   132     void ConstructFromResourceL( TResourceReader& aReader );
       
   133 
       
   134 // from base class MCoeControlObserver
       
   135     
       
   136     /**
       
   137      * Method to handle events that occur when user selects a menu item.
       
   138      *
       
   139      * @param aControl The control that sent the event.
       
   140 	 * @param aEventType The event type.
       
   141      */
       
   142     void HandleControlEventL( CCoeControl* aControl,
       
   143                                        TCoeEvent aEventType );
       
   144 
       
   145 private:
       
   146 
       
   147     /**
       
   148      * Default constructor
       
   149      *
       
   150      * @param aObserver Menu observer (not owned) that handles 
       
   151      *                  stylus popup events.
       
   152      * @param aPoint The position where stylus was tapped
       
   153      * @param aPopup Preview popup from which stylus popup
       
   154      *               menu was launched, can be NULL.
       
   155      */
       
   156     CAiStylusPopUpMenu( MEikMenuObserver* aObserver, const TPoint& aPoint,
       
   157                          CAknPreviewPopUpController* aPopup );
       
   158 
       
   159     void ConstructL();
       
   160 
       
   161 private: // data
       
   162 
       
   163     /**
       
   164      * Screen relative position where stylus was tapped.
       
   165      */
       
   166     TPoint iPosition;
       
   167     
       
   168     /**
       
   169      * Controller for the actual popup.
       
   170      * Own.
       
   171      */
       
   172     CAknPreviewPopUpController* iController;
       
   173     
       
   174     /**
       
   175      * Popup's content.
       
   176      * Own.
       
   177      */
       
   178     CAiStylusPopUpMenuContent* iContent;
       
   179     
       
   180     /**
       
   181      * Observer which will be used to forward selected menu command id.
       
   182      * Not own.
       
   183      */
       
   184     MEikMenuObserver* iMenuObserver;
       
   185     
       
   186     /**
       
   187      * Preview popup which launches stylus popup menu.
       
   188      * If NULL, menu wasn't launched from a preview popup.
       
   189      * If not NULL, stylus popup menu will close also the preview popup
       
   190      * when an option is selected in the stylus popup menu.
       
   191      * Not own.
       
   192      */
       
   193     CAknPreviewPopUpController* iPreviewPopup;
       
   194     
       
   195     };
       
   196 
       
   197 
       
   198 #endif // CAKNSTYLUSPOPUPMENU_H