1.1 --- a/epoc32/include/mw/eikmenup.h Tue Nov 24 13:55:44 2009 +0000
1.2 +++ b/epoc32/include/mw/eikmenup.h Tue Mar 16 16:12:26 2010 +0000
1.3 @@ -1,1 +1,1050 @@
1.4 -eikmenup.h
1.5 +/*
1.6 +* Copyright (c) 1997-1999 Nokia Corporation and/or its subsidiary(-ies).
1.7 +* All rights reserved.
1.8 +* This component and the accompanying materials are made available
1.9 +* under the terms of the License "Symbian Foundation License v1.0" to Symbian Foundation members and "Symbian Foundation End User License Agreement v1.0" to non-members
1.10 +* which accompanies this distribution, and is available
1.11 +* at the URL "http://www.symbianfoundation.org/legal/licencesv10.html".
1.12 +*
1.13 +* Initial Contributors:
1.14 +* Nokia Corporation - initial contribution.
1.15 +*
1.16 +* Contributors:
1.17 +*
1.18 +* Description:
1.19 +*
1.20 +*/
1.21 +
1.22 +
1.23 +#if !defined(__EIKMENUP_H__)
1.24 +#define __EIKMENUP_H__
1.25 +
1.26 +#if !defined(__EIKBCTRL_H__)
1.27 +#include <eikbctrl.h>
1.28 +#endif
1.29 +
1.30 +#if !defined(__EIKDEF_H__)
1.31 +#include <eikdef.h>
1.32 +#endif
1.33 +
1.34 +#if !defined(__EIKSBOBS_H__)
1.35 +#include <eiksbobs.h> // for TEikScrollEvent
1.36 +#endif
1.37 +
1.38 +#include <bidi.h>
1.39 +
1.40 +// FORWARD DECLARATIONS
1.41 +class MEikMenuObserver;
1.42 +class CEikHotKeyTable;
1.43 +class CEikMenuPaneTitle;
1.44 +class CEikButtonBase;
1.45 +class CEikScrollBarFrame;
1.46 +class CEikScrollBar;
1.47 +class TEikScrollBarModel;
1.48 +class CGulIcon;
1.49 +class CEikMenuPaneExtension ;
1.50 +
1.51 +// CONSTANTS
1.52 +const TInt KScaleableTextSeparator = 0x0001;
1.53 +
1.54 +/**
1.55 + * A helper class for extending CEikMenuPaneItem without breaking binary
1.56 + * compability.
1.57 + */
1.58 +class CExtendedItemData : public CBase
1.59 + {
1.60 +
1.61 +public:
1.62 +
1.63 + /**
1.64 + * Destructor.
1.65 + */
1.66 + ~CExtendedItemData();
1.67 +
1.68 +public:
1.69 +
1.70 + /** Two packaked bitmaps: bitmap icon and mask for it. */
1.71 + CGulIcon* iIcon;
1.72 +
1.73 + /** Scalable text buffer. */
1.74 + HBufC* iScaleableText;
1.75 + };
1.76 +
1.77 +
1.78 +/**
1.79 + * The @c CEikMenuPaneItem class encapsulates the data needed to define a menu
1.80 + * pane item and provides some of the functionality required to display the
1.81 + * item.
1.82 + *
1.83 + * @since ER5U
1.84 + */
1.85 +class CEikMenuPaneItem : public CBase
1.86 + {
1.87 +
1.88 +public:
1.89 +
1.90 + /** Struct to menu pane item. */
1.91 + struct SData
1.92 + {
1.93 +
1.94 + /** Nominal text length.*/
1.95 + enum { ENominalTextLength=40 };
1.96 +
1.97 + /**
1.98 + * ID of the command to issue when the menu item using this @c SData is
1.99 + * selected.
1.100 + */
1.101 + TInt iCommandId;
1.102 +
1.103 + /** Resource ID of a menu pane to cascade from this item. */
1.104 + TInt iCascadeId;
1.105 +
1.106 + /**
1.107 + * Flags used internally by @c CEikMenuPane and accessible through
1.108 + * functions such as @c CEikMenuPane::SetItemDimmed().
1.109 + */
1.110 + TInt iFlags;
1.111 +
1.112 + /** The text buffer displayed in the main area of the menu item. */
1.113 + TBuf<ENominalTextLength> iText; // less than this actually stored
1.114 +
1.115 + /**
1.116 + * Additional descriptive text about the item. This is used by @c
1.117 + * CEikMenuPane to display hotkey names.
1.118 + */
1.119 + TBuf<1> iExtraText;
1.120 + };
1.121 +
1.122 +public:
1.123 +
1.124 + /**
1.125 + * C++ default constructor.
1.126 + */
1.127 + IMPORT_C CEikMenuPaneItem();
1.128 +
1.129 + /**
1.130 + * Destructor.
1.131 + */
1.132 + IMPORT_C ~CEikMenuPaneItem();
1.133 +
1.134 + /**
1.135 + * Sets a menu item icon. This replaces any icon already set for the menu
1.136 + * item.
1.137 + *
1.138 + * @param aIcon Menu item icon consisting of a picture bitmap and a mask
1.139 + * bitmap.
1.140 + */
1.141 + IMPORT_C void SetIcon(CGulIcon* aIcon);
1.142 +
1.143 + /**
1.144 + * Draws the menu item icon.
1.145 + *
1.146 + * @param aGc Graphics context to which the icon is drawn.
1.147 + * @param aRect Rectangle in which the icon is drawn.
1.148 + * @param aDimmed If @c ETrue the icon is drawn dimmed.
1.149 + * @param aBitmapSpaceRequired Length of one side of the square required to
1.150 + * contain the bitmap.
1.151 + */
1.152 + IMPORT_C void DrawItemIcon(CWindowGc& aGc,
1.153 + TRect aRect,
1.154 + TBool aDimmed,
1.155 + TInt aBitmapSpaceRequired) const;
1.156 +
1.157 + /**
1.158 + * Construct an icon from bitmaps.
1.159 + *
1.160 + * Constructs a new icon for the menu item, taking ownership of the picture
1.161 + * bitmap aBitmap and the mask bitmap aMask unless the bitmaps are
1.162 + * externally owned.
1.163 + *
1.164 + * @param aBitmap Picture bitmap.
1.165 + * @param aMask Mask bitmap.
1.166 + */
1.167 + IMPORT_C void CreateIconL(CFbsBitmap* aBitmap,
1.168 + CFbsBitmap* aMask);
1.169 +
1.170 + /**
1.171 + * Gets a pointer to the menu item's icon picture bitmap. This does not
1.172 + * imply transfer of ownership.
1.173 + *
1.174 + * @return Picture bitmap.
1.175 + */
1.176 + IMPORT_C CFbsBitmap* IconBitmap() const;
1.177 +
1.178 + /**
1.179 + * Gets a pointer to the menu item's icon mask bitmap. This does not imply
1.180 + * transfer of ownership.
1.181 + *
1.182 + * @return Mask bitmap.
1.183 + */
1.184 + IMPORT_C CFbsBitmap* IconMask() const;
1.185 +
1.186 + /**
1.187 + * Sets icon bitmap ownership.
1.188 + * Sets the menu item's icon bitmaps as externally owned if @c
1.189 + * aOwnedExternally is @c ETrue.
1.190 + *
1.191 + * @param aOwnedExternally If @c ETrue bitmaps are set as externally owned.
1.192 + * @c If EFalse bitmaps are set as not being externally owned.
1.193 + */
1.194 + IMPORT_C void SetBitmapsOwnedExternally(TBool aOwnedExternally);
1.195 +
1.196 + /**
1.197 + * Sets the picture bitmap. Transfers ownership unless the bitmaps are
1.198 + * already owned externally.
1.199 + *
1.200 + * @param aBitmap Picture bitmap.
1.201 + */
1.202 + IMPORT_C void SetIconBitmapL(CFbsBitmap* aBitmap);
1.203 +
1.204 + /**
1.205 + * Sets the mask bitmap. Transfers ownership unless the bitmaps are already
1.206 + * owned externally.
1.207 + *
1.208 + * @param aMask Mask bitmap.
1.209 + */
1.210 + IMPORT_C void SetIconMaskL(CFbsBitmap* aMask);
1.211 +
1.212 + /**
1.213 + * Returns scaleable text. If there isn't scaleable text available then
1.214 + * this method returns @c iData.iText.
1.215 + *
1.216 + * @return Pointer to TPtrC object that contains scaleable text.
1.217 + */
1.218 + IMPORT_C TPtrC ScaleableText() const;
1.219 +
1.220 + /**
1.221 + * Sets scaleable text. @c iData.iText is set to first text version.
1.222 + *
1.223 + * @param aText Scalable text.
1.224 + */
1.225 + IMPORT_C void SetScaleableTextL(const TDesC& aText);
1.226 +
1.227 +private:
1.228 + inline void CreateExtendedDataBlock();
1.229 + inline TBool IsScaleableText(const TDesC& aText) const;
1.230 + TPtrC GetNominalText(const TDesC& aText);
1.231 +
1.232 +public:
1.233 +
1.234 + /** The y position of the menu pane item. */
1.235 + TInt iPos;
1.236 +
1.237 + /** The menu pane item's hotkey text. */
1.238 + TInt iHotKeyCode;
1.239 +
1.240 + /** Information from an SData struct. */
1.241 + SData iData;
1.242 +
1.243 +private:
1.244 + CExtendedItemData* iExtendedData;
1.245 + };
1.246 +
1.247 +
1.248 +inline void CEikMenuPaneItem::CreateExtendedDataBlock()
1.249 + {
1.250 + if (!iExtendedData)
1.251 + {
1.252 + TRAPD(err, ( iExtendedData = new (ELeave) CExtendedItemData() ) );
1.253 + }
1.254 + }
1.255 +
1.256 +
1.257 +inline TBool CEikMenuPaneItem::IsScaleableText(const TDesC& aText) const
1.258 + {
1.259 + return (aText.Locate(TChar(KScaleableTextSeparator)) == KErrNotFound ? EFalse : ETrue);
1.260 + }
1.261 +
1.262 +
1.263 +/**
1.264 + * Menu panes are opened by activating the menu title
1.265 + * @c (CEikMenuPaneTitle / MENU_TITLE) which is displayed in the menu bar @c
1.266 + * (CEikMenuBar / MENU_BAR). They can also be cascaded from a menu item @c
1.267 + * (CEikMenuPaneItem / MENU_ITEM) or launched by a menu button @c
1.268 + * (CEikMenuButton).
1.269 + *
1.270 + * Menu panes may be defined using a @c MENU_PANE resource.
1.271 + */
1.272 +class CEikMenuPane : public CEikBorderedControl
1.273 + {
1.274 +private:
1.275 + enum {ENothingSelected=-1};
1.276 + class CMenuScroller;
1.277 + friend class CMenuScroller;
1.278 + friend class CEikMenuPaneExtension;
1.279 +public:
1.280 +
1.281 + /** The text to be displayed for a hotkey. */
1.282 + typedef TBuf<20> THotKeyDisplayText;
1.283 +
1.284 +public:
1.285 +
1.286 + /**
1.287 + * This class provides a constructor to create an array of menu pane items
1.288 + * and a destructor to destroy an array of menu pane items.
1.289 + */
1.290 + class CItemArray:public CArrayPtrFlat<CEikMenuPaneItem>
1.291 + {
1.292 +
1.293 + public:
1.294 +
1.295 + /**
1.296 + * C++ default constructor that creates a flat array of menu pane
1.297 + * items.
1.298 + */
1.299 + IMPORT_C CItemArray();
1.300 +
1.301 + /**
1.302 + * Destructor.
1.303 + */
1.304 + IMPORT_C ~CItemArray();
1.305 +
1.306 + /**
1.307 + * Appends @c CEikMenuPaneItem class object to array.
1.308 + *
1.309 + * @param aMenuItem The menu item to add.
1.310 + */
1.311 + IMPORT_C void AddItemL(CEikMenuPaneItem* aMenuItem);
1.312 + };
1.313 +
1.314 +public:
1.315 +
1.316 + /**
1.317 + * Destructor.
1.318 + */
1.319 + IMPORT_C ~CEikMenuPane();
1.320 +
1.321 + /**
1.322 + * C++ default constructor. Constructs a menu pane object with the
1.323 + * specified observer.
1.324 + *
1.325 + * @param aMenuObserver Menu observer.
1.326 + */
1.327 + IMPORT_C CEikMenuPane(MEikMenuObserver* aMenuObserver);
1.328 +
1.329 + /**
1.330 + * Handles 2nd base construction. Completes construction of a menu pane object.
1.331 + *
1.332 + * @param aOwner Menu pane owner ( for cascade menu ).
1.333 + * @param aEditMenuObserver Observer for the edit menu. In default this is
1.334 + * @c NULL.
1.335 + */
1.336 + IMPORT_C void ConstructL(CEikMenuPane* aOwner,
1.337 + MEikMenuObserver* aEditMenuObserver = NULL);
1.338 +
1.339 + /**
1.340 + * Destroys the menu pane's item array.
1.341 + */
1.342 + IMPORT_C void Reset();
1.343 +
1.344 +public: // framework
1.345 +
1.346 + /**
1.347 + * From @c CcoeControl.
1.348 + *
1.349 + * Handles key events offered to the menu by the control environment and
1.350 + * provides an appropriate implementation of @c
1.351 + * CCoeControl::OfferKeyEventL().
1.352 + *
1.353 + * @param aKeyEvent The key event.
1.354 + * @param aType The type of key event: @c EEventKey, @c EEventKeyUp or @c
1.355 + * EEventKeyDown.
1.356 + */
1.357 + IMPORT_C TKeyResponse OfferKeyEventL(const TKeyEvent& aKeyEvent,
1.358 + TEventCode aType);
1.359 +
1.360 + /**
1.361 + * From @c CcoeControl.
1.362 + *
1.363 + * Handles a pointer event on the menu.
1.364 + *
1.365 + * @param aPointerEvent The pointer event to handle.
1.366 + */
1.367 + IMPORT_C void HandlePointerEventL(const TPointerEvent& aPointerEvent);
1.368 +
1.369 + /**
1.370 + * From @c CcoeControl.
1.371 + *
1.372 + * Gets the list of logical colours employed in the drawing of the control,
1.373 + * paired with an explanation of how they are used. Appends the list into
1.374 + * @c aColorUseList.
1.375 + *
1.376 + * @since 005u
1.377 + * @param aColorUseList The list of colours paired with explanations.
1.378 + */
1.379 + IMPORT_C virtual void GetColorUseListL(
1.380 + CArrayFix<TCoeColorUse>& aColorUseList) const;
1.381 +
1.382 + /**
1.383 + * From @c CcoeControl.
1.384 + *
1.385 + * Handles a change to the menu's resources which are shared across the
1.386 + * environment. For example, colours or fonts.
1.387 + *
1.388 + * @since 005u
1.389 + * @param aType The type of resource that has changed.
1.390 + */
1.391 + IMPORT_C virtual void HandleResourceChange(TInt aType); // not available before Release 005u
1.392 +
1.393 +private: // from base class
1.394 +
1.395 + /**
1.396 + * Not implemented.
1.397 + *
1.398 + * @param Not used.
1.399 + * @return NULL
1.400 + */
1.401 + IMPORT_C void* ExtensionInterface( TUid aInterface );
1.402 +
1.403 +public: // from MCoeInputObserver
1.404 +
1.405 + /**
1.406 + * From @c CCoeControl.
1.407 + *
1.408 + * Gets the list box’s input capabilities as set through the list box flags.
1.409 + *
1.410 + * @return List box input capabilities.
1.411 + */
1.412 + IMPORT_C TCoeInputCapabilities InputCapabilities() const;
1.413 +
1.414 +protected: // from base class
1.415 +
1.416 + /**
1.417 + * From @c CCoeControl
1.418 + *
1.419 + * Draw a control called by window server.
1.420 + *
1.421 + * All controls, except blank controls, should implement this function. The
1.422 + * default implementation draws a blank control. This function is used for
1.423 + * window server-initiated redrawing of controls, and for some
1.424 + * application-initiated drawing. It should be implemented by each control,
1.425 + * but is only called from within @c CCoeControl's member functions, and
1.426 + * not from the derived class. For this reason it is a private member
1.427 + * function of @c CCoeControl.
1.428 + *
1.429 + * The rectangle aRect indicates the region of the control that needs to be
1.430 + * redrawn. The implementation of @c Draw() must always draw to every pixel
1.431 + * within this rectangle.
1.432 + *
1.433 + * @param aRect The region of the control to be redrawn.
1.434 + * Co-ordinates are relative to the control's origin (top left
1.435 + * corner). Optional, not used currently.
1.436 + */
1.437 + IMPORT_C void Draw(const TRect& aRect) const;
1.438 +
1.439 + /**
1.440 + * From @c CCoeControl.
1.441 + *
1.442 + * Takes any action required when the menu pane gains or loses focus,
1.443 + * to change its appearance for example.
1.444 + *
1.445 + * @param aDrawNow If @c EDrawNow the menu pane is redrawn. If @c
1.446 + * ENoDrawNow the menu pane is not redrawn.
1.447 + */
1.448 + IMPORT_C void FocusChanged(TDrawNow aDrawNow);
1.449 +
1.450 + /**
1.451 + * From @c CCoeControl.
1.452 + *
1.453 + * Constructs the menu pane using the specified resource reader.
1.454 + * Fills the menu item array with the list of menu items provided by the
1.455 + * resource file.
1.456 + *
1.457 + * @param aReader The resource reader to use.
1.458 + * @leave KErrNoMemory Memory allocation failure earlier construction.
1.459 + */
1.460 + IMPORT_C void ConstructFromResourceL(TResourceReader& aReader);
1.461 +
1.462 +public: // new functions
1.463 +
1.464 + /**
1.465 + * Adds a menu item dynamically by creating a new menu item, setting its
1.466 + * data to @c aMenuItem and appending it to the pane's menu item array.
1.467 + * Updates the menu's scroll bar to take account of the new item.
1.468 + *
1.469 + * @param aMenuItem The menu item to add.
1.470 + * NOTICE that @c SData is a structure so all fields in it should be
1.471 + * set to avoid any unexpected behaviour.
1.472 + */
1.473 + IMPORT_C void AddMenuItemL(const CEikMenuPaneItem::SData& aMenuItem);
1.474 +
1.475 + /**
1.476 + * Adds a menu item dynamically by creating a new menu item, setting its
1.477 + * data to @c aMenuItem and inserting it into the pane's menu item array.
1.478 + * Updates the menu's scroll bar to take account of the new item.
1.479 + *
1.480 + * @param aMenuItem The menu item to add. NOTICE that @c SData is a
1.481 + * structure so all fields in it should be set to avoid any
1.482 + * unexpected behaviour.
1.483 + * @param aPreviousId The id of the item after which the new item should be
1.484 + * added.
1.485 + */
1.486 + IMPORT_C void AddMenuItemL(const CEikMenuPaneItem::SData& aMenuItem,
1.487 + TInt aPreviousId);
1.488 +
1.489 + /**
1.490 + * Adds menu items dynamically by creating new menu items from resource
1.491 + * and inserts them into the pane's menu item array.
1.492 + *
1.493 + * @param aResourceId The ID of the resource for the menu item.
1.494 + * @param aPreviousId The ID of the previous menu item, after which this
1.495 + * newly created item should be added.
1.496 + * @param aAddSeperator Shouldn't be used as separator is not not supported
1.497 + * anymore.
1.498 + */
1.499 + IMPORT_C void AddMenuItemsL(TInt aResourceId,
1.500 + TInt aPreviousId = 0,
1.501 + TBool aAddSeperator = EFalse);
1.502 +
1.503 + /**
1.504 + * Deletes the specified item in the menu pane.
1.505 + *
1.506 + * @param aCommandId The ID for the item to be deleted.
1.507 + */
1.508 + IMPORT_C void DeleteMenuItem(TInt aCommandId);
1.509 +
1.510 + /**
1.511 + * Deletes the items between specified items.
1.512 + *
1.513 + * @param aStartIndex The index of the item after which items should be
1.514 + * deleted.
1.515 + * @param aEndIndex The index of the item up to which items should be
1.516 + * deleted.
1.517 + */
1.518 + IMPORT_C void DeleteBetweenMenuItems(TInt aStartIndex,
1.519 + TInt aEndIndex);
1.520 +
1.521 + /**
1.522 + * Gets a reference to the data in the specified menu item.
1.523 + *
1.524 + * @param aCommandId The command ID of the menu item for which data is
1.525 + * obtained.
1.526 + * @return Reference to struct that contains command id.
1.527 + */
1.528 + IMPORT_C CEikMenuPaneItem::SData& ItemData(TInt aCommandId);
1.529 +
1.530 + /**
1.531 + * Gets a pointer to the specified menu item. Also gets the position of the
1.532 + * item within the menu pane. Panics if there are no menu items in the menu
1.533 + * pane. Panics if the menu pane id does not identify any menu pane item in
1.534 + * the array.
1.535 + *
1.536 + * @param aCommandId The ID of the menu item for which a pointer is
1.537 + * returned.
1.538 + * @param aPos On return, the position of the menu item with an ID of
1.539 + * aCommandId.
1.540 + * @return A pointer to the menu item.
1.541 + * @panic EEikPanicNoSuchMenuItem Panics if there are no menu items in the
1.542 + * menu pane or if the menu pane id does not
1.543 + * identify any menu pane item in the array.
1.544 + */
1.545 + IMPORT_C CEikMenuPaneItem* ItemAndPos(TInt aCommandId,TInt& aPos);
1.546 +
1.547 + /**
1.548 + * Displays the menu pane with the corner identified by @c aTargetType in
1.549 + * the position specified by @c aTargetPos. This function uses @c
1.550 + * aMinTitleWidth to calculate the area required to display the menu pane,
1.551 + * taking into account whether the menu is a cascading menu or popup menu.
1.552 + *
1.553 + * @param aHotKeyTable Optional hotkey table.
1.554 + * @param aTargetPos Position of the corner of the menu pane identified by
1.555 + * @c aTargetType.
1.556 + * @param aMenuPaneTitle The menu pane's title.
1.557 + * @param aMinWidth Minimum width of the menu's title.
1.558 + * @param aTargetType The corner of the menu pane to which @c aTargetPos
1.559 + * relates. The default is the top left corner. Possible: @c
1.560 + * EPopupTargetTopLeft, @c EPopupTargetTopRight,
1.561 + * @cEPopupTargetBottomLeft, @c EPopupTargetBottomRight.
1.562 + */
1.563 + IMPORT_C void StartDisplayingMenuPane(
1.564 + const CEikHotKeyTable* aHotKeyTable,
1.565 + const TPoint& aTargetPos,
1.566 + const CEikMenuPaneTitle* aMenuPaneTitle,
1.567 + TInt aMinWidth,
1.568 + TPopupTargetPosType aTargetType = EPopupTargetTopLeft);
1.569 +
1.570 + /**
1.571 + * Sets the text in a menu item.
1.572 + *
1.573 + * @param aCommandId The command (as defined in an .hrh file) associated
1.574 + * with this menu item. This identifies the menu item whose text is
1.575 + * to be set.
1.576 + * @param aDes New item text.
1.577 + */
1.578 + IMPORT_C void SetItemTextL(TInt aCommandId,
1.579 + const TDesC& aDes);
1.580 +
1.581 + /**
1.582 + * Sets the text in a menu item from resource.
1.583 + *
1.584 + * @param aCommandId The command (as defined in an .hrh file) associated
1.585 + * with this menu item. This identifies the menu item whose text is
1.586 + * to be set.
1.587 + * @param aRid The resource ID of the menu item text.
1.588 + */
1.589 + IMPORT_C void SetItemTextL(TInt aCommandId,
1.590 + TInt aRid);
1.591 +
1.592 + /**
1.593 + * Dims (greys out) or undims a menu item. Dimming indicates that user
1.594 + * input is not accepted.
1.595 + *
1.596 + * @param aCommandId The command (as defined in an .hrh file) associated
1.597 + * with this menu item. This identifies the menu item whose text is
1.598 + * to be dimmed or un-dimmed.
1.599 + * @param aDimmed @c ETrue to dim this menu item. @c EFalse to un-dim this
1.600 + * menu item.
1.601 + */
1.602 + IMPORT_C void SetItemDimmed(TInt aCommandId,
1.603 + TBool aDimmed);
1.604 +
1.605 + /**
1.606 + * Sets the item to be indicated or not. It should be used to change the
1.607 + * state of radio buttons or check box items. It has real effect only
1.608 + * starting from S60 v3.0.
1.609 + *
1.610 + * @param aCommandId The command (as defined in an .hrh file) associated
1.611 + * with this menu item. This identifies the menu item for which the
1.612 + * state is set or unset.
1.613 + * @param aButtonState should be @c EEikMenuItemSymbolOn or @c
1.614 + * EEikMenuItemSymbolIndeterminate
1.615 + */
1.616 + IMPORT_C void SetItemButtonState(TInt aCommandId,
1.617 + TInt aButtonState);
1.618 +
1.619 + /**
1.620 + * Sets the selected menu item.
1.621 + *
1.622 + * @param aSelectedItem The index of the item to get selected
1.623 + */
1.624 + IMPORT_C void SetSelectedItem(TInt aSelectedItem);
1.625 +
1.626 + /**
1.627 + * Gets the position of the selected menu item.
1.628 + *
1.629 + * @return The position of the selected menu item.
1.630 + */
1.631 + IMPORT_C TInt SelectedItem() const;
1.632 +
1.633 + /**
1.634 + * Closes and destroys any current cascade menu and takes focus back. Does
1.635 + * nothing if no cascade menu exists.
1.636 + */
1.637 + IMPORT_C void CloseCascadeMenu();
1.638 +
1.639 + /**
1.640 + * Sets the array containing the list of menu items for the current menu
1.641 + * pane.
1.642 + *
1.643 + * @param aItemArray The menu item array for the menu pane.
1.644 + */
1.645 + IMPORT_C void SetItemArray(CItemArray* aItemArray);
1.646 +
1.647 + /**
1.648 + * Set menu item array ownership.
1.649 + *
1.650 + * @param aOwnedExternally If @c ETrue the menu pane's menu item array is
1.651 + * set as externally owned. If @c EFalse the menu pane's menu item
1.652 + * array is set as not externally owned.
1.653 + */
1.654 + IMPORT_C void SetItemArrayOwnedExternally(TBool aOwnedExternally);
1.655 +
1.656 + /**
1.657 + * Sets the specified button to launch the menu pane. Doesn't have any
1.658 + * effect in current implementation.
1.659 + *
1.660 + * @param aButton The button to set as launching the menu.
1.661 + */
1.662 + IMPORT_C void SetLaunchingButton(CEikButtonBase* aButton);
1.663 +
1.664 + /**
1.665 + * Moves the menu pane highlight to a newly selected menu item identified
1.666 + * by @c aNewSelectedItem. Scrolls the menu to show the new selected item
1.667 + * if necessary and redraws only the newly selected item and the currently
1.668 + * selected item if possible.
1.669 + *
1.670 + * @param aNewSelectedItem The newly selected menu item index.
1.671 + */
1.672 + IMPORT_C void MoveHighlightTo(TInt aNewSelectedItem);
1.673 +
1.674 + /**
1.675 + * Gets the number of menu items within the menu pane.
1.676 + *
1.677 + * @return Number of menu items within menu pane.
1.678 + */
1.679 + IMPORT_C TInt NumberOfItemsInPane() const;
1.680 +
1.681 + /**
1.682 + * Closes the menu pane.
1.683 + */
1.684 + IMPORT_C void Close();
1.685 +
1.686 + /**
1.687 + * From @ CCoeControl
1.688 + *
1.689 + * Handles key events offered to the menu by the control environment.
1.690 + *
1.691 + * @since Platform 004.
1.692 + * @param aKeyEvent The key event.
1.693 + * @param aType The type of key event: @c EEventKey, @c EEventKeyUp or @c
1.694 + * EEventKeyDown.
1.695 + * @param aConsumeAllKeys If @c ETrue this function returns @c
1.696 + * EKeyWasConsumed regardless of whether it was used. If @c EFalse
1.697 + * the key event is consumed if possible and either @c
1.698 + * EKeyWasConsumed or @c EKeyWasNotConsumed is returned as
1.699 + * appropriate.
1.700 + */
1.701 + IMPORT_C TKeyResponse OfferKeyEventL(const TKeyEvent& aKeyEvent,
1.702 + TEventCode aType,
1.703 + TBool aConsumeAllKeys); // not available before Platform 004
1.704 +
1.705 + /**
1.706 + * Sets whether the scroll bar occupies the left side of the menu pane.
1.707 + *
1.708 + * @param aOnLeft If @c ETrue the scroll bar will occupy the left side of
1.709 + * the menu pane.
1.710 + */
1.711 + IMPORT_C void SetScrollBarOnLeft(TBool aOnLeft);
1.712 +
1.713 + /**
1.714 + * Sets whether the menu pane uses an arrow head scroll bar.
1.715 + *
1.716 + * @param aArrowHead If @c ETrue the menu pane uses an arrow head scroll
1.717 + * bar.
1.718 + */
1.719 + IMPORT_C void SetArrowHeadScrollBar(TBool aArrowHead);
1.720 +
1.721 +// new for AVKON
1.722 +
1.723 + /**
1.724 + * Moves highlight to the next item or to the first one if last item is
1.725 + * selected.
1.726 + */
1.727 + IMPORT_C void NavigateToNextItem();
1.728 +
1.729 + /**
1.730 + * Inserts the menu item to the specified position.
1.731 + *
1.732 + * @param aMenuItem The menu item to add. NOTICE @c SData is the structure
1.733 + * and all fileds should be initialized.
1.734 + * @param aPosition The position of newly created item in the array.
1.735 + */
1.736 + IMPORT_C void InsertMenuItemL(const CEikMenuPaneItem::SData& aMenuItem,
1.737 + TInt aPosition);
1.738 +
1.739 + /**
1.740 + * Checks whether menu pane contains the menu item and returns position of
1.741 + * it if the item is found.
1.742 + *
1.743 + * @param[in] aCommandId The command ID of the item to be searched for.
1.744 + * @param[out] aPosition On return contains position of the item.
1.745 + * @return @c ETrue if item was found. Otherwise @c EFalse.
1.746 + */
1.747 + IMPORT_C TBool MenuItemExists(TInt aCommandId,
1.748 + TInt& aPosition);
1.749 +
1.750 + /**
1.751 + * Checks whether the menu pane is a cascade menu or a main menu.
1.752 + *
1.753 + * @return @c ETrue if the menu pane is cascade menu and @c EFalse if the
1.754 + * menu pane is the main menu.
1.755 + */
1.756 + IMPORT_C TBool IsCascadeMenuPane() const;
1.757 +
1.758 + /**
1.759 + * Enables or disables text scrolling functionality. It is disabled by
1.760 + * default.
1.761 + *
1.762 + * @param aEnable @c ETrue to enable text scrolling functionality.
1.763 + */
1.764 + IMPORT_C void EnableMarqueeL(const TBool aEnable);
1.765 +
1.766 + /**
1.767 + * Report that selection was done for the currently highlighted item.
1.768 + */
1.769 + void ActivateCurrentItemL();
1.770 +
1.771 + /**
1.772 + * Closes cascade menu if there is one and it is active.
1.773 + */
1.774 + TBool CancelActiveMenuPane();
1.775 +
1.776 + /**
1.777 + * Deletes dimmed items from the menu item array.
1.778 + */
1.779 + void FilterDimmedItems();
1.780 +
1.781 + /**
1.782 + * Not implemented.
1.783 + *
1.784 + * @param aWidth Not used.
1.785 + */
1.786 + void ClipMenuItems(TInt aWidth);
1.787 +
1.788 + /**
1.789 + * Gets the menu pane for the cascade menu.
1.790 + *
1.791 + * @return The menu pane for the cascade menu.
1.792 + */
1.793 + IMPORT_C CEikMenuPane* CascadeMenuPane();
1.794 +
1.795 + /**
1.796 + * Gets a reference to the data in the specified menu item.
1.797 + *
1.798 + * @since S60 3.1
1.799 + * @param aItemIndex The index of the item in the items array.
1.800 + * @return The menu item's data.
1.801 + * @leave KErrArgument Wrong @aItemIndex.
1.802 + */
1.803 + IMPORT_C CEikMenuPaneItem::SData& ItemDataByIndexL(TInt aItemIndex);
1.804 +
1.805 + /**
1.806 + * Checks if the position of the menu was set from outside.
1.807 + *
1.808 + * @since S60 3.1
1.809 + * @return @c ETrue in case when position of the menu was set from outside.
1.810 + */
1.811 + TBool IsPositionToBeForced() const;
1.812 +
1.813 + /**
1.814 + * Creates and enables a special characters row to be used in the edit
1.815 + * menu.
1.816 + *
1.817 + * @since S60 3.1
1.818 + * @param aSpecialChars Buffer that holds the selected characters after
1.819 + * user has selected them.
1.820 + */
1.821 + IMPORT_C void ConstructMenuSctRowL( TDes& aSpecialChars );
1.822 +
1.823 + /**
1.824 + * Returns the command id of the specified menu item. The function panics
1.825 + * if aIndex doesn't exist or is out of range.
1.826 + * @param aIndex The index of the menu item for which the command ID is returned.
1.827 + * @since 3.1
1.828 + */
1.829 + IMPORT_C TInt MenuItemCommandId( TInt aIndex ) const;
1.830 +
1.831 +
1.832 + /**
1.833 + * Creates and enables a special characters row to be used in the edit menu.
1.834 + * The special character row is constructed from the given special character table.
1.835 + *
1.836 + * @param aSpecialChars Buffer that holds the selected characters after
1.837 + * user has selected them.
1.838 + * @param aResourceId The special character table resource id to define the
1.839 + * characters in the row.
1.840 + *
1.841 + * @since S60 3.1
1.842 + */
1.843 + IMPORT_C void ConstructMenuSctRowL( TDes& aSpecialChars, TInt aResourceId );
1.844 +
1.845 + /**
1.846 + * Creates and enables a special characters row to be used in the edit menu.
1.847 + * The special character row is constructed from the given special character dialog.
1.848 + *
1.849 + * @param aSpecialChars Buffer that holds the selected characters after
1.850 + * user has selected them.
1.851 + * @param aResourceId The special character dialog resource id that contains a special character table
1.852 + *
1.853 + * @since S60 3.2
1.854 + */
1.855 + IMPORT_C void ConstructMenuSctRowFromDialogL( TDes& aSpecialChars, TInt aResourceId );
1.856 +
1.857 + /**
1.858 + * Creates and enables a special characters row to be used in the edit menu.
1.859 + * The special character row is constructed from the given special character dialog.
1.860 + *
1.861 + * @param aCharCase the charcase used by menu sct
1.862 + * @param aSpecialChars Buffer that holds the selected characters after
1.863 + * user has selected them.
1.864 + * @param aResourceId The special character dialog resource id that contains a special character table
1.865 + *
1.866 + * @since S60 3.2
1.867 + */
1.868 + IMPORT_C void ConstructMenuSctRowFromDialogL( TInt aCharCase, TDes& aSpecialChars, TInt aResourceId );
1.869 +
1.870 +private:
1.871 + enum { EInvalidCurrentSize=0x01, EBackgroundFaded=0x02 };
1.872 +
1.873 +private: // new functions
1.874 + TRect CalculateSizeAndPosition() ;
1.875 + enum THighlightType {ENoHighlight,EDrawHighlight,ERemoveHighlight};
1.876 + void DrawItem(CWindowGc& aGc,TInt aItem, THighlightType aHighlight) const;
1.877 + void FindHotKeyDisplayText(TDes& aDes,const CEikMenuPaneItem& aItem) const;
1.878 + void ReportSelectionMadeL( TBool aAbortTransition = ETrue );
1.879 + void ReportCanceled();
1.880 + void GiveVisualFeedback();
1.881 + void LaunchCascadeMenuL(TInt aCascadeMenuId);
1.882 + void DoLaunchCascadeMenuL(TInt aCascadeMenuId);
1.883 + void TryLaunchCascadeMenuL(const CEikMenuPaneItem& aItem);
1.884 + void PrepareGcForDrawingItems(CGraphicsContext& aGc) const;
1.885 + TBool ItemArrayOwnedExternally() const;
1.886 + TBool IsHotKeyL(const TInt modifiers,const TInt aCode);
1.887 + TBool MoveToItemL(TInt aCode, TInt aModifiers);
1.888 + void HandleScrollEventL(CEikScrollBar* aScrollBar,TEikScrollEvent aEventType);
1.889 + void CreateScrollBarFrame();
1.890 + void UpdateScrollBar();
1.891 + void DoUpdateScrollBarL();
1.892 + void UpdateScrollBarThumbs();
1.893 + static TInt UpdateScrollBarCallBackL(TAny* aObj);
1.894 + TRect ViewRect() const;
1.895 +// TInt NumberOfItemsThatFitInView() const;
1.896 + TInt TotalItemHeight() const;
1.897 + void ScrollToMakeItemVisible(TInt aItemIndex);
1.898 + void Scroll(TInt aAmount);
1.899 + TBool CheckCreateScroller();
1.900 + void CheckCreateScrollerL();
1.901 + void ResetItemArray();
1.902 + void CreateItemArrayL();
1.903 + void SetVScrollBarFlag();
1.904 + TInt TopHighlightGap() const;
1.905 + TInt BottomHighlightGap() const;
1.906 + TInt EvaluateMaxIconWidth() const;
1.907 + void CreateIconFromResourceL(TResourceReader& aReader, CEikMenuPaneItem& aItem) const;
1.908 + // new for AVKON
1.909 + void AnimateMenuPane(const TPoint& aNewPos);
1.910 +
1.911 + // To make layout correct
1.912 + TRect ListMenuPane() const;
1.913 + TRect PopupMenuWindow() const;
1.914 + TRect PopupSubmenuWindow() const;
1.915 +
1.916 + // Skin support for menu
1.917 + void UpdateBackgroundContext(const TRect& aWindowRect);
1.918 +
1.919 + // Support method for highlight animation
1.920 + void RepaintHighlight() const;
1.921 +
1.922 +private: // from CCoeControl
1.923 + IMPORT_C void Reserved_1();
1.924 + IMPORT_C void Reserved_2();
1.925 +
1.926 +private : // new functions
1.927 + void LoadCascadeBitmapL() ;
1.928 +
1.929 + // Support for check mark, from v3.0
1.930 + void LoadCheckMarkBitmapL();
1.931 + TBool MenuHasCheckBoxOn() const;
1.932 + // Support for radio button, from v3.0
1.933 + void LoadRadioButtonBitmapL();
1.934 + TBool IsItemMemberOfRadioButtonGroup(TInt aItem) const ;
1.935 + // for drawing,from v3.0
1.936 + TBool MenuHasIcon() const;
1.937 +
1.938 + TRect CalculateSizeAndPositionScalable( const TRect& aWindowRect, TInt aNumItemsInPane ) ;
1.939 + TRect HighlightRect() const;
1.940 + void PrepareHighlightFrame() const;
1.941 + void SetCascadedIconSize() const;
1.942 +
1.943 + // fixes marquee flickering
1.944 + friend class CAknMarqueeControl;
1.945 + static TInt RedrawMarqueeEvent( TAny* aControl );
1.946 +
1.947 + CEikMenuPaneExtension* Extension() const;
1.948 +
1.949 +protected: // from CoeControl
1.950 +
1.951 + /**
1.952 + * From @c CCoeControl.
1.953 + *
1.954 + * Retrieves an object of the same type as that encapsulated in aId. Other
1.955 + * than in the case where @c NULL is returned, the object returned must be
1.956 + * of the same object type - that is, the @c ETypeId member of the object
1.957 + * pointed to by the pointer returned by this function must be equal to the
1.958 + * @c iUid member of @c aId.
1.959 + *
1.960 + * @since SDK 7.0s
1.961 + * @param aId An encapsulated object type ID.
1.962 + * @return Encapsulates the pointer to the object provided. Note that the
1.963 + * encapsulated pointer may be @c NULL.
1.964 + */
1.965 + IMPORT_C TTypeUid::Ptr MopSupplyObject(TTypeUid aId);
1.966 +
1.967 +public: // From CoeControl.
1.968 +
1.969 + /**
1.970 + * From @c CoeControl.
1.971 + *
1.972 + * Gets the number of controls contained in a compound control. This
1.973 + * function should be implemented by all compound controls.
1.974 + *
1.975 + * Note:
1.976 + * In SDK 6.1 this was changed from protected to public.
1.977 + *
1.978 + * @return The number of component controls contained by this control.
1.979 + */
1.980 + IMPORT_C TInt CountComponentControls() const;
1.981 +
1.982 + /**
1.983 + * From @c CoeControl.
1.984 + *
1.985 + * Gets the specified component of a compound control. This function should´
1.986 + * be implemented by all compound controls.
1.987 + *
1.988 + * Note:
1.989 + * Within a compound control, each component control is identified by an
1.990 + * index, where the index depends on the order the controls were added: the
1.991 + * first is given an index of 0, the next an index of 1, and so on.
1.992 + *
1.993 + * @param[in, out] aIndex The index of the control to get.
1.994 + * @return The component control with an index of @c aIndex.
1.995 + */
1.996 + IMPORT_C CCoeControl* ComponentControl(TInt aIndex) const;
1.997 +
1.998 +protected: // new functions
1.999 +
1.1000 + /**
1.1001 + * Disables sliding effect
1.1002 + * By default is enabled if there is enough memory.
1.1003 + *
1.1004 + * @since 3.1
1.1005 + */
1.1006 + void DisableAnimation();
1.1007 +
1.1008 + /**
1.1009 + * The position of the menu will be changed according to the one
1.1010 + * which is specified by arguments in StartDisplayingMenuPane()
1.1011 + * By default those arguments are not used.
1.1012 + *
1.1013 + * @since 3.1
1.1014 + * @param aForced @c Etrue if arguments are used.
1.1015 + */
1.1016 + void SetPositionToBeForced(TBool aForced);
1.1017 +
1.1018 + /**
1.1019 + * Gets the maximum number of items which can be seen simultaneously.
1.1020 + *
1.1021 + * @return The maximum number of items which can be seen simultaneously.
1.1022 + */
1.1023 + TInt NumberOfItemsThatFitInView() const;
1.1024 +
1.1025 + void DrawNow();
1.1026 +
1.1027 +private: // data
1.1028 + friend class CEikMenuButton;
1.1029 + MEikMenuObserver* iMenuObserver;
1.1030 + MEikMenuObserver* iEditMenuObserver;
1.1031 + CEikMenuPane* iCascadeMenuPane;
1.1032 + const CEikMenuPaneTitle* iMenuPaneTitle;
1.1033 + const CEikHotKeyTable* iHotKeyTable;
1.1034 + CEikMenuPane* iOwner;
1.1035 + CItemArray* iItemArray;
1.1036 + TBool iArrayOwnedExternally;
1.1037 + TBool iAllowPointerUpEvents;
1.1038 + TInt iNumberOfDragEvents;
1.1039 + TInt iSelectedItem;
1.1040 + TInt iItemHeight;
1.1041 + TInt iBaseLine;
1.1042 + TInt iHotkeyColWidth;
1.1043 + TInt iFlags;
1.1044 + CEikScrollBarFrame* iSBFrame;
1.1045 + CMenuScroller* iScroller;
1.1046 + CEikButtonBase* iLaunchingButton; // for popouts only
1.1047 + TInt iSubPopupWidth; // 0..2
1.1048 + TBool iEnableAnimation;
1.1049 + CEikMenuPaneExtension* iExtension ; // iSpare used for extension class pointer.
1.1050 +
1.1051 + };
1.1052 +
1.1053 +#endif
1.1054 +