AknToolbar.h

Go to the documentation of this file.
00001 /*
00002 * ==============================================================================
00003 *  Name        : AknToolbar.h
00004 *  Part of     : UI Framework / Avkon
00005 *  Interface   : SDK, Toolbar API
00006 *  Description : Popup toolbar component
00007 *  Version     : %version: e003sa02#47.1.1 %
00008 *
00009 *  Copyright (c) 2005-2007 Nokia Corporation.
00010 *  This material, including documentation and any related 
00011 *  computer programs, is protected by copyright controlled by 
00012 *  Nokia Corporation. All rights are reserved. Copying, 
00013 *  including reproducing, storing, adapting or translating, any 
00014 *  or all of this material requires the prior written consent of 
00015 *  Nokia Corporation. This material also contains confidential 
00016 *  information which may not be disclosed to others without the 
00017 *  prior written consent of Nokia Corporation.
00018 * ==============================================================================
00019 */
00020 
00021 
00022 #ifndef __AKNTOOLBAR_H__
00023 #define __AKNTOOLBAR_H__
00024 
00025 //  INCLUDES
00026 #include <avkon.hrh> // TAknOrientation
00027 #include <akncontrol.h> // CCoeControl
00028 #include <coecobs.h>    // MCoeControlObserver
00029 #include <eikcmobs.h>   // MEikCommandObserver
00030 #include <aknpopupfader.h>
00031 #include <babitflags.h>
00032 
00033 // FORWARD DECLARATIONS
00034 class CAknButton;
00035 class CAknToolbarItem;
00036 class CAknToolbarExtension;
00037 class MAknToolbarObserver;
00038 class CEikButtonGroupContainer;
00039 class TAknWindowComponentLayout;
00040 class CAknsFrameBackgroundControlContext;
00041 class CAknsBasicBackgroundControlContext;
00042 
00043 
00044 // DisableToolbarL leaves with this value if toolbar is shown, since toolbar
00045 // should not be shown when disabling/enabling toolbar. 
00046 const TInt KErrToolbarShown = -101;   
00047 
00048 // CLASS DECLARATION
00049 
00056 class CAknToolbar : public CAknControl, public MCoeControlObserver, 
00057     public MCoeControlBackground, public MEikCommandObserver, 
00058     public MAknFadedComponent
00059     {
00060     public: //Enumerations: 
00061 
00062     enum TEventModifiers {
00063         ELongPress = 1,
00064         ELongPressEnded = 2,
00065     };
00066 
00067     public: // Constructors and destructor
00068 
00075         IMPORT_C static CAknToolbar* NewL( const TInt aResourceId );
00076 
00083         IMPORT_C static CAknToolbar* NewLC( const TInt aResourceId );
00084 
00088         ~CAknToolbar();
00089 
00090     public: // From base class
00091 
00098          IMPORT_C TInt CountComponentControls() const;
00099 
00107         IMPORT_C CCoeControl* ComponentControl( TInt aIndex ) const ;
00108 
00115         IMPORT_C void HandlePointerEventL( const TPointerEvent& aPointerEvent );
00116 
00123         IMPORT_C void HandleResourceChange( TInt aType );
00124 
00132         IMPORT_C void HandleControlEventL( CCoeControl* aControl, 
00133                                            TCoeEvent aEventType );
00134 
00139         IMPORT_C void PositionChanged();
00140 
00147         IMPORT_C void ProcessCommandL( TInt aCommandId );
00148 
00156         IMPORT_C void SetDimmed( TBool aDimmed );
00157 
00168         IMPORT_C TKeyResponse OfferKeyEventL( const TKeyEvent& aKeyEvent,
00169                                               TEventCode aType );
00170 
00177         IMPORT_C TCoeInputCapabilities InputCapabilities() const;
00178 
00189         IMPORT_C void Draw( CWindowGc& aGc,
00190                             const CCoeControl& aControl,
00191                             const TRect& aRect ) const;
00192 
00193     public: // New functions
00194 
00202         IMPORT_C CCoeControl* ControlOrNull( const TInt aControlId ) const;
00203 
00210         IMPORT_C void SetToolbarVisibility( const TBool aVisible );
00211 
00219         IMPORT_C void SetToolbarVisibility( const TBool aVisible, 
00220                                             const TBool aFocusing );
00221 
00232         IMPORT_C void SetItemDimmed( const TInt aCommandId,
00233                                      const TBool aDimmed,
00234                                      const TBool aDrawNow );
00235 
00246         IMPORT_C void HideItem( const TInt aCommandId,
00247                                 const TBool aHide,
00248                                 const TBool aDrawNow );
00249 
00255         IMPORT_C void SetToolbarObserver( MAknToolbarObserver* aObserver );
00256 
00262         IMPORT_C MAknToolbarObserver* ToolbarObserver();
00263 
00274         IMPORT_C void AddItemL( CCoeControl* aItem, 
00275                                 const TInt aType, 
00276                                 const TInt aCommandId, 
00277                                 const TInt aFlags );
00278 
00290         IMPORT_C void AddItemL( CCoeControl* aItem,
00291                                 const TInt aType,
00292                                 const TInt aCommandId,
00293                                 const TInt aFlags,
00294                                 const TInt aIndex );
00295 
00301         IMPORT_C void RemoveItem( const TInt aCommandId );
00302 
00309         IMPORT_C TBool IsSupportedItemType( const TInt aType ) const;
00310 
00319         IMPORT_C void SetInitialFocusedItem( const TInt aCommandId );
00320 
00327         IMPORT_C void SetEmphasis( const TBool aEmphasis );
00328 
00334         IMPORT_C TBool IsShown() const;
00335 
00342         IMPORT_C void SetWithSliding( const TBool aSlide );
00343 
00351         IMPORT_C void SetCloseOnCommand( const TInt aCommandId,
00352                                          const TBool aClose );
00353 
00360         IMPORT_C void SetCloseOnAllCommands( const TBool aClose );
00361         
00368         IMPORT_C void SetOrientation( const TAknOrientation aOrientation );
00369         
00374         IMPORT_C void UpdateBackground();
00375          
00382         void ShowToolbarForBackgroundUpdate(); 
00383         
00394         IMPORT_C void DisableToolbarL( TBool aDisable ); 
00395 
00403         IMPORT_C TBool IsToolbarDisabled() const; 
00404         
00413         IMPORT_C void SetFocusedItemL( const TInt aCommandId ); 
00414 
00423         IMPORT_C TInt FocusedItem() const; 
00424 
00432         void PrepareForFocusLossL(); 
00433 
00443         IMPORT_C TInt EventModifiers() const; 
00444 
00450         IMPORT_C TInt ToolbarFlags() const; 
00451 
00452         /*
00453          * Count faded components
00454          * @return then number of faded components
00455          */
00456         TInt CountFadedComponents(); 
00457 
00458         /*
00459          * Returns faded components by index
00460          * @return faded component
00461          */
00462         CCoeControl* FadedComponent( TInt aIndex ); 
00463 
00464         /*
00465          * Reduces main pane rect if it intersects with toolbar's rect
00466          * @param aBoundingRect the rect to reduce
00467          */
00468         void ReduceRect( TRect& aBoundingRect ) const; 
00469 
00477         IMPORT_C void SetSoftkeyResourceIdL( TInt aSoftkeyResourceId ); 
00478 
00483         void ExtensionEventL( TInt aCommandId ); 
00484 
00492         TInt ToolbarVisibleIndexByControl( const CCoeControl* aControl ) const;
00493 
00498         IMPORT_C CAknToolbarExtension* ToolbarExtension() const;                
00499 
00504         void DynInitExtensionL( CCoeControl* aControl ); 
00505 
00509         static TInt ReadyToSlide( TAny* aThis ); 
00510 
00514         void SlideWithIdle(); 
00515 
00525         IMPORT_C void HideItemsAndDrawOnlyBackground( TBool aHide ); 
00526 
00542         IMPORT_C void HideItemsAndDrawOnlyBackground( TBool aHide, TInt aPriority ); 
00543 
00544 
00545     protected: // From base class
00546 
00552         IMPORT_C void SizeChanged();
00553 
00560         IMPORT_C void FocusChanged( TDrawNow aDrawNow );
00561 
00568         IMPORT_C void* ExtensionInterface( TUid aInterface );
00569 
00578         IMPORT_C TTypeUid::Ptr MopSupplyObject( TTypeUid aId );
00579 
00580     private: // Constructors
00581 
00585         CAknToolbar();
00586 
00590         void ConstructL();
00591 
00592     private: // From base class
00593 
00602         IMPORT_C void ConstructFromResourceL( TResourceReader& aReader );
00603 
00611         IMPORT_C void Draw( const TRect& aRect ) const;
00612 
00613     private: // New functions
00614 
00620         void ConstructFromResourceL( const TInt aResourceId );
00621 
00629         CAknToolbarItem* ConstructControlLC( TResourceReader& aReader );
00630 
00637         TRect CalculateSizeAndPosition();
00638 
00648         void CalculateRects( TRect& aMainPaneRect, TRect& aToolbarRect,
00649             TRect& aGridPaneRect, TRect& aCellPaneRect );
00650 
00658         TRect CalculateControlRect( TRect& aCurrentCellPaneRect ); 
00659 
00668         TBool TooFewItemsVisible(); 
00669 
00676         CAknToolbarItem* ToolbarItemByControl( const CCoeControl* aControl ) const;
00677 
00684         CAknToolbarItem* ToolbarItemById( const TInt aId ) const;
00685 
00692         TInt ToolbarItemIndexById( const TInt aId ) const;
00693 
00700         TInt ToolbarItemIndexByControl( const CCoeControl* aControl ) const;
00701 
00709         TInt ToolbarVisibleIndexById( const TInt aId ) const;  
00710 
00717         void SlideToolbar( const TPoint& aEndPos );
00718 
00722         void SetRightCbaTextL();
00723 
00733         TInt GetNextSelectableItemIndex( TInt aStartIndex,
00734                                         TBool aMoveForward );
00735 
00747         void MoveHighlightL( TInt aItemIndex,
00748                               const TBool aDrawNow,
00749                               const TBool aMoveForward = ETrue,
00750                               const TBool aPrepareControl = ETrue );
00751 
00757         void ShowToolbarL();
00758 
00762         void HideToolbarL();
00763 
00770         void InitFocusedItemL( const TBool aDrawNow );
00771 
00776         void SetShown( const TBool aShown );
00777 
00781         void SelectItemL( const TInt aIndex, const TBool aSelect );
00782 
00786         TRect RectFromLayout( const TRect& aParent,
00787             const TAknWindowComponentLayout& aComponentLayout ) const;
00788         
00792         static TInt WaitForScreenSwitch(TAny* aThis); 
00793 
00798         void HideToolbarForBackgroundUpdate(); 
00799         
00803         void UpdateControlPositions();
00804 
00810         void ShowViaIdle();
00811         
00815         static TInt ShowDelayedToolbar( TAny* aThis );
00816 
00821         void ModifyHighlightMaskL( TBool aCreateBitmaps );
00822 
00827         void FadeBehindPopup( TBool aFade ); 
00828 
00832         void CheckHitAreas( ); 
00833 
00838         void CheckFixedToolbarButtonsL();
00839 
00846         void DrawFixedBackgroundL( CWindowGc& aGc, 
00847                                    const CCoeControl& aControl, 
00848                                    const TRect& aRect ) const;
00849                                    
00853         void AdjustButton( CAknButton& aButton );
00854         
00858         void AdjustAllButtons();
00859         
00864         void SetOrdinalPositions() const;
00865 
00870         void UpdateControlVisibility();
00871         
00872     private: // Member variables
00873 
00874         // Array for toolbar items
00875         RPointerArray<CAknToolbarItem> iItems;
00876 
00877         // Array for visible toolbar items
00878         RPointerArray<CAknToolbarItem> iVisibleItems;
00879 
00880         // Toolbar flags
00881         TInt iFlags;
00882 
00883         // Observer to report toolbar item events, not owned
00884         MAknToolbarObserver* iToolbarObserver;
00885 
00886         // Index of focused item, used with focusable toolbar
00887         TInt iFocusedItem;
00888 
00889         // Index of selected item, used with focusable and non-focusable toolbar
00890         TInt iSelectedItem;
00891 
00892         // Toolbar cba, used with focusable toolbar
00893         // own
00894         CEikButtonGroupContainer* iToolbarCba;
00895 
00896         // Resource id for toolbar
00897         TInt iToolbarResourceId;
00898 
00899         // The default focused item
00900         TInt iInitialFocusedItem;
00901 
00902         // Last focused item before focus was lost
00903         TInt iLastFocusedItem;
00904 
00905         // Toolbar frame context
00906         // own
00907         CAknsFrameBackgroundControlContext* iFrameContext;
00908 
00909         // Toolbar background context
00910         // own
00911         CAknsBasicBackgroundControlContext* iBgContext;
00912         
00913         // Toolbar orientation
00914         TAknOrientation iOrientation;
00915         
00916         // Transparency bitmap
00917         // own
00918         CFbsBitmap* iBgBitmap;
00919 
00920         // This is used to call ShowToolbarForBackgroundChange after toolbar has
00921         // been hidden 
00922         // own
00923         CIdle* iIdle;
00924         
00925         // Highlight bitmap
00926         CFbsBitmap* iHighlightBitmap; 
00927 
00928         // Highlight mask 
00929         CFbsBitmap* iHighlightMask; 
00930         
00931         // event modifiers
00932         TInt iEventModifiers; 
00933         
00934             // Background fader
00935         TAknPopupFader iFader;
00936             
00937             // Softkey resource
00938         TInt iSoftkeyResource; 
00939             
00940         // Used to store previous item that had pointerevents
00941         TInt iPreviousItem;
00942 
00943             // Step for toolbar sliding
00944             TInt iStep; 
00945 
00946             // End position for toolbar sliding 
00947             TInt iEndPos;
00948             
00949             // Internal flags used to store toolbar's properties
00950             TBitFlags iInternalFlags;
00951             
00952             // Background area to be drawn when not enough visible items
00953             // to cover the toolbar area
00954             TRect iBgRect;
00955 
00956         // Toolbar window priority if set in HideItemsAndDrawOnlyBackground
00957             TInt iDrawingPriority;
00958 
00959     };
00960 
00961 #endif // __AKNTOOLBAR_H__
00962 
00963 // End of File

Copyright © Nokia Corporation 2001-2007
Back to top