epoc32/include/mw/akntitle.h
branchSymbian3
changeset 4 837f303aceeb
     1.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.2 +++ b/epoc32/include/mw/akntitle.h	Wed Mar 31 12:33:34 2010 +0100
     1.3 @@ -0,0 +1,328 @@
     1.4 +/*
     1.5 +* Copyright (c) 2002-2008 Nokia Corporation and/or its subsidiary(-ies).
     1.6 +* All rights reserved.
     1.7 +* This component and the accompanying materials are made available
     1.8 +* under the terms of "Eclipse Public License v1.0"
     1.9 +* which accompanies this distribution, and is available
    1.10 +* at the URL "http://www.eclipse.org/legal/epl-v10.html".
    1.11 +*
    1.12 +* Initial Contributors:
    1.13 +* Nokia Corporation - initial contribution.
    1.14 +*
    1.15 +* Contributors:
    1.16 +*
    1.17 +* Description:  A default control in the status pane's title pane.
    1.18 +*
    1.19 +*/
    1.20 +
    1.21 +
    1.22 +#ifndef C_AKNTITLE_H
    1.23 +#define C_AKNTITLE_H
    1.24 +
    1.25 +#include <AknControl.h>
    1.26 +#include <coeccntx.h>
    1.27 +
    1.28 +class CEikLabel;
    1.29 +class CEikImage;
    1.30 +class CAknTitlePaneExtension;
    1.31 +class CAknTitlePaneLabel;
    1.32 +class MAknTitlePaneObserver;
    1.33 +class TAknTextLineLayout;
    1.34 +
    1.35 +/**
    1.36 + * A default control in the status pane's title pane.
    1.37 + *
    1.38 + * @lib avkon.lib
    1.39 + */
    1.40 +class CAknTitlePane : public CAknControl, public MCoeControlContext
    1.41 +	{
    1.42 +public:
    1.43 +    /**
    1.44 +    * Constructor.
    1.45 +    */
    1.46 +    IMPORT_C CAknTitlePane();
    1.47 +
    1.48 +    /**
    1.49 +    * Destructor.
    1.50 +    */
    1.51 +    IMPORT_C ~CAknTitlePane();
    1.52 +    
    1.53 +    /**
    1.54 +    * 2nd phase constructor.
    1.55 +    */
    1.56 +    IMPORT_C void ConstructL();
    1.57 +    
    1.58 +    /**
    1.59 +    * Read title pane data from resource file and show it in
    1.60 +    * the status pane's title pane.
    1.61 +    */
    1.62 +    IMPORT_C void ConstructFromResourceL( TResourceReader& aReader );
    1.63 +    
    1.64 +    /**
    1.65 +    * Set a text and show it in the status pane's title pane.
    1.66 +    * Descriptor is copied to the title pane control and ownership of
    1.67 +    * the original descriptor is left to the application.
    1.68 +    *
    1.69 +    * @param  aText  Text to be shown on the title pane.
    1.70 +    */
    1.71 +    IMPORT_C void SetTextL( const TDesC& aText );
    1.72 +    
    1.73 +    /**
    1.74 +    * Sets text to the title pane.
    1.75 +    *
    1.76 +    * @param  aText	 New text. This object takes ownership of @c aText.
    1.77 +    */
    1.78 +    IMPORT_C void SetText( HBufC* aText );
    1.79 +
    1.80 +    /**
    1.81 +    * Set a text and show it in the status pane's title pane.
    1.82 +    * If whole text does not fit into titlepane, it will be scrolled once
    1.83 +    * and then shown in truncated form. 
    1.84 +    *
    1.85 +    * Descriptor is copied to the title pane control and ownership
    1.86 +    * of the original descriptor is left to the application.
    1.87 +    *
    1.88 +    * @since 3.0
    1.89 +    *
    1.90 +    * @param  aText    Text to be shown on the title pane.
    1.91 +    * @param  aScroll  If @c ETrue text is scrolled when needed, otherwise not.
    1.92 +    * 
    1.93 +    */
    1.94 +    IMPORT_C void SetTextL( const TDesC& aText, TBool aScroll );    
    1.95 +
    1.96 +    /**
    1.97 +    * Sets text to the title pane. If whole text does not fit into titlepane,
    1.98 +    * it will be scrolled once and then shown in truncated form. 
    1.99 +    *
   1.100 +    * @since 3.0
   1.101 +    *
   1.102 +    * @param  aText   New text. This object takes ownership of @c aText.
   1.103 +    *                 If @c NULL is given then already existing text's
   1.104 +    *                 scrollability will be changed according to @c aScroll.
   1.105 +    * @param aScroll  If ETrue text is scrolled when needed, otherwise not.  
   1.106 +    */
   1.107 +    IMPORT_C void SetText( HBufC* aText, TBool aScroll );
   1.108 +    
   1.109 +    /**
   1.110 +    * Returns text currently in the status pane's title pane.
   1.111 +    * Ownership is not transferred.
   1.112 +    *
   1.113 +    * @return  Text currently shown in the title pane.
   1.114 +    */
   1.115 +    inline const TDesC* Text() const;
   1.116 +    
   1.117 +    /**
   1.118 +    * Set a picture to the title pane and show it in the
   1.119 +    * status pane's title pane.
   1.120 +    * Title pane object takes ownership of the picture.
   1.121 +    * If @c NULL bitmap is passed, previously set image is shown.
   1.122 +    *
   1.123 +    * @param  aBitmap      Bitmap to be set on the title pane.
   1.124 +    * @param  aMaskBitmap  Mask of the bitmap.
   1.125 +    */
   1.126 +    IMPORT_C void SetPicture( const CFbsBitmap* aBitmap,
   1.127 +                              const CFbsBitmap* aMaskBitmap = NULL );
   1.128 +    
   1.129 +    /**
   1.130 +    * Set a picture from file and show it in the status pane's title pane.
   1.131 +    *
   1.132 +    * @param  aFileName  Name of the bitmap file.
   1.133 +    * @param  aMainId    Index of the bitmap in the bitmap file.
   1.134 +    * @param  aMaskId    Index of the bitmap's mask in the bitmap file.
   1.135 +    */
   1.136 +    IMPORT_C void SetPictureFromFileL( const TDesC& aFileName,
   1.137 +                                       TInt aMainId,
   1.138 +                                       TInt aMaskId = -1 );
   1.139 +
   1.140 +    /**
   1.141 +    * Set a small picture to the title pane and show it in the
   1.142 +    * status pane's title pane together with text.
   1.143 +    * 
   1.144 +    * Title pane object takes ownership of the picture.
   1.145 +    *
   1.146 +    * If @c NULL bitmap is passed, previously set image is used.
   1.147 +    *
   1.148 +    * @since 3.0
   1.149 +    *
   1.150 +    * @param  aBitmap      Bitmap to be set on the title pane.
   1.151 +    * @param  aMaskBitmap  Mask of the bitmap.
   1.152 +    * @param  aVisible     If @c ETrue, picture is set visible. Otherwise only text is shown.
   1.153 +    */
   1.154 +    IMPORT_C void SetSmallPicture( const CFbsBitmap* aBitmap,
   1.155 +                                   const CFbsBitmap* aMaskBitmap,
   1.156 +                                   TBool aVisible );
   1.157 +    
   1.158 +    /**
   1.159 +    * Set data from resource file and show it in the status pane's title pane.
   1.160 +    *
   1.161 +    * @param  aReader  Resource reader of the title pane data.
   1.162 +    */
   1.163 +    IMPORT_C void SetFromResourceL( TResourceReader& aReader );
   1.164 +    
   1.165 +    /**
   1.166 +    * Set default value to the status pane's title pane.
   1.167 +    * Default value is the name of currently active application.
   1.168 +    */
   1.169 +    IMPORT_C void SetTextToDefaultL();
   1.170 +    
   1.171 +    /**
   1.172 +    * Gets the maximum amount of text rows that title pane is able to display simultaneously
   1.173 +    * in the currently active status pane layout. Typically the return value is 
   1.174 +    * either 2 (default portrait mode layout) or 1 (landscape mode layouts).
   1.175 +    * In the extended status pane layouts the maximum number of lines is always 1.
   1.176 +    *
   1.177 +    * Since release 3.2, regardless of the status pane layout,
   1.178 +    * the maximum number of lines is always 1.
   1.179 +    *
   1.180 +    * @since 3.1
   1.181 +    *
   1.182 +    * @return Maximum number of visible text lines.
   1.183 +    */    
   1.184 +    IMPORT_C TInt MaxNumberOfVisibleTextRows() const;
   1.185 +
   1.186 +    /**
   1.187 +    * Sets the number of text rows that can be used to display the text. 
   1.188 +    * The largest allowed value is the the value returned from MaxNumberOfVisibleTextRows() and 
   1.189 +    * the minimum value is always 1.
   1.190 +    *
   1.191 +    * @since 3.1
   1.192 +    *
   1.193 +    * @param  aRows  Number of rows that can be used to display the text.
   1.194 +    */    
   1.195 +    IMPORT_C void SetNumberOfVisibleTextRows( TInt aRows );
   1.196 +    
   1.197 +public: // From base class @c MCoeControlContext.
   1.198 +
   1.199 +    /** 
   1.200 +    * Allows to modify graphics context before @c Draw.
   1.201 +    *
   1.202 +    * @param  aGc  Graphics context to be modified.
   1.203 +    */
   1.204 +    IMPORT_C virtual void PrepareContext( CWindowGc& aGc ) const;
   1.205 +    
   1.206 +protected: // From base class @c CCoeControl.
   1.207 +
   1.208 +    /**
   1.209 +    * Handles the size change events.
   1.210 +    */
   1.211 +    IMPORT_C virtual void SizeChanged();
   1.212 +
   1.213 +    /**
   1.214 +    * Handles the position change events.
   1.215 +    */
   1.216 +    IMPORT_C virtual void PositionChanged();
   1.217 +
   1.218 +    /**
   1.219 +	* Handles a change to the control's resources which are shared across
   1.220 +	* the environment, e.g. skin change.
   1.221 +	*
   1.222 +	* @param  aType  Event type.
   1.223 +	*/
   1.224 +    IMPORT_C virtual void HandleResourceChange( TInt aType );
   1.225 +
   1.226 +    /**
   1.227 +    * Returns number of controls inside the title pane control.
   1.228 +    *
   1.229 +    * @return Number of component controls.
   1.230 +    */
   1.231 +    IMPORT_C virtual TInt CountComponentControls() const;
   1.232 +
   1.233 +    /**
   1.234 +    * Returns a control determined by control index.
   1.235 +    *
   1.236 +    * @param  aIndex  Index of a control to be returned.
   1.237 +    *
   1.238 +    * @return Pointer to the control.
   1.239 +    */
   1.240 +    IMPORT_C virtual CCoeControl* ComponentControl(TInt aIndex) const;
   1.241 +    
   1.242 +public: // From base class @c CCoeControl.
   1.243 +
   1.244 +    /**
   1.245 +    * Handles pointer events.
   1.246 +    *
   1.247 +    * @param  aPointerEvent  Pointer event to be handled.
   1.248 +    */
   1.249 +    IMPORT_C void HandlePointerEventL( const TPointerEvent& aPointerEvent );
   1.250 +
   1.251 +public: // New methods
   1.252 +
   1.253 +    /**
   1.254 +    * Sets observer for title pane events.
   1.255 +    *
   1.256 +    * @param  aObserver  Pointer to title pane observer.
   1.257 +    */
   1.258 +    IMPORT_C void SetTitlePaneObserver( MAknTitlePaneObserver* aObserver );
   1.259 +
   1.260 +private: // From base class @c CAknControl.
   1.261 +
   1.262 +    IMPORT_C void* ExtensionInterface( TUid aInterface );
   1.263 +
   1.264 +public:
   1.265 +
   1.266 +    /**
   1.267 +    * Gets title text label.
   1.268 +    * @internal
   1.269 +    */
   1.270 +    CEikLabel* TextLabel();
   1.271 +    
   1.272 +    /**
   1.273 +    * Gets the title image.
   1.274 +    * @internal
   1.275 +    */
   1.276 +    CEikImage* TitleImage();
   1.277 +
   1.278 +private:
   1.279 +
   1.280 +    void CommonConstructL();
   1.281 +    TUid AppUid() const;
   1.282 +
   1.283 +    TInt FormatTitlePaneLabelL( const TInt aOneLineLayoutWidth,
   1.284 +                                const TInt aTwoLineLayoutWidth,
   1.285 +                                const CFont* aOneLineFont,
   1.286 +                                const CFont* aTwoLineFont );
   1.287 +
   1.288 +    void ReadFromResourceFileL( TResourceReader& aReader );
   1.289 +    void SetSmallPictureFromFileL( const TDesC& aFileName, TInt aMainId, TInt aMaskId = -1 );
   1.290 +    
   1.291 +private: // From base class @c CCoeControl.
   1.292 +
   1.293 +    IMPORT_C virtual void Draw( const TRect& aRect ) const;
   1.294 +    
   1.295 +protected:
   1.296 +
   1.297 +    MAknTitlePaneObserver* iTitlePaneObserver;
   1.298 +    
   1.299 +private:
   1.300 +    void SizeChangedInNormalStatusPane();
   1.301 +    void SizeChangedInExtendedStatusPane();
   1.302 +    void SizeChangedInFlatStatusPane();
   1.303 +    void SizeChangedInStaconPane();
   1.304 +    RWindow* StatuspaneContainerWindow() const;
   1.305 +    void SetupTitleLabelEffectL();
   1.306 +    void SetContainerWindowNonFading( TBool aNonFading );
   1.307 +    
   1.308 +    void SetupStaconPaneScrollEffectL();
   1.309 +    void SetupFlatStatusPaneScrollEffectL();
   1.310 +    void SetupNormalStatusPaneScrollEffectL();
   1.311 +    void SetupFlatStatusPaneFadeEffectL();
   1.312 +    void SetupExtendedStatusPaneScrollEffectL();
   1.313 +    void SetupNoEffectL();
   1.314 +    
   1.315 +    TBool TextFits( TAknTextLineLayout& aTextLayout );
   1.316 +
   1.317 +private: // Member data
   1.318 +
   1.319 +    HBufC*                  iTitleText;
   1.320 +    HBufC*                  iDefaultTitleText;
   1.321 +    CAknTitlePaneLabel*     iTitleLabel;
   1.322 +    TBool                   iImageShown;
   1.323 +    CAknTitlePaneExtension* iExtension;
   1.324 +    };
   1.325 +
   1.326 +inline const TDesC* CAknTitlePane::Text() const
   1.327 +    {
   1.328 +    return( iTitleText );
   1.329 +    }
   1.330 +
   1.331 +#endif // C_AKNTITLE_H