williamr@2: /* williamr@2: * Copyright (c) 2005-2007 Nokia Corporation and/or its subsidiary(-ies). williamr@2: * All rights reserved. williamr@2: * This component and the accompanying materials are made available williamr@4: * under the terms of "Eclipse Public License v1.0" williamr@2: * which accompanies this distribution, and is available williamr@4: * at the URL "http://www.eclipse.org/legal/epl-v10.html". williamr@2: * williamr@2: * Initial Contributors: williamr@2: * Nokia Corporation - initial contribution. williamr@2: * williamr@2: * Contributors: williamr@2: * williamr@2: * Description: Popup toolbar component williamr@2: * williamr@2: */ williamr@2: williamr@2: williamr@2: williamr@2: #ifndef __AKNTOOLBAR_H__ williamr@2: #define __AKNTOOLBAR_H__ williamr@2: williamr@2: // INCLUDES williamr@2: #include <avkon.hrh> // TAknOrientation williamr@4: #include <AknControl.h> // CCoeControl williamr@2: #include <coecobs.h> // MCoeControlObserver williamr@2: #include <eikcmobs.h> // MEikCommandObserver williamr@4: #include <AknPopupFader.h> williamr@2: #include <babitflags.h> williamr@4: #include <AknsItemID.h> williamr@2: williamr@2: // FORWARD DECLARATIONS williamr@2: class CAknButton; williamr@2: class CAknToolbarItem; williamr@2: class CAknToolbarExtension; williamr@2: class MAknToolbarObserver; williamr@2: class CEikButtonGroupContainer; williamr@2: class TAknWindowComponentLayout; williamr@2: class CAknsFrameBackgroundControlContext; williamr@2: class CAknsBasicBackgroundControlContext; williamr@2: williamr@2: williamr@2: // DisableToolbarL leaves with this value if toolbar is shown, since toolbar williamr@2: // should not be shown when disabling/enabling toolbar. williamr@2: const TInt KErrToolbarShown = -101; williamr@2: williamr@2: // CLASS DECLARATION williamr@2: williamr@2: /** williamr@2: * The class to provide toolbar for the application williamr@2: * williamr@2: * @lib eikcoctl.lib williamr@2: * @since Series 60 3.1 williamr@2: */ williamr@2: class CAknToolbar : public CAknControl, public MCoeControlObserver, williamr@2: public MCoeControlBackground, public MEikCommandObserver, williamr@2: public MAknFadedComponent williamr@2: { williamr@2: public: //Enumerations: williamr@2: williamr@2: enum TEventModifiers { williamr@2: ELongPress = 1, williamr@2: ELongPressEnded = 2, williamr@2: }; williamr@2: williamr@2: public: // Constructors and destructor williamr@2: williamr@2: /** williamr@2: * Two-phased constructor. williamr@2: * williamr@2: * @param aResourceId The ID for this component's resource williamr@2: * @return Pointer to the created toolbar object williamr@2: */ williamr@2: IMPORT_C static CAknToolbar* NewL( const TInt aResourceId ); williamr@2: williamr@2: /** williamr@2: * Two-phased constructor. williamr@2: * williamr@2: * @param aResourceId The ID for this component's resource williamr@2: * @return Pointer to the created toolbar object williamr@2: */ williamr@2: IMPORT_C static CAknToolbar* NewLC( const TInt aResourceId ); williamr@2: williamr@2: /** williamr@2: * Destructor williamr@2: */ williamr@2: ~CAknToolbar(); williamr@2: williamr@2: public: // From base class williamr@2: williamr@2: /** williamr@2: * From CCoeControl. williamr@2: * Gets the number of controls contained in a compound control. williamr@2: * williamr@2: * @return The number of component controls contained by this control. williamr@2: */ williamr@2: IMPORT_C TInt CountComponentControls() const; williamr@2: williamr@2: /** williamr@2: * From CCoeControl. williamr@2: * Gets the specified component of a compound control. williamr@2: * williamr@2: * @param aIndex The index of the control to get williamr@2: * @return The component control with an index of aIndex. williamr@2: */ williamr@2: IMPORT_C CCoeControl* ComponentControl( TInt aIndex ) const ; williamr@2: williamr@2: /** williamr@2: * From CCoeControl. williamr@2: * Handles pointer events. williamr@2: * williamr@2: * @param aPointerEvent The pointer event. williamr@2: */ williamr@2: IMPORT_C void HandlePointerEventL( const TPointerEvent& aPointerEvent ); williamr@2: williamr@2: /** williamr@2: * From CCoeControl. williamr@2: * Handles a change to the control's resources. williamr@2: * williamr@2: * @param aType A message UID value. williamr@2: */ williamr@2: IMPORT_C void HandleResourceChange( TInt aType ); williamr@2: williamr@2: /** williamr@2: * From MCoeControlObserver. williamr@2: * Handles an event from an observed toolbar item. williamr@2: * williamr@2: * @param aControl The control which sent the event williamr@2: * @param aEventType The event type williamr@2: */ williamr@2: IMPORT_C void HandleControlEventL( CCoeControl* aControl, williamr@2: TCoeEvent aEventType ); williamr@2: williamr@2: /** williamr@2: * From CCoeControl. williamr@2: * Responds to changes in the position of a toolbar. williamr@2: */ williamr@2: IMPORT_C void PositionChanged(); williamr@2: williamr@2: /** williamr@2: * From MEikCommandObserver. williamr@2: * Processes user commands. williamr@2: * williamr@2: * @param TInt aCommandId ID of the command to respond to. williamr@2: */ williamr@2: IMPORT_C void ProcessCommandL( TInt aCommandId ); williamr@2: williamr@2: /** williamr@2: * From CCoeControl. williamr@2: * Sets toolbar dimmed. Doesn't redraw. williamr@2: * williamr@2: * @param aDimmed is ETrue to dim the toolbar, williamr@2: * EFalse to set the toolbar as not dimmed williamr@2: */ williamr@2: IMPORT_C void SetDimmed( TBool aDimmed ); williamr@2: williamr@2: /** williamr@2: * From CCoeControl. williamr@2: * Handles key events. williamr@2: * williamr@2: * @param aKeyEvent The key event williamr@2: * @param aType The type of key event: EEventKey, EEventKeyUp williamr@2: * or EEventKeyDown. williamr@2: * @return TKeyResponse Indicates whether or not the key event was used williamr@2: * by this control. williamr@2: */ williamr@2: IMPORT_C TKeyResponse OfferKeyEventL( const TKeyEvent& aKeyEvent, williamr@2: TEventCode aType ); williamr@2: williamr@2: /** williamr@2: * From CCoeControl. williamr@2: * Gets the control's input capabilities. williamr@2: * williamr@2: * @return The control's input capabilities. williamr@2: */ williamr@2: IMPORT_C TCoeInputCapabilities InputCapabilities() const; williamr@2: williamr@2: /** williamr@2: * From MCoeControlBackground. williamr@2: * Draw the background for a given control. williamr@2: * The text drawer that shall be used to draw text on the specific williamr@2: * background can be fetched through the GetTextDrawer() method. williamr@2: * williamr@2: * @param aGc Graphics context used for drawing. williamr@2: * @param aControl The control being drawn (may be a child of the drawer). williamr@2: * @param aRect The area to be redrawn. williamr@2: */ williamr@2: IMPORT_C void Draw( CWindowGc& aGc, williamr@2: const CCoeControl& aControl, williamr@2: const TRect& aRect ) const; williamr@2: williamr@2: public: // New functions williamr@2: williamr@2: /** williamr@2: * Gets a pointer to the specified control. williamr@2: * williamr@2: * @param aControlId The ID of the control for which a pointer is williamr@2: * required. williamr@2: * @return Pointer to the control with the specified ID. williamr@2: */ williamr@2: IMPORT_C CCoeControl* ControlOrNull( const TInt aControlId ) const; williamr@2: williamr@2: /** williamr@2: * Shows or hides toolbar. Position of the top left corner should be set williamr@2: * in advance. Toolbar set visible with this method is by default focusing. williamr@2: * Does nothing if toolbar is disabled. williamr@2: * @param aVisible ETrue to show it, EFalse to hide it. williamr@2: */ williamr@2: IMPORT_C void SetToolbarVisibility( const TBool aVisible ); williamr@2: williamr@2: /** williamr@2: * Shows or hides toolbar. Position of the top left corner should be set williamr@2: * in advance. This overload of the method allows toolbar to be set williamr@2: * non-focusing. Does nothing if toolbar is disabled. williamr@2: * @param aVisible ETrue to show it, EFalse to hide it. williamr@2: * @param aFocusing ETrue to set toolbar focusing, otherwise EFalse. williamr@2: */ williamr@2: IMPORT_C void SetToolbarVisibility( const TBool aVisible, williamr@2: const TBool aFocusing ); williamr@2: williamr@2: /** williamr@2: * Dims (greys out) or undims a toolbar item. williamr@2: * williamr@2: * @param aCommandId The command (as defined in an .hrh file) williamr@2: * associated with this toolbar item. This identifies the toolbar williamr@2: * item, whose text is to be dimmed or un-dimmed. williamr@2: * @param aDimmed Use ETrue to dim this toolbar item or EFalse to williamr@2: * un-dim this toolbar item. williamr@2: * @param aDrawNow Should be ETrue for the item to be redrawn. williamr@2: */ williamr@2: IMPORT_C void SetItemDimmed( const TInt aCommandId, williamr@2: const TBool aDimmed, williamr@2: const TBool aDrawNow ); williamr@2: williamr@2: /** williamr@2: * Hides or unhides a toolbar item. williamr@2: * williamr@2: * @param aCommandId The command (as defined in an .hrh file) williamr@2: * associated with this toolbar item. This identifies the toolbar williamr@2: * item, which will be set to hidden or unhidden. williamr@2: * @param aHide Use ETrue to hide this toolbar item or EFalse to williamr@2: * unhide this toolbar item. williamr@2: * @param aDrawNow Should be ETrue for the toolbar to be redrawn. williamr@2: */ williamr@2: IMPORT_C void HideItem( const TInt aCommandId, williamr@2: const TBool aHide, williamr@2: const TBool aDrawNow ); williamr@2: williamr@2: /** williamr@2: * Sets the observer for the toolbar. williamr@2: * williamr@2: * @param aObserver A pointer to the observer. Ownership is not changed. williamr@2: */ williamr@2: IMPORT_C void SetToolbarObserver( MAknToolbarObserver* aObserver ); williamr@2: williamr@2: /** williamr@2: * Returns a pointer to the toolbar observer. williamr@2: * williamr@2: * @return Pointer to the toolbar observer. williamr@2: */ williamr@2: IMPORT_C MAknToolbarObserver* ToolbarObserver(); williamr@2: williamr@2: /** williamr@2: * Adds one item to the end of the toolbar. Takes ownership. williamr@2: * Leaves with value KErrNotSupported, if the control type is not williamr@2: * supported by toolbar (see CAknToolbar::IsSupportedItemType()). williamr@2: * williamr@2: * @param aItem The control. williamr@2: * @param aType The type of the new toolbar item. williamr@2: * @param aCommandId The command ID for this item. williamr@2: * @param aFlags The flags. williamr@2: */ williamr@2: IMPORT_C void AddItemL( CCoeControl* aItem, williamr@2: const TInt aType, williamr@2: const TInt aCommandId, williamr@2: const TInt aFlags ); williamr@2: williamr@2: /** williamr@2: * Adds one item to the specified place. Takes ownership. williamr@2: * Leaves with value KErrNotSupported, if the control type is not williamr@2: * supported by toolbar (see CAknToolbar::IsSupportedItemType()). williamr@2: * williamr@2: * @param aItem The control. williamr@2: * @param aType The type of the new toolbar item. williamr@2: * @param aCommandId The command ID for this item. williamr@2: * @param aFlags The flags. williamr@2: * @param aIndex The index in array at which item should be added. williamr@2: */ williamr@2: IMPORT_C void AddItemL( CCoeControl* aItem, williamr@2: const TInt aType, williamr@2: const TInt aCommandId, williamr@2: const TInt aFlags, williamr@2: const TInt aIndex ); williamr@2: williamr@2: /** williamr@2: * Removes one item from the toolbar. williamr@2: * williamr@2: * @param aCommandId The ID of the item which should be removed. williamr@2: */ williamr@2: IMPORT_C void RemoveItem( const TInt aCommandId ); williamr@2: williamr@2: /** williamr@2: * Returns ETrue if the type of the item can be included in the williamr@2: * toolbar. williamr@2: * williamr@2: * @return ETrue for the supported type, otherwise EFalse. williamr@2: */ williamr@2: IMPORT_C TBool IsSupportedItemType( const TInt aType ) const; williamr@2: williamr@2: /** williamr@2: * Changes the command ID for the initially focused item when toolbar is williamr@2: * shown or gain focus. Notice that, if this item is not visible, then williamr@2: * focus will be according default behaviour. Normally, focus will be on williamr@2: * the first item, if KAknToolbarMiddleItemFocused flag was not used. williamr@2: * williamr@2: * @param aCommandId The command ID for the item to get focus. williamr@2: */ williamr@2: IMPORT_C void SetInitialFocusedItem( const TInt aCommandId ); williamr@2: williamr@2: /** williamr@2: * Called by the framework to handle the emphasising or williamr@2: * de-emphasising of a toolbar window when it is needed. williamr@2: * williamr@2: * @param aEmphasis ETrue to emphasize the menu, EFalse otherwise. williamr@2: */ williamr@2: IMPORT_C void SetEmphasis( const TBool aEmphasis ); williamr@2: williamr@2: /** williamr@2: * Returns toolbar visibility at this moment williamr@2: * williamr@2: * @return ETrue, if toolbar is shown. williamr@2: */ williamr@2: IMPORT_C TBool IsShown() const; williamr@2: williamr@2: /** williamr@2: * Specifies whether toolbar should be shown with sliding effect or not. williamr@2: * By default toolbar is shown with sliding. williamr@2: * williamr@2: * @param aSlide ETrue for sliding effect, EFalse without sliding. williamr@2: */ williamr@2: IMPORT_C void SetWithSliding( const TBool aSlide ); williamr@2: williamr@2: /** williamr@2: * Sets whether the toolbar should be closed or remain open after the williamr@2: * specified command is issued from the toolbar. williamr@2: * williamr@2: * @param aCommandId The command. williamr@2: * @param aClose ETrue, if toolbar should be close. williamr@2: */ williamr@2: IMPORT_C void SetCloseOnCommand( const TInt aCommandId, williamr@2: const TBool aClose ); williamr@2: williamr@2: /** williamr@2: * Sets whether the toolbar should be closed after a command is issued williamr@2: * from the toolbar. This method affects every command on the toolbar. williamr@2: * williamr@2: * @param aClose ETrue, if toolbar should be closed. williamr@2: */ williamr@2: IMPORT_C void SetCloseOnAllCommands( const TBool aClose ); williamr@2: williamr@2: /** williamr@2: * Sets toolbar orientation. williamr@2: * williamr@2: * @param aOrientation Orientation that should be used for toolbar. williamr@2: * @since 3.2 williamr@2: */ williamr@2: IMPORT_C void SetOrientation( const TAknOrientation aOrientation ); williamr@2: williamr@2: /** williamr@2: * Updates transparent toolbar's background. williamr@2: * @since 3.2 williamr@2: */ williamr@2: IMPORT_C void UpdateBackground(); williamr@2: williamr@2: /** williamr@2: * Shows toolbar again after it has been hidden for background changing williamr@2: * purposes williamr@2: * williamr@2: * @since 3.2 williamr@2: */ williamr@2: void ShowToolbarForBackgroundUpdate(); williamr@2: williamr@2: /** williamr@2: * Disables/Enables toolbar so that it cannot/can be activated from e.g. williamr@2: * touch pane. Needed especially if a dialog is on the screen and williamr@2: * toolbar is not wished to be shown. Leaves with value KErrToolbarShown williamr@2: * if called when toolbar is shown. williamr@2: * williamr@2: * @param aDisable ETrue if toolbar should be disabled williamr@2: * williamr@2: * @since S60 3.2 williamr@2: */ williamr@2: IMPORT_C void DisableToolbarL( TBool aDisable ); williamr@2: williamr@2: /** williamr@2: * Checks if toolbar is disabled. williamr@2: * williamr@2: * @return ETrue if toolbar is disabled, EFalse if not williamr@2: * williamr@2: * @since S60 3.2 williamr@2: */ williamr@2: IMPORT_C TBool IsToolbarDisabled() const; williamr@2: williamr@2: /** williamr@2: * Moves highlight from one item to another. Leaves with williamr@2: * value KErrNotFound if item not found. williamr@2: * williamr@2: * @param aCommandId command id of the item to be focused. williamr@2: * williamr@2: * @since S60 3.2 williamr@2: */ williamr@2: IMPORT_C void SetFocusedItemL( const TInt aCommandId ); williamr@2: williamr@2: /** williamr@2: * Returns command id of focused item. williamr@2: * williamr@2: * @return command id of focused item. Returns KErrNotFound if williamr@2: * no item is focused. williamr@2: * williamr@2: * @since S60 3.2 williamr@2: */ williamr@2: IMPORT_C TInt FocusedItem() const; williamr@2: williamr@2: /** williamr@2: * Takes focus away from edwin or other controls if needed. Called by williamr@2: * AknAppUi from HandleWsEventL when a pointer event is targeted to williamr@2: * other control than toolbar. williamr@2: * williamr@2: * @since S60 3.2 williamr@2: */ williamr@2: void PrepareForFocusLossL(); williamr@2: williamr@2: /** williamr@2: * Returns event modifiers defined in TEventModifiers in this header. williamr@2: * This can be used by applications in OfferToolbarEventL to know if williamr@2: * the event sent was for example a long press event. Information is williamr@2: * valid only during OfferToolbarEventL. williamr@2: * williamr@2: * @return event modifiers williamr@2: * @since S60 3.2 williamr@2: */ williamr@2: IMPORT_C TInt EventModifiers() const; williamr@2: williamr@2: /** williamr@2: * Returns the flags of toolbar. Flags are defined in eikon.hrh. williamr@2: * @return toolbar flags williamr@2: * @since S60 3.2 williamr@2: */ williamr@2: IMPORT_C TInt ToolbarFlags() const; williamr@2: williamr@2: /* williamr@2: * Count faded components williamr@2: * @return then number of faded components williamr@2: */ williamr@2: TInt CountFadedComponents(); williamr@2: williamr@2: /* williamr@2: * Returns faded components by index williamr@2: * @return faded component williamr@2: */ williamr@2: CCoeControl* FadedComponent( TInt aIndex ); williamr@2: williamr@2: /* williamr@2: * Reduces main pane rect if it intersects with toolbar's rect williamr@2: * @param aBoundingRect the rect to reduce williamr@2: */ williamr@2: void ReduceRect( TRect& aBoundingRect ) const; williamr@2: williamr@2: /** williamr@2: * Sets the resource id for toolbar softkeys. If cba allready exists williamr@2: * then changes the existing softkeys and redraws toolbar cba. williamr@2: * @param aSoftkeyResourceId ID of the resource structure specifying williamr@2: * the command buttons. williamr@2: * @since S60 3.2 williamr@2: */ williamr@2: IMPORT_C void SetSoftkeyResourceIdL( TInt aSoftkeyResourceId ); williamr@2: williamr@2: /** williamr@2: * Extension notifies of its events using this method williamr@2: * aCommandId command id of the button williamr@2: */ williamr@2: void ExtensionEventL( TInt aCommandId ); williamr@2: williamr@2: /** williamr@2: * Returns the index of the toolbar item inside of the iVisibleItems williamr@2: * array. williamr@2: * williamr@2: * @param aControl The control which index is needed. williamr@2: * @return Index of the toolbar item. williamr@2: */ williamr@2: TInt ToolbarVisibleIndexByControl( const CCoeControl* aControl ) const; williamr@2: williamr@2: /** williamr@2: * Returns pointer to toolbar extension if available williamr@2: * @return toolbar extension or NULL williamr@2: */ williamr@2: IMPORT_C CAknToolbarExtension* ToolbarExtension() const; williamr@2: williamr@2: /** williamr@2: * Calls DynInitToolbar with extensions commmand id williamr@2: * williamr@2: */ williamr@2: void DynInitExtensionL( CCoeControl* aControl ); williamr@2: williamr@2: /** williamr@2: * Callback for sliding toolbar. williamr@2: */ williamr@2: static TInt ReadyToSlide( TAny* aThis ); williamr@2: williamr@2: /** williamr@2: * Slide toolbar williamr@2: */ williamr@2: void SlideWithIdle(); williamr@2: williamr@2: /** williamr@2: * Hides/Unhides toolbar items temporarily. When called with ETrue williamr@2: * toolbar draws just background in landscape and is hidden in portrait. williamr@2: * Calling with EFalse returns the situation to normal, so drawing the williamr@2: * items normally in portrait and landscape. Use this method only with williamr@2: * fixed toolbar! williamr@2: * williamr@2: * @param aHide ETrue if hiding items, EFalse if unhiding. williamr@2: */ williamr@2: IMPORT_C void HideItemsAndDrawOnlyBackground( TBool aHide ); williamr@2: williamr@2: /** williamr@2: * Hides/Unhides toolbar items temporarily. When called with ETrue williamr@2: * toolbar draws just background in landscape and is hidden in portrait. williamr@2: * Toolbar window priority is changed to priority passed in parameter. williamr@2: * Priority should be one of the window priority values defined in williamr@2: * TCoeWinPriority. Default priority is ECoeWinPriorityLow. williamr@2: * Note that if toolbar is already hidden, the toolbar window priority williamr@2: * is still changed to priority passed in parameter. williamr@2: * Calling the function HideItemsAndDrawOnlyBackground with EFalse returns williamr@2: * the situation to normal, so drawing the items normally in portrait williamr@2: * and landscape. Use this method only with fixed toolbar! williamr@2: * williamr@2: * @param aHide ETrue if hiding items, EFalse if unhiding. williamr@2: * @param aPriority Ordinal priority of toolbar window. williamr@2: */ williamr@2: IMPORT_C void HideItemsAndDrawOnlyBackground( TBool aHide, TInt aPriority ); williamr@4: /** williamr@4: * Sets the skin background for fixed toolbar. The new background is used williamr@4: * for all the subsequent drawing operations. This method does not itself williamr@4: * cause a repaint. williamr@4: * williamr@4: * @internal williamr@4: * williamr@4: * @param aIID Skin item ID of the new background. This is one of the constants williamr@4: * defined in AknsConstants.h, and the usual values are KAknsIIDQsnBgScreen williamr@4: * @since S60 5.0 williamr@4: */ williamr@4: IMPORT_C void SetSkinBackgroundId( const TAknsItemID& aIID ); williamr@2: williamr@2: williamr@2: protected: // From base class williamr@2: williamr@2: /** williamr@2: * From CCoeControl. williamr@2: * Responds to size changes to sets the size and position of williamr@2: * the contents of this control. williamr@2: */ williamr@2: IMPORT_C void SizeChanged(); williamr@2: williamr@2: /** williamr@2: * From CCoeControl. williamr@2: * This function is called whenever a control gains or loses focus. williamr@2: * williamr@2: * @param aDrawNow Contains the value that was passed to it by SetFocus(). williamr@2: */ williamr@2: IMPORT_C void FocusChanged( TDrawNow aDrawNow ); williamr@2: williamr@2: /** williamr@2: * From CAknControl. williamr@2: * For future extensions. williamr@2: * williamr@2: * @param aInterface The ID for the extension interface. williamr@2: */ williamr@2: IMPORT_C void* ExtensionInterface( TUid aInterface ); williamr@2: williamr@2: /** williamr@2: * From CCoeControl. williamr@2: * Retrieves an object of the same type as that encapsulated in aId. williamr@2: * williamr@2: * @param aId An encapsulated object type ID. williamr@2: * @return Encapsulated pointer to the object provided. williamr@2: * Note that the encapsulated pointer may be NULL. williamr@2: */ williamr@2: IMPORT_C TTypeUid::Ptr MopSupplyObject( TTypeUid aId ); williamr@2: williamr@2: private: // Constructors williamr@2: williamr@2: /** williamr@2: * C++ default constructor. williamr@2: */ williamr@2: CAknToolbar(); williamr@2: williamr@2: /** williamr@2: * Symbian 2nd phase constructor. williamr@2: */ williamr@2: void ConstructL(); williamr@2: williamr@2: private: // From base class williamr@2: williamr@2: /** williamr@2: * From CCoeControl. williamr@2: * Constructs controls from a resource file. williamr@2: * Hides the one defined in base class. williamr@2: * williamr@2: * @param aReader The resource reader with which to access williamr@2: * the control's resource values. williamr@2: */ williamr@2: IMPORT_C void ConstructFromResourceL( TResourceReader& aReader ); williamr@2: williamr@2: /** williamr@2: * From CCoeControl. williamr@2: * Draw a control called by window server. williamr@2: * williamr@2: * @param aRect The region of the control to be redrawn. williamr@2: * Co-ordinates are relative to the control's origin (top left corner). williamr@2: */ williamr@2: IMPORT_C void Draw( const TRect& aRect ) const; williamr@2: williamr@2: private: // New functions williamr@2: williamr@2: /** williamr@2: * Constructs controls from a resource file. williamr@2: * williamr@2: * @param aResourceId The ID for this component's resource. williamr@2: */ williamr@2: void ConstructFromResourceL( const TInt aResourceId ); williamr@2: williamr@2: /** williamr@2: * Constructs one of the toolbar items. williamr@2: * williamr@2: * @param aReader The resource reader with which to access the control's williamr@2: * resource values. williamr@2: * @return Constructed toolbar item. williamr@2: */ williamr@2: CAknToolbarItem* ConstructControlLC( TResourceReader& aReader ); williamr@2: williamr@2: /** williamr@2: * Calculates size and position of the toolbar depending on the williamr@2: * number and size of the toolbar items. williamr@2: * williamr@2: * @return Toolbar rectangular. williamr@2: */ williamr@2: TRect CalculateSizeAndPosition(); williamr@2: williamr@2: /** williamr@2: * Calculates rects that are used in calculating the size williamr@2: * and position of the toolbar items williamr@2: * williamr@2: * @param aMainPaneRect main pane rect williamr@2: * @param aToolbarRect rect for toolbar williamr@2: * @param aGridPaneRect rect for grid pane williamr@2: * @param aCellPaneRect rect for cell pane williamr@2: */ williamr@2: void CalculateRects( TRect& aMainPaneRect, TRect& aToolbarRect, williamr@2: TRect& aGridPaneRect, TRect& aCellPaneRect ); williamr@2: williamr@2: /** williamr@2: * Calculates the position and size of the control rect williamr@2: * williamr@2: * @param aCurrentCellPaneRect current cell pane rect is needed to williamr@2: * get correct control rect from layout data. williamr@2: * @return control rect for the toolbar item williamr@2: */ williamr@2: TRect CalculateControlRect( TRect& aCurrentCellPaneRect ); williamr@2: williamr@2: /** williamr@2: * Checks the number of visible items, and if too few the toolbar CBA is williamr@2: * deleted. If last time there were too few items then toolbar CBA is williamr@2: * created again. Also the ordinal position of the toolbar is set if williamr@2: * there are changes to previous situation. williamr@2: * williamr@2: * @return ETrue if too few items are visible, EFalse if not williamr@2: */ williamr@2: TBool TooFewItemsVisible(); williamr@2: williamr@2: /** williamr@2: * Returns toolbar item object for the specified control. williamr@2: * williamr@2: * @param aControl Pointer to the control. williamr@2: * @return Pointer to the toolbar item. williamr@2: */ williamr@2: CAknToolbarItem* ToolbarItemByControl( const CCoeControl* aControl ) const; williamr@2: williamr@2: /** williamr@2: * Returns toolbar item object for the specified command ID. williamr@2: * williamr@2: * @param aId The command ID of the item. williamr@2: * @return Pointer to the toolbar item. williamr@2: */ williamr@2: CAknToolbarItem* ToolbarItemById( const TInt aId ) const; williamr@2: williamr@2: /** williamr@2: * Returns the index of the toolbar item inside of the iItems array. williamr@2: * williamr@2: * @param aId The command ID of the item williamr@2: * @return Index of the toolbar item. williamr@2: */ williamr@2: TInt ToolbarItemIndexById( const TInt aId ) const; williamr@2: williamr@2: /** williamr@2: * Returns the index of the toolbar item inside of the iItems array. williamr@2: * williamr@2: * @param aControl The control which index is needed. williamr@2: * @return Index of the toolbar item. williamr@2: */ williamr@2: TInt ToolbarItemIndexByControl( const CCoeControl* aControl ) const; williamr@2: williamr@2: /** williamr@2: * Returns the index of the toolbar item inside of the iVisibleItems williamr@2: * array. williamr@2: * williamr@2: * @param aId The command ID of the item. williamr@2: * @return Index of the toolbar item. williamr@2: */ williamr@2: TInt ToolbarVisibleIndexById( const TInt aId ) const; williamr@2: williamr@2: /** williamr@2: * Draws toolbar with sliding effect. williamr@2: * williamr@2: * @param aEndPos The position of the top left corner of toolbar at williamr@2: * the end of animation. williamr@2: */ williamr@2: void SlideToolbar( const TPoint& aEndPos ); williamr@2: williamr@2: /** williamr@2: * Changes CBA text if all items are dimmed. williamr@2: */ williamr@2: void SetRightCbaTextL(); williamr@2: williamr@2: /** williamr@2: * Returns next non-dimmed and non-hidden control index. williamr@2: * williamr@2: * @param aStartIndex The index of the item from which the search williamr@2: * should be started. williamr@2: * @param aMoveForward ETrue if search is done from lower index to williamr@2: * the higher one. williamr@2: * @return The index of next non-dimmed and non-hidden item. williamr@2: */ williamr@2: TInt GetNextSelectableItemIndex( TInt aStartIndex, williamr@2: TBool aMoveForward ); williamr@2: williamr@2: /** williamr@2: * Moves highlight from one item to another. It also will change williamr@2: * softkey text for the focused toolbar. williamr@2: * williamr@2: * @param aItemIndex The index for the newly focused item. williamr@2: * @param aDrawNow Specifies whether the item should be redrawn. williamr@2: * @param aMoveForward Specifies whether the next item in the array williamr@2: * should be selected when the item with aItemIndex is dimmed. williamr@2: * @param aPrepareControl Specifies whether PrepareForFocusLossL() or williamr@2: * PrepareForFocusGainL() functions should be called. williamr@2: */ williamr@2: void MoveHighlightL( TInt aItemIndex, williamr@2: const TBool aDrawNow, williamr@2: const TBool aMoveForward = ETrue, williamr@2: const TBool aPrepareControl = ETrue ); williamr@2: williamr@2: /** williamr@2: * Makes toolbar visible and activates it. Position of the top left williamr@2: * corner should be set in advance. Also use SetFocus() to specify williamr@2: * whether toolbar gets key events or not. williamr@2: */ williamr@2: void ShowToolbarL(); williamr@2: williamr@2: /** williamr@2: * Hides toolbar. williamr@2: */ williamr@2: void HideToolbarL(); williamr@2: williamr@2: /** williamr@2: * Sets the focus to the middle or the first item, depending on the williamr@2: * toolbar flags. williamr@2: * williamr@2: * @param aDrawNow if the newly focused item should be redrawn. williamr@2: */ williamr@2: void InitFocusedItemL( const TBool aDrawNow ); williamr@2: williamr@2: /** williamr@2: * Sets the flag to be on or off and also calls williamr@2: * CCoeControl::MakeVisible(). williamr@2: */ williamr@2: void SetShown( const TBool aShown ); williamr@2: williamr@2: /** williamr@2: * Selects/deselects the toolbar item at given index. williamr@2: */ williamr@2: void SelectItemL( const TInt aIndex, const TBool aSelect ); williamr@2: williamr@2: /** williamr@2: * Gets rect from layout data. williamr@2: */ williamr@2: TRect RectFromLayout( const TRect& aParent, williamr@2: const TAknWindowComponentLayout& aComponentLayout ) const; williamr@2: williamr@2: /** williamr@2: * Callback to get notified when ready to show toolbar again williamr@2: */ williamr@2: static TInt WaitForScreenSwitch(TAny* aThis); williamr@2: williamr@2: /** williamr@2: * Hides toolbar so that screen capture can be taken from the williamr@2: * background in order to update it. williamr@2: */ williamr@2: void HideToolbarForBackgroundUpdate(); williamr@2: williamr@2: /** williamr@2: * Updates control positions so that tooltips are positioned correctly williamr@2: */ williamr@2: void UpdateControlPositions(); williamr@2: williamr@2: /** williamr@2: * Shows toolbar via CIdle. As a result, toolbar's window priority is williamr@2: * setted after the application's container window. This places toolbar williamr@2: * to the right place in the window tree. williamr@2: */ williamr@2: void ShowViaIdle(); williamr@2: williamr@2: /** williamr@2: * Callback for delayed toolbar showing. williamr@2: */ williamr@2: static TInt ShowDelayedToolbar( TAny* aThis ); williamr@2: williamr@2: williamr@2: /** williamr@2: * Fades behind toolbar williamr@2: * @param aFade if ETrue then fade williamr@2: */ williamr@2: void FadeBehindPopup( TBool aFade ); williamr@2: williamr@2: /** williamr@2: * Sets buttons to check their touchable areas when tapped williamr@2: */ williamr@2: void CheckHitAreas( ); williamr@2: williamr@2: /** williamr@2: * Counts buttons of fixed tool bar and adds button(s) if needed williamr@2: * There has to bee at leas three buttons in fixed toolbar. williamr@2: */ williamr@2: void CheckFixedToolbarButtonsL(); williamr@2: williamr@2: /** williamr@2: * Draws backgrounds of fixed toolbar williamr@2: * @param aGc Graphics context used for drawing. williamr@2: * @param aControl The control being drawn (may be a child of the drawer). williamr@2: * @param aRect The area to be drawn. williamr@2: */ williamr@2: void DrawFixedBackgroundL( CWindowGc& aGc, williamr@2: const CCoeControl& aControl, williamr@2: const TRect& aRect ) const; williamr@2: williamr@2: /** williamr@2: * Adjusts button's properties depending on the toolbar's features. williamr@2: */ williamr@2: void AdjustButton( CAknButton& aButton ); williamr@2: williamr@2: /** williamr@2: * Adjusts all buttons' properties depending on the toolbar's features. williamr@2: */ williamr@2: void AdjustAllButtons(); williamr@2: williamr@2: /** williamr@2: * Adjusts toolbar's and overlying dialog's window positions so that williamr@2: * dialog is displayed on top of the toolbar. williamr@2: */ williamr@2: void SetOrdinalPositions() const; williamr@2: williamr@2: /** williamr@2: * Updates control visibility based on toolbar visibility and williamr@2: * buttons visibility inside toolbar. williamr@2: */ williamr@2: void UpdateControlVisibility(); williamr@2: williamr@4: /* williamr@4: * Update item tooltip position williamr@4: */ williamr@4: void UpdateItemTooltipPosition(); williamr@4: williamr@2: private: // Member variables williamr@2: williamr@2: // Array for toolbar items williamr@2: RPointerArray<CAknToolbarItem> iItems; williamr@2: williamr@2: // Array for visible toolbar items williamr@2: RPointerArray<CAknToolbarItem> iVisibleItems; williamr@2: williamr@2: // Toolbar flags williamr@2: TInt iFlags; williamr@2: williamr@2: // Observer to report toolbar item events, not owned williamr@2: MAknToolbarObserver* iToolbarObserver; williamr@2: williamr@2: // Index of focused item, used with focusable toolbar williamr@2: TInt iFocusedItem; williamr@2: williamr@2: // Index of selected item, used with focusable and non-focusable toolbar williamr@2: TInt iSelectedItem; williamr@2: williamr@2: // Toolbar cba, used with focusable toolbar williamr@2: // own williamr@2: CEikButtonGroupContainer* iToolbarCba; williamr@2: williamr@2: // Resource id for toolbar williamr@2: TInt iToolbarResourceId; williamr@2: williamr@2: // The default focused item williamr@2: TInt iInitialFocusedItem; williamr@2: williamr@2: // Last focused item before focus was lost williamr@2: TInt iLastFocusedItem; williamr@2: williamr@2: // Toolbar frame context williamr@2: // own williamr@2: CAknsFrameBackgroundControlContext* iFrameContext; williamr@2: williamr@2: // Toolbar background context williamr@2: // own williamr@2: CAknsBasicBackgroundControlContext* iBgContext; williamr@2: williamr@2: // Toolbar orientation williamr@2: TAknOrientation iOrientation; williamr@2: williamr@2: // Transparency bitmap williamr@2: // own williamr@4: // this member variable is deserted williamr@2: CFbsBitmap* iBgBitmap; williamr@2: williamr@2: // This is used to call ShowToolbarForBackgroundChange after toolbar has williamr@2: // been hidden williamr@2: // own williamr@2: CIdle* iIdle; williamr@2: williamr@2: // Highlight bitmap williamr@4: // this member variable is deserted williamr@2: CFbsBitmap* iHighlightBitmap; williamr@2: williamr@2: // Highlight mask williamr@4: // this member variable is deserted williamr@2: CFbsBitmap* iHighlightMask; williamr@2: williamr@2: // event modifiers williamr@2: TInt iEventModifiers; williamr@2: williamr@2: // Background fader williamr@2: TAknPopupFader iFader; williamr@2: williamr@2: // Softkey resource williamr@2: TInt iSoftkeyResource; williamr@2: williamr@2: // Used to store previous item that had pointerevents williamr@2: TInt iPreviousItem; williamr@2: williamr@4: // Item that catches point down event williamr@4: TInt iDownItem; williamr@4: williamr@2: // Step for toolbar sliding williamr@2: TInt iStep; williamr@2: williamr@2: // End position for toolbar sliding williamr@2: TInt iEndPos; williamr@2: williamr@2: // Internal flags used to store toolbar's properties williamr@2: TBitFlags iInternalFlags; williamr@2: williamr@2: // Background area to be drawn when not enough visible items williamr@2: // to cover the toolbar area williamr@2: TRect iBgRect; williamr@2: williamr@2: // Toolbar window priority if set in HideItemsAndDrawOnlyBackground williamr@2: TInt iDrawingPriority; williamr@2: williamr@4: /* williamr@4: * Background theme ID user defined. And in default, its value is williamr@4: * KAknsIIDNone is used and toolbar draw background with the current skin williamr@4: */ williamr@4: TAknsItemID iBgIID; williamr@2: }; williamr@2: williamr@2: #endif // __AKNTOOLBAR_H__ williamr@2: williamr@2: // End of File