williamr@4: /* williamr@4: * Copyright (c) 2002-2008 Nokia Corporation and/or its subsidiary(-ies). williamr@4: * All rights reserved. williamr@4: * This component and the accompanying materials are made available williamr@4: * under the terms of "Eclipse Public License v1.0" williamr@4: * which accompanies this distribution, and is available williamr@4: * at the URL "http://www.eclipse.org/legal/epl-v10.html". williamr@4: * williamr@4: * Initial Contributors: williamr@4: * Nokia Corporation - initial contribution. williamr@4: * williamr@4: * Contributors: williamr@4: * williamr@4: * Description: A default control in the status pane's title pane. williamr@4: * williamr@4: */ williamr@4: williamr@4: williamr@4: #ifndef C_AKNTITLE_H williamr@4: #define C_AKNTITLE_H williamr@4: williamr@4: #include williamr@4: #include williamr@4: williamr@4: class CEikLabel; williamr@4: class CEikImage; williamr@4: class CAknTitlePaneExtension; williamr@4: class CAknTitlePaneLabel; williamr@4: class MAknTitlePaneObserver; williamr@4: class TAknTextLineLayout; williamr@4: williamr@4: /** williamr@4: * A default control in the status pane's title pane. williamr@4: * williamr@4: * @lib avkon.lib williamr@4: */ williamr@4: class CAknTitlePane : public CAknControl, public MCoeControlContext williamr@4: { williamr@4: public: williamr@4: /** williamr@4: * Constructor. williamr@4: */ williamr@4: IMPORT_C CAknTitlePane(); williamr@4: williamr@4: /** williamr@4: * Destructor. williamr@4: */ williamr@4: IMPORT_C ~CAknTitlePane(); williamr@4: williamr@4: /** williamr@4: * 2nd phase constructor. williamr@4: */ williamr@4: IMPORT_C void ConstructL(); williamr@4: williamr@4: /** williamr@4: * Read title pane data from resource file and show it in williamr@4: * the status pane's title pane. williamr@4: */ williamr@4: IMPORT_C void ConstructFromResourceL( TResourceReader& aReader ); williamr@4: williamr@4: /** williamr@4: * Set a text and show it in the status pane's title pane. williamr@4: * Descriptor is copied to the title pane control and ownership of williamr@4: * the original descriptor is left to the application. williamr@4: * williamr@4: * @param aText Text to be shown on the title pane. williamr@4: */ williamr@4: IMPORT_C void SetTextL( const TDesC& aText ); williamr@4: williamr@4: /** williamr@4: * Sets text to the title pane. williamr@4: * williamr@4: * @param aText New text. This object takes ownership of @c aText. williamr@4: */ williamr@4: IMPORT_C void SetText( HBufC* aText ); williamr@4: williamr@4: /** williamr@4: * Set a text and show it in the status pane's title pane. williamr@4: * If whole text does not fit into titlepane, it will be scrolled once williamr@4: * and then shown in truncated form. williamr@4: * williamr@4: * Descriptor is copied to the title pane control and ownership williamr@4: * of the original descriptor is left to the application. williamr@4: * williamr@4: * @since 3.0 williamr@4: * williamr@4: * @param aText Text to be shown on the title pane. williamr@4: * @param aScroll If @c ETrue text is scrolled when needed, otherwise not. williamr@4: * williamr@4: */ williamr@4: IMPORT_C void SetTextL( const TDesC& aText, TBool aScroll ); williamr@4: williamr@4: /** williamr@4: * Sets text to the title pane. If whole text does not fit into titlepane, williamr@4: * it will be scrolled once and then shown in truncated form. williamr@4: * williamr@4: * @since 3.0 williamr@4: * williamr@4: * @param aText New text. This object takes ownership of @c aText. williamr@4: * If @c NULL is given then already existing text's williamr@4: * scrollability will be changed according to @c aScroll. williamr@4: * @param aScroll If ETrue text is scrolled when needed, otherwise not. williamr@4: */ williamr@4: IMPORT_C void SetText( HBufC* aText, TBool aScroll ); williamr@4: williamr@4: /** williamr@4: * Returns text currently in the status pane's title pane. williamr@4: * Ownership is not transferred. williamr@4: * williamr@4: * @return Text currently shown in the title pane. williamr@4: */ williamr@4: inline const TDesC* Text() const; williamr@4: williamr@4: /** williamr@4: * Set a picture to the title pane and show it in the williamr@4: * status pane's title pane. williamr@4: * Title pane object takes ownership of the picture. williamr@4: * If @c NULL bitmap is passed, previously set image is shown. williamr@4: * williamr@4: * @param aBitmap Bitmap to be set on the title pane. williamr@4: * @param aMaskBitmap Mask of the bitmap. williamr@4: */ williamr@4: IMPORT_C void SetPicture( const CFbsBitmap* aBitmap, williamr@4: const CFbsBitmap* aMaskBitmap = NULL ); williamr@4: williamr@4: /** williamr@4: * Set a picture from file and show it in the status pane's title pane. williamr@4: * williamr@4: * @param aFileName Name of the bitmap file. williamr@4: * @param aMainId Index of the bitmap in the bitmap file. williamr@4: * @param aMaskId Index of the bitmap's mask in the bitmap file. williamr@4: */ williamr@4: IMPORT_C void SetPictureFromFileL( const TDesC& aFileName, williamr@4: TInt aMainId, williamr@4: TInt aMaskId = -1 ); williamr@4: williamr@4: /** williamr@4: * Set a small picture to the title pane and show it in the williamr@4: * status pane's title pane together with text. williamr@4: * williamr@4: * Title pane object takes ownership of the picture. williamr@4: * williamr@4: * If @c NULL bitmap is passed, previously set image is used. williamr@4: * williamr@4: * @since 3.0 williamr@4: * williamr@4: * @param aBitmap Bitmap to be set on the title pane. williamr@4: * @param aMaskBitmap Mask of the bitmap. williamr@4: * @param aVisible If @c ETrue, picture is set visible. Otherwise only text is shown. williamr@4: */ williamr@4: IMPORT_C void SetSmallPicture( const CFbsBitmap* aBitmap, williamr@4: const CFbsBitmap* aMaskBitmap, williamr@4: TBool aVisible ); williamr@4: williamr@4: /** williamr@4: * Set data from resource file and show it in the status pane's title pane. williamr@4: * williamr@4: * @param aReader Resource reader of the title pane data. williamr@4: */ williamr@4: IMPORT_C void SetFromResourceL( TResourceReader& aReader ); williamr@4: williamr@4: /** williamr@4: * Set default value to the status pane's title pane. williamr@4: * Default value is the name of currently active application. williamr@4: */ williamr@4: IMPORT_C void SetTextToDefaultL(); williamr@4: williamr@4: /** williamr@4: * Gets the maximum amount of text rows that title pane is able to display simultaneously williamr@4: * in the currently active status pane layout. Typically the return value is williamr@4: * either 2 (default portrait mode layout) or 1 (landscape mode layouts). williamr@4: * In the extended status pane layouts the maximum number of lines is always 1. williamr@4: * williamr@4: * Since release 3.2, regardless of the status pane layout, williamr@4: * the maximum number of lines is always 1. williamr@4: * williamr@4: * @since 3.1 williamr@4: * williamr@4: * @return Maximum number of visible text lines. williamr@4: */ williamr@4: IMPORT_C TInt MaxNumberOfVisibleTextRows() const; williamr@4: williamr@4: /** williamr@4: * Sets the number of text rows that can be used to display the text. williamr@4: * The largest allowed value is the the value returned from MaxNumberOfVisibleTextRows() and williamr@4: * the minimum value is always 1. williamr@4: * williamr@4: * @since 3.1 williamr@4: * williamr@4: * @param aRows Number of rows that can be used to display the text. williamr@4: */ williamr@4: IMPORT_C void SetNumberOfVisibleTextRows( TInt aRows ); williamr@4: williamr@4: public: // From base class @c MCoeControlContext. williamr@4: williamr@4: /** williamr@4: * Allows to modify graphics context before @c Draw. williamr@4: * williamr@4: * @param aGc Graphics context to be modified. williamr@4: */ williamr@4: IMPORT_C virtual void PrepareContext( CWindowGc& aGc ) const; williamr@4: williamr@4: protected: // From base class @c CCoeControl. williamr@4: williamr@4: /** williamr@4: * Handles the size change events. williamr@4: */ williamr@4: IMPORT_C virtual void SizeChanged(); williamr@4: williamr@4: /** williamr@4: * Handles the position change events. williamr@4: */ williamr@4: IMPORT_C virtual void PositionChanged(); williamr@4: williamr@4: /** williamr@4: * Handles a change to the control's resources which are shared across williamr@4: * the environment, e.g. skin change. williamr@4: * williamr@4: * @param aType Event type. williamr@4: */ williamr@4: IMPORT_C virtual void HandleResourceChange( TInt aType ); williamr@4: williamr@4: /** williamr@4: * Returns number of controls inside the title pane control. williamr@4: * williamr@4: * @return Number of component controls. williamr@4: */ williamr@4: IMPORT_C virtual TInt CountComponentControls() const; williamr@4: williamr@4: /** williamr@4: * Returns a control determined by control index. williamr@4: * williamr@4: * @param aIndex Index of a control to be returned. williamr@4: * williamr@4: * @return Pointer to the control. williamr@4: */ williamr@4: IMPORT_C virtual CCoeControl* ComponentControl(TInt aIndex) const; williamr@4: williamr@4: public: // From base class @c CCoeControl. williamr@4: williamr@4: /** williamr@4: * Handles pointer events. williamr@4: * williamr@4: * @param aPointerEvent Pointer event to be handled. williamr@4: */ williamr@4: IMPORT_C void HandlePointerEventL( const TPointerEvent& aPointerEvent ); williamr@4: williamr@4: public: // New methods williamr@4: williamr@4: /** williamr@4: * Sets observer for title pane events. williamr@4: * williamr@4: * @param aObserver Pointer to title pane observer. williamr@4: */ williamr@4: IMPORT_C void SetTitlePaneObserver( MAknTitlePaneObserver* aObserver ); williamr@4: williamr@4: private: // From base class @c CAknControl. williamr@4: williamr@4: IMPORT_C void* ExtensionInterface( TUid aInterface ); williamr@4: williamr@4: public: williamr@4: williamr@4: /** williamr@4: * Gets title text label. williamr@4: * @internal williamr@4: */ williamr@4: CEikLabel* TextLabel(); williamr@4: williamr@4: /** williamr@4: * Gets the title image. williamr@4: * @internal williamr@4: */ williamr@4: CEikImage* TitleImage(); williamr@4: williamr@4: private: williamr@4: williamr@4: void CommonConstructL(); williamr@4: TUid AppUid() const; williamr@4: williamr@4: TInt FormatTitlePaneLabelL( const TInt aOneLineLayoutWidth, williamr@4: const TInt aTwoLineLayoutWidth, williamr@4: const CFont* aOneLineFont, williamr@4: const CFont* aTwoLineFont ); williamr@4: williamr@4: void ReadFromResourceFileL( TResourceReader& aReader ); williamr@4: void SetSmallPictureFromFileL( const TDesC& aFileName, TInt aMainId, TInt aMaskId = -1 ); williamr@4: williamr@4: private: // From base class @c CCoeControl. williamr@4: williamr@4: IMPORT_C virtual void Draw( const TRect& aRect ) const; williamr@4: williamr@4: protected: williamr@4: williamr@4: MAknTitlePaneObserver* iTitlePaneObserver; williamr@4: williamr@4: private: williamr@4: void SizeChangedInNormalStatusPane(); williamr@4: void SizeChangedInExtendedStatusPane(); williamr@4: void SizeChangedInFlatStatusPane(); williamr@4: void SizeChangedInStaconPane(); williamr@4: RWindow* StatuspaneContainerWindow() const; williamr@4: void SetupTitleLabelEffectL(); williamr@4: void SetContainerWindowNonFading( TBool aNonFading ); williamr@4: williamr@4: void SetupStaconPaneScrollEffectL(); williamr@4: void SetupFlatStatusPaneScrollEffectL(); williamr@4: void SetupNormalStatusPaneScrollEffectL(); williamr@4: void SetupFlatStatusPaneFadeEffectL(); williamr@4: void SetupExtendedStatusPaneScrollEffectL(); williamr@4: void SetupNoEffectL(); williamr@4: williamr@4: TBool TextFits( TAknTextLineLayout& aTextLayout ); williamr@4: williamr@4: private: // Member data williamr@4: williamr@4: HBufC* iTitleText; williamr@4: HBufC* iDefaultTitleText; williamr@4: CAknTitlePaneLabel* iTitleLabel; williamr@4: TBool iImageShown; williamr@4: CAknTitlePaneExtension* iExtension; williamr@4: }; williamr@4: williamr@4: inline const TDesC* CAknTitlePane::Text() const williamr@4: { williamr@4: return( iTitleText ); williamr@4: } williamr@4: williamr@4: #endif // C_AKNTITLE_H