eikmenup.h

Go to the documentation of this file.
00001 // EIKMENUP.H
00002 //
00003 // Copyright (c) 1997-1999 Symbian Ltd.  All rights reserved.
00004 //
00005 
00006 #if !defined(__EIKMENUP_H__)
00007 #define __EIKMENUP_H__
00008 
00009 #if !defined(__EIKBCTRL_H__)
00010 #include <eikbctrl.h>
00011 #endif
00012 
00013 #if !defined(__EIKDEF_H__)
00014 #include <eikdef.h>
00015 #endif
00016 
00017 #if !defined(__EIKSBOBS_H__)
00018 #include <eiksbobs.h> // for TEikScrollEvent
00019 #endif
00020 
00021 #include <bidi.h>
00022 
00023 // FORWARD DECLARATIONS
00024 class MEikMenuObserver;
00025 class CEikHotKeyTable;
00026 class CEikMenuPaneTitle;
00027 class CEikButtonBase;
00028 class CEikScrollBarFrame;
00029 class CEikScrollBar;
00030 class TEikScrollBarModel;
00031 class CGulIcon;
00032 class CEikMenuPaneExtension ;
00033 
00034 // CONSTANTS
00035 const TInt KScaleableTextSeparator = 0x0001;
00036 
00041 class CExtendedItemData : public CBase
00042     {
00043     
00044 public:
00045     
00049     ~CExtendedItemData();
00050     
00051 public:
00052     
00054     CGulIcon* iIcon;
00055     
00057     HBufC* iScaleableText;    
00058     };
00059 
00060 
00068 class CEikMenuPaneItem : public CBase
00069     {
00070     
00071 public:
00072     
00074     struct SData
00075         {
00076         
00078         enum { ENominalTextLength=40 };
00079         
00084         TInt iCommandId;
00085         
00087         TInt iCascadeId;
00088         
00093         TInt iFlags;
00094         
00096         TBuf<ENominalTextLength> iText; // less than this actually stored
00097         
00102         TBuf<1> iExtraText;
00103         };
00104         
00105 public:
00106 
00110     IMPORT_C CEikMenuPaneItem();
00111     
00115     IMPORT_C ~CEikMenuPaneItem();
00116     
00124     IMPORT_C void SetIcon(CGulIcon* aIcon);
00125     
00135     IMPORT_C void DrawItemIcon(CWindowGc& aGc, 
00136                                TRect aRect, 
00137                                TBool aDimmed, 
00138                                TInt aBitmapSpaceRequired) const;
00139     
00150     IMPORT_C void CreateIconL(CFbsBitmap* aBitmap, 
00151                               CFbsBitmap* aMask);
00152     
00159     IMPORT_C CFbsBitmap* IconBitmap() const;
00160     
00167     IMPORT_C CFbsBitmap* IconMask() const;
00168     
00177     IMPORT_C void SetBitmapsOwnedExternally(TBool aOwnedExternally);
00178     
00185     IMPORT_C void SetIconBitmapL(CFbsBitmap* aBitmap);
00186     
00193     IMPORT_C void SetIconMaskL(CFbsBitmap* aMask);
00194     
00201     IMPORT_C TPtrC ScaleableText() const;
00202     
00208     IMPORT_C void SetScaleableTextL(const TDesC& aText);
00209 
00210 private:
00211     inline void CreateExtendedDataBlock();
00212     inline TBool IsScaleableText(const TDesC& aText) const;
00213     TPtrC GetNominalText(const TDesC& aText);
00214 
00215 public:
00216 
00218     TInt iPos;
00219     
00221     TInt iHotKeyCode;
00222     
00224     SData  iData;
00225 
00226 private:
00227     CExtendedItemData* iExtendedData;
00228     };
00229 
00230 
00231 inline void CEikMenuPaneItem::CreateExtendedDataBlock()
00232     {
00233     if (!iExtendedData)
00234         {
00235         TRAPD(err, ( iExtendedData = new (ELeave) CExtendedItemData() ) );
00236         }
00237     }
00238 
00239 
00240 inline TBool CEikMenuPaneItem::IsScaleableText(const TDesC& aText) const
00241     {
00242     return (aText.Locate(TChar(KScaleableTextSeparator)) == KErrNotFound ? EFalse : ETrue);
00243     }
00244 
00245 
00255 class CEikMenuPane : public CEikBorderedControl
00256     {
00257 private:
00258     enum {ENothingSelected=-1};
00259     class CMenuScroller;
00260     friend class CMenuScroller;
00261     friend class CEikMenuPaneExtension;
00262 public:
00263     
00265     typedef TBuf<20> THotKeyDisplayText;
00266     
00267 public:
00268 
00273     class CItemArray:public CArrayPtrFlat<CEikMenuPaneItem>
00274         {
00275         
00276     public:
00277         
00282         IMPORT_C CItemArray();
00283         
00287         IMPORT_C ~CItemArray();
00288         
00294         IMPORT_C void AddItemL(CEikMenuPaneItem* aMenuItem);
00295         };
00296 
00297 public:
00298 
00302     IMPORT_C ~CEikMenuPane();
00303     
00310     IMPORT_C CEikMenuPane(MEikMenuObserver* aMenuObserver);
00311 
00319     IMPORT_C void ConstructL(CEikMenuPane* aOwner, 
00320                              MEikMenuObserver* aEditMenuObserver = NULL);
00321     
00325     IMPORT_C void Reset();
00326     
00327 public: // framework
00328 
00340     IMPORT_C TKeyResponse OfferKeyEventL(const TKeyEvent& aKeyEvent,
00341                                          TEventCode aType);
00342     
00350     IMPORT_C void HandlePointerEventL(const TPointerEvent& aPointerEvent);
00351     
00362     IMPORT_C virtual void GetColorUseListL(
00363         CArrayFix<TCoeColorUse>& aColorUseList) const; 
00364     
00374     IMPORT_C virtual void HandleResourceChange(TInt aType);         // not available before Release 005u
00375 
00376 private: // from base class
00377 
00384     IMPORT_C void* ExtensionInterface( TUid aInterface );
00385     
00386 public: // from MCoeInputObserver
00387     
00395     IMPORT_C TCoeInputCapabilities InputCapabilities() const;
00396     
00397 protected: // from base class
00398     
00420     IMPORT_C void Draw(const TRect& aRect) const;
00421     
00431     IMPORT_C void FocusChanged(TDrawNow aDrawNow);
00432     
00443     IMPORT_C void ConstructFromResourceL(TResourceReader& aReader);
00444     
00445 public: // new functions
00446 
00456     IMPORT_C void AddMenuItemL(const CEikMenuPaneItem::SData& aMenuItem);
00457     
00469     IMPORT_C void AddMenuItemL(const CEikMenuPaneItem::SData& aMenuItem, 
00470                                TInt aPreviousId);
00471     
00482     IMPORT_C void AddMenuItemsL(TInt aResourceId, 
00483                                 TInt aPreviousId = 0,
00484                                 TBool aAddSeperator = EFalse);
00485     
00491     IMPORT_C void DeleteMenuItem(TInt aCommandId);
00492     
00501     IMPORT_C void DeleteBetweenMenuItems(TInt aStartIndex, 
00502                                          TInt aEndIndex);
00503     
00511     IMPORT_C CEikMenuPaneItem::SData& ItemData(TInt aCommandId);
00512     
00528     IMPORT_C CEikMenuPaneItem* ItemAndPos(TInt aCommandId,TInt& aPos);
00529     
00546     IMPORT_C void StartDisplayingMenuPane(
00547             const CEikHotKeyTable* aHotKeyTable,                               
00548             const TPoint& aTargetPos, 
00549             const CEikMenuPaneTitle* aMenuPaneTitle,
00550             TInt aMinWidth,  
00551             TPopupTargetPosType aTargetType = EPopupTargetTopLeft);
00552             
00561     IMPORT_C void SetItemTextL(TInt aCommandId,
00562                                const TDesC& aDes);
00563     
00572     IMPORT_C void SetItemTextL(TInt aCommandId,
00573                                TInt aRid);
00574                                
00585     IMPORT_C void SetItemDimmed(TInt aCommandId,
00586                                 TBool aDimmed);
00587                                 
00599     IMPORT_C void SetItemButtonState(TInt aCommandId,
00600                                      TInt aButtonState);
00601     
00607     IMPORT_C void SetSelectedItem(TInt aSelectedItem);
00608     
00614     IMPORT_C TInt SelectedItem() const;
00615     
00620     IMPORT_C void CloseCascadeMenu();
00621     
00628     IMPORT_C void SetItemArray(CItemArray* aItemArray);
00629     
00637     IMPORT_C void SetItemArrayOwnedExternally(TBool aOwnedExternally);
00638     
00645     IMPORT_C void SetLaunchingButton(CEikButtonBase* aButton);
00646     
00655     IMPORT_C void MoveHighlightTo(TInt aNewSelectedItem);
00656     
00662     IMPORT_C TInt NumberOfItemsInPane() const;
00663     
00667     IMPORT_C void Close();
00668     
00684     IMPORT_C TKeyResponse OfferKeyEventL(const TKeyEvent& aKeyEvent,
00685                                          TEventCode aType,
00686                                          TBool aConsumeAllKeys); // not available before Platform 004
00687     
00694     IMPORT_C void SetScrollBarOnLeft(TBool aOnLeft);
00695     
00702     IMPORT_C void SetArrowHeadScrollBar(TBool aArrowHead);
00703     
00704 // new for AVKON
00705     
00710     IMPORT_C void NavigateToNextItem();
00711     
00719     IMPORT_C void InsertMenuItemL(const CEikMenuPaneItem::SData& aMenuItem, 
00720                                   TInt aPosition);
00721     
00730     IMPORT_C TBool MenuItemExists(TInt aCommandId, 
00731                                   TInt& aPosition);
00732     
00739     IMPORT_C TBool IsCascadeMenuPane() const;
00740     
00747     IMPORT_C void EnableMarqueeL(const TBool aEnable); 
00748 
00752     void ActivateCurrentItemL();
00753     
00757     TBool CancelActiveMenuPane();
00758     
00762     void FilterDimmedItems();
00763     
00769     void ClipMenuItems(TInt aWidth);
00770     
00776     IMPORT_C CEikMenuPane* CascadeMenuPane();
00777     
00786     IMPORT_C CEikMenuPaneItem::SData& ItemDataByIndexL(TInt aItemIndex);
00787     
00794     TBool IsPositionToBeForced() const;
00795     
00804     IMPORT_C void ConstructMenuSctRowL( TDes& aSpecialChars );
00805 
00812     IMPORT_C TInt MenuItemCommandId( TInt aIndex ) const;
00813 
00814     
00826     IMPORT_C void ConstructMenuSctRowL( TDes& aSpecialChars, TInt aResourceId );
00827 
00838     IMPORT_C void ConstructMenuSctRowFromDialogL( TDes& aSpecialChars, TInt aResourceId );
00839 
00851     IMPORT_C void ConstructMenuSctRowFromDialogL( TInt aCharCase, TDes& aSpecialChars, TInt aResourceId );
00852 
00853 private:
00854     enum { EInvalidCurrentSize=0x01, EBackgroundFaded=0x02 };
00855     
00856 private: // new functions
00857     TRect CalculateSizeAndPosition() ;
00858     enum THighlightType {ENoHighlight,EDrawHighlight,ERemoveHighlight};
00859     void DrawItem(CWindowGc& aGc,TInt aItem,THighlightType aHighlight) const;
00860     void FindHotKeyDisplayText(TDes& aDes,const CEikMenuPaneItem& aItem) const;
00861     void ReportSelectionMadeL( TBool aAbortTransition = ETrue );
00862     void ReportCanceled();
00863     void GiveVisualFeedback();
00864     void LaunchCascadeMenuL(TInt aCascadeMenuId);
00865     void DoLaunchCascadeMenuL(TInt aCascadeMenuId);
00866     void TryLaunchCascadeMenuL(const CEikMenuPaneItem& aItem);
00867     void PrepareGcForDrawingItems(CGraphicsContext& aGc) const;
00868     TBool ItemArrayOwnedExternally() const;
00869     TBool IsHotKeyL(const TInt modifiers,const TInt aCode);
00870     TBool MoveToItemL(TInt aCode, TInt aModifiers);
00871     void HandleScrollEventL(CEikScrollBar* aScrollBar,TEikScrollEvent aEventType);
00872     void CreateScrollBarFrame();
00873     void UpdateScrollBar();
00874     void DoUpdateScrollBarL();
00875     void UpdateScrollBarThumbs();
00876     static TInt UpdateScrollBarCallBackL(TAny* aObj);
00877     TRect ViewRect() const;
00878 //    TInt NumberOfItemsThatFitInView() const;
00879     TInt TotalItemHeight() const;
00880     void ScrollToMakeItemVisible(TInt aItemIndex);
00881     void Scroll(TInt aAmount);
00882     TBool CheckCreateScroller();
00883     void CheckCreateScrollerL();
00884     void ResetItemArray();
00885     void CreateItemArrayL();
00886     void SetVScrollBarFlag();
00887     TInt TopHighlightGap() const;
00888     TInt BottomHighlightGap() const;
00889     TInt EvaluateMaxIconWidth() const;
00890     void CreateIconFromResourceL(TResourceReader& aReader, CEikMenuPaneItem& aItem) const;
00891     // new for AVKON
00892     void AnimateMenuPane(const TPoint& aNewPos);
00893 
00894     // To make layout correct
00895     TRect ListMenuPane() const;
00896     TRect PopupMenuWindow() const;
00897     TRect PopupSubmenuWindow() const;
00898 
00899     // Skin support for menu
00900     void UpdateBackgroundContext(const TRect& aWindowRect);
00901 
00902     // Support method for highlight animation
00903     void RepaintHighlight() const;
00904 
00905 private: // from CCoeControl
00906     IMPORT_C void Reserved_1();
00907     IMPORT_C void Reserved_2();
00908 
00909 private : // new functions
00910     void LoadCascadeBitmapL() ;
00911 
00912     // Support for check mark, from v3.0
00913     void LoadCheckMarkBitmapL();
00914     TBool MenuHasCheckBoxOn() const;
00915     // Support for radio button, from v3.0
00916     void LoadRadioButtonBitmapL();
00917     TBool IsItemMemberOfRadioButtonGroup(TInt aItem) const ;
00918     // for drawing,from v3.0
00919     TBool MenuHasIcon() const;
00920 
00921     TRect CalculateSizeAndPositionScalable( const TRect& aWindowRect, TInt aNumItemsInPane ) ;
00922     TRect HighlightRect() const;
00923     void PrepareHighlightFrame() const;
00924     void SetCascadedIconSize() const;
00925 
00926     // fixes marquee flickering
00927     friend class CAknMarqueeControl;
00928     static TInt RedrawMarqueeEvent( TAny* aControl );
00929     
00930     CEikMenuPaneExtension* Extension() const;
00931 
00932 protected: // from CoeControl
00933 
00948     IMPORT_C TTypeUid::Ptr MopSupplyObject(TTypeUid aId);
00949 
00950 public: // From CoeControl.
00951     
00963     IMPORT_C TInt CountComponentControls() const;
00964     
00979     IMPORT_C CCoeControl* ComponentControl(TInt aIndex) const;
00980     
00981 protected: // new functions
00982     
00989     void DisableAnimation();
00990     
00999     void SetPositionToBeForced(TBool aForced);
01000     
01006     TInt NumberOfItemsThatFitInView() const;
01007     
01008     
01009 private: // data
01010     friend class CEikMenuButton;
01011     MEikMenuObserver* iMenuObserver;
01012     MEikMenuObserver* iEditMenuObserver;
01013     CEikMenuPane* iCascadeMenuPane;
01014     const CEikMenuPaneTitle* iMenuPaneTitle;
01015     const CEikHotKeyTable* iHotKeyTable;
01016     CEikMenuPane* iOwner;
01017     CItemArray* iItemArray;
01018     TBool iArrayOwnedExternally;
01019     TBool iAllowPointerUpEvents;
01020     TInt iNumberOfDragEvents;
01021     TInt iSelectedItem;
01022     TInt iItemHeight;
01023     TInt iBaseLine;
01024     TInt iHotkeyColWidth;
01025     TInt iFlags;
01026     CEikScrollBarFrame* iSBFrame;
01027     CMenuScroller* iScroller;
01028     CEikButtonBase* iLaunchingButton; // for popouts only
01029     TInt iSubPopupWidth; // 0..2
01030     TBool iEnableAnimation;
01031     CEikMenuPaneExtension* iExtension ;  // iSpare used for extension class pointer.
01032 
01033     };
01034 
01035 #endif
01036 

Copyright © Nokia Corporation 2001-2008
Back to top