javauis/lcdui_akn/lcdui/inc/CMIDMenuHandler.h
branchRCL_3
changeset 19 04becd199f91
equal deleted inserted replaced
16:f5050f1da672 19:04becd199f91
       
     1 /*
       
     2 * Copyright (c) 2003, 2008 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:  Menu pane handling, common across all Displayables.
       
    15 *
       
    16 */
       
    17 
       
    18 
       
    19 #ifndef CMIDMENUHANDLER_H
       
    20 #define CMIDMENUHANDLER_H
       
    21 
       
    22 //  INCLUDES
       
    23 #include <eikbctrl.h>
       
    24 // CEikMenuPaneItem (this is actually from eikmenup.h)
       
    25 #include <eikmenub.h>
       
    26 // MEikMenuObserver interface in class declaration
       
    27 #include <eikmobs.h>
       
    28 
       
    29 #include "CMIDTicker.h"
       
    30 
       
    31 // FORWARD DECLARATIONS
       
    32 class CMIDDisplayable;
       
    33 class CMIDCanvas;
       
    34 class CMIDDefaultBackground;
       
    35 class CMIDUIManager;
       
    36 class CEikMenuBar;
       
    37 class CEikButtonGroupContainer;
       
    38 class CEikAppUi;
       
    39 class CMIDMenuHandler;
       
    40 class CMIDTickerController;
       
    41 class CMIDKeyDecoder;
       
    42 class CMIDScaler;
       
    43 class CEikonEnv;
       
    44 
       
    45 // CLASS DECLARATION
       
    46 
       
    47 // make a common place for the CMIDDisplayable and this const
       
    48 const TInt KMenuBarResourceId = 0xfffd;
       
    49 /**
       
    50 *  CMIDMenuHandler handles the menu and CBA for all Displayables
       
    51 *
       
    52 *  @lib lcdui.dll
       
    53 *  @since Series60 2.0
       
    54 */
       
    55 NONSHARABLE_CLASS(CMIDMenuHandler) : public CBase, public MEikMenuObserver
       
    56 {
       
    57 public:
       
    58     enum TMenuType
       
    59     {
       
    60         ENoMenu=0,
       
    61         EOptionsMenu,
       
    62         EOkMenu,
       
    63         EHelpMenu,
       
    64 #ifdef RD_JAVA_S60_RELEASE_9_2
       
    65         EScreenAndHelpMenu,
       
    66         EPopUpMenu
       
    67 #else
       
    68         EScreenAndHelpMenu
       
    69 #endif // RD_JAVA_S60_RELEASE_9_2          
       
    70     };
       
    71 
       
    72 public:  // Constructors and destructor
       
    73 
       
    74     /**
       
    75     * Two-phased constructor.
       
    76     * Used to create the first instance, the use GetInstance to get pointer
       
    77     */
       
    78     static CMIDMenuHandler* NewL(MMIDEnv& aEnv);
       
    79 
       
    80     /**
       
    81     * Destructor.
       
    82     */
       
    83     ~CMIDMenuHandler();
       
    84 
       
    85 public: // New functions
       
    86 
       
    87     /**
       
    88      * @since s60
       
    89      */
       
    90     TUint MenuItemsCount() const;
       
    91 
       
    92     /**
       
    93      * @since s60
       
    94      */
       
    95     void ShowMenuL(const TMenuType& aType);
       
    96 
       
    97     /**
       
    98      * @since s60
       
    99      */
       
   100     inline CEikMenuBar* MenuBar() const;
       
   101 
       
   102     /**
       
   103      * @since s60
       
   104      */
       
   105     inline CEikButtonGroupContainer* Cba();
       
   106 
       
   107     /**
       
   108      * @since s60
       
   109      */
       
   110     void SetDisplayable(CMIDDisplayable* aView);
       
   111 
       
   112     /**
       
   113      * @since s60
       
   114      */
       
   115     inline CMIDDisplayable* GetDisplayable();
       
   116 
       
   117     /**
       
   118      * Stops displaying menu
       
   119      * @since s60
       
   120      */
       
   121     void HideMenuIfVisible();
       
   122 
       
   123     /**
       
   124     * Contents of the menu is updated if the menu is currently displayed
       
   125     * @since ?Series60_version 3.1
       
   126     */
       
   127     void UpdateMenuIfVisibleL();
       
   128 
       
   129     /**
       
   130     * Checks if MIDlet's full-screen (game)canvas scaling is enabled.
       
   131     * @return   ETrue if scaling is enabled else EFalse.
       
   132      * @since s60
       
   133     */
       
   134     TBool IsScalingEnabled() const;
       
   135 
       
   136     /**
       
   137     * Returns Nokia-MIDlet-Original-Display-Size attribute size
       
   138     * as it is defined in jad file.
       
   139     * @return   Original MIDlet size if attribute is defined else
       
   140     *           zero-size.
       
   141     */
       
   142     inline TSize GetScalingParameterOrgMIDletScrSize() const;
       
   143 
       
   144     /**
       
   145     * Returns Nokia-MIDlet-Taregt-Display-Size attribute size
       
   146     * as it is defined in jad file.
       
   147     * @return   Target MIDlet size if attribute is defined else
       
   148     *           zero-size.
       
   149     */
       
   150     inline TSize GetScalingParameterTargetMIDletScrSize() const;
       
   151 
       
   152     /**
       
   153     * Checks if "MIDlet scaling on orientation switch" is allowed by
       
   154     * setting Nokia-MIDlet-allow-scaling-on-orientation-switch attribute
       
   155     * to true value.
       
   156     * @return   ETrue if feature is enabled else EFalse.
       
   157     */
       
   158     inline TBool GetScalingParameterScaleMIDletOnOrientSwitch() const;
       
   159 
       
   160     /**
       
   161      * Checks if the scaling is enabled in the current device screen.
       
   162      * Checks that Nokia-MIDlet-Original-Display-Size is defined and its
       
   163      * width and height are smaller than the current screen width and heigth.
       
   164      *
       
   165      * @return ETrue if scaling is enabled and effective in current screen.
       
   166      * @since S60 5.0
       
   167      */
       
   168     TBool IsScalingEffectiveInCurrentScreen() const;
       
   169 
       
   170     /**
       
   171     * This function returns current screen size.
       
   172     * @return size of screen
       
   173     */
       
   174     TSize GetScreenSize() const;
       
   175 
       
   176 public: // From MEikMenuObserver
       
   177 
       
   178     /**
       
   179      *
       
   180      * @since s60
       
   181      */
       
   182     void ProcessCommandL(TInt aCommandId);
       
   183 
       
   184     /**
       
   185      *
       
   186      * @since s60
       
   187      */
       
   188     void SetEmphasis(CCoeControl* /*aMenuControl*/,TBool aEmphasis);
       
   189 
       
   190     /**
       
   191      *
       
   192      * @since s60
       
   193      */
       
   194     void DynInitMenuPaneL(TInt /*aResourceId*/, CEikMenuPane* /*aMenuPane*/);
       
   195 
       
   196 private: // Constructors
       
   197 
       
   198     /**
       
   199      * Ctor
       
   200      * @param aEnv Java environment
       
   201      *
       
   202      * @since s60
       
   203      */
       
   204     CMIDMenuHandler(MMIDEnv& aEnv);
       
   205 
       
   206     /**
       
   207      * By default Symbian 2nd phase constructor is private.
       
   208      */
       
   209     void ConstructL();
       
   210 
       
   211     /**
       
   212      * Prohibit copy constructor if not deriving from CBase.
       
   213      * @since s60
       
   214      */
       
   215     CMIDMenuHandler(const CMIDMenuHandler&);
       
   216 
       
   217     /**
       
   218      * Prohibit assigment operator if not deriving from CBase.
       
   219      * @since s60
       
   220      */
       
   221     CMIDMenuHandler& operator=(const CMIDMenuHandler&);
       
   222 
       
   223     /**
       
   224      * Updating of scaling factors
       
   225      */
       
   226     void SetScalingFactors();
       
   227 
       
   228     /**
       
   229      * @since s60
       
   230      */
       
   231     TSize DesToTSize(TPtrC scrSize);
       
   232 
       
   233     /**
       
   234      * Enable Multiple key events for Canvas
       
   235      *
       
   236      * @param aGaugeItemData Data pointer
       
   237      * @since s60
       
   238      */
       
   239     void SendMultipleKeyPressedEvent();
       
   240 
       
   241 
       
   242 private: // Data
       
   243 
       
   244     MMIDEnv& iEnv;
       
   245 
       
   246     CEikMenuBar* iMenuBar;
       
   247     CEikButtonGroupContainer* iCba;
       
   248 
       
   249     CMIDDisplayable* iDisplayable;
       
   250     CEikAppUi* iAppUi;
       
   251     TRect iViewRect;
       
   252 
       
   253     /** The array of menu items to be added next time we display a menu */
       
   254     RArray<CEikMenuPaneItem::SData> iMenuItems;
       
   255 
       
   256     /** Prevents trying to display a menu twice in case the user clicks twice
       
   257     on options CBA whilst menu is displaying - this causes a crash in current
       
   258     3.0 builds */
       
   259     TBool iAttemptingToDisplayMenu;
       
   260 
       
   261     const CEikonEnv& iEikEnv;
       
   262 
       
   263     /** Menutype of currently present menu */
       
   264     TMenuType iMenuType;
       
   265 
       
   266     /** Parameters for scaling by JAD attribute */
       
   267     TSize iOrgMIDletScrSize;
       
   268     TSize iTargetMIDletScrSize;
       
   269     TBool iScaleMIDletOnOrientSwitch;
       
   270 
       
   271 };
       
   272 
       
   273 
       
   274 // -----------------------------------------------------------------------------
       
   275 // CMIDMenuHandler::MenuBar
       
   276 //
       
   277 //
       
   278 // -----------------------------------------------------------------------------
       
   279 //
       
   280 inline CEikMenuBar* CMIDMenuHandler::MenuBar() const
       
   281 {
       
   282     return iMenuBar;
       
   283 }
       
   284 
       
   285 // -----------------------------------------------------------------------------
       
   286 // CMIDMenuHandler::Cba
       
   287 //
       
   288 //
       
   289 // -----------------------------------------------------------------------------
       
   290 //
       
   291 inline CEikButtonGroupContainer* CMIDMenuHandler::Cba()
       
   292 {
       
   293     return iCba;
       
   294 }
       
   295 
       
   296 // -----------------------------------------------------------------------------
       
   297 // CMIDMenuHandler::GetDisplayable
       
   298 //
       
   299 //
       
   300 // -----------------------------------------------------------------------------
       
   301 //
       
   302 inline CMIDDisplayable* CMIDMenuHandler::GetDisplayable()
       
   303 {
       
   304     return iDisplayable;
       
   305 }
       
   306 
       
   307 // -----------------------------------------------------------------------------
       
   308 // CMIDMenuHandler::GetScalingParameterOrgMIDletScrSize
       
   309 // -----------------------------------------------------------------------------
       
   310 //
       
   311 inline TSize CMIDMenuHandler::GetScalingParameterOrgMIDletScrSize() const
       
   312 {
       
   313     return iOrgMIDletScrSize;
       
   314 }
       
   315 
       
   316 // -----------------------------------------------------------------------------
       
   317 // CMIDMenuHandler::GetScalingParameterTargetMIDletScrSize
       
   318 // -----------------------------------------------------------------------------
       
   319 //
       
   320 inline TSize CMIDMenuHandler::GetScalingParameterTargetMIDletScrSize() const
       
   321 {
       
   322     return iTargetMIDletScrSize;
       
   323 }
       
   324 
       
   325 // -----------------------------------------------------------------------------
       
   326 // CMIDMenuHandler::GetScalingParameterScaleMIDletOnOrientSwitch
       
   327 // -----------------------------------------------------------------------------
       
   328 //
       
   329 inline TBool CMIDMenuHandler::GetScalingParameterScaleMIDletOnOrientSwitch() const
       
   330 {
       
   331     return iScaleMIDletOnOrientSwitch;
       
   332 }
       
   333 
       
   334 #endif // CMIDMENUHANDLER_H
       
   335