epoc32/include/mw/akntitle.h
author William Roberts <williamr@symbian.org>
Wed, 31 Mar 2010 12:33:34 +0100
branchSymbian3
changeset 4 837f303aceeb
permissions -rw-r--r--
Current Symbian^3 public API header files (from PDK 3.0.h)
This is the epoc32/include tree with the "platform" subtrees removed, and
all but a selected few mbg and rsg files removed.
     1 /*
     2 * Copyright (c) 2002-2008 Nokia Corporation and/or its subsidiary(-ies).
     3 * All rights reserved.
     4 * This component and the accompanying materials are made available
     5 * under the terms of "Eclipse Public License v1.0"
     6 * which accompanies this distribution, and is available
     7 * at the URL "http://www.eclipse.org/legal/epl-v10.html".
     8 *
     9 * Initial Contributors:
    10 * Nokia Corporation - initial contribution.
    11 *
    12 * Contributors:
    13 *
    14 * Description:  A default control in the status pane's title pane.
    15 *
    16 */
    17 
    18 
    19 #ifndef C_AKNTITLE_H
    20 #define C_AKNTITLE_H
    21 
    22 #include <AknControl.h>
    23 #include <coeccntx.h>
    24 
    25 class CEikLabel;
    26 class CEikImage;
    27 class CAknTitlePaneExtension;
    28 class CAknTitlePaneLabel;
    29 class MAknTitlePaneObserver;
    30 class TAknTextLineLayout;
    31 
    32 /**
    33  * A default control in the status pane's title pane.
    34  *
    35  * @lib avkon.lib
    36  */
    37 class CAknTitlePane : public CAknControl, public MCoeControlContext
    38 	{
    39 public:
    40     /**
    41     * Constructor.
    42     */
    43     IMPORT_C CAknTitlePane();
    44 
    45     /**
    46     * Destructor.
    47     */
    48     IMPORT_C ~CAknTitlePane();
    49     
    50     /**
    51     * 2nd phase constructor.
    52     */
    53     IMPORT_C void ConstructL();
    54     
    55     /**
    56     * Read title pane data from resource file and show it in
    57     * the status pane's title pane.
    58     */
    59     IMPORT_C void ConstructFromResourceL( TResourceReader& aReader );
    60     
    61     /**
    62     * Set a text and show it in the status pane's title pane.
    63     * Descriptor is copied to the title pane control and ownership of
    64     * the original descriptor is left to the application.
    65     *
    66     * @param  aText  Text to be shown on the title pane.
    67     */
    68     IMPORT_C void SetTextL( const TDesC& aText );
    69     
    70     /**
    71     * Sets text to the title pane.
    72     *
    73     * @param  aText	 New text. This object takes ownership of @c aText.
    74     */
    75     IMPORT_C void SetText( HBufC* aText );
    76 
    77     /**
    78     * Set a text and show it in the status pane's title pane.
    79     * If whole text does not fit into titlepane, it will be scrolled once
    80     * and then shown in truncated form. 
    81     *
    82     * Descriptor is copied to the title pane control and ownership
    83     * of the original descriptor is left to the application.
    84     *
    85     * @since 3.0
    86     *
    87     * @param  aText    Text to be shown on the title pane.
    88     * @param  aScroll  If @c ETrue text is scrolled when needed, otherwise not.
    89     * 
    90     */
    91     IMPORT_C void SetTextL( const TDesC& aText, TBool aScroll );    
    92 
    93     /**
    94     * Sets text to the title pane. If whole text does not fit into titlepane,
    95     * it will be scrolled once and then shown in truncated form. 
    96     *
    97     * @since 3.0
    98     *
    99     * @param  aText   New text. This object takes ownership of @c aText.
   100     *                 If @c NULL is given then already existing text's
   101     *                 scrollability will be changed according to @c aScroll.
   102     * @param aScroll  If ETrue text is scrolled when needed, otherwise not.  
   103     */
   104     IMPORT_C void SetText( HBufC* aText, TBool aScroll );
   105     
   106     /**
   107     * Returns text currently in the status pane's title pane.
   108     * Ownership is not transferred.
   109     *
   110     * @return  Text currently shown in the title pane.
   111     */
   112     inline const TDesC* Text() const;
   113     
   114     /**
   115     * Set a picture to the title pane and show it in the
   116     * status pane's title pane.
   117     * Title pane object takes ownership of the picture.
   118     * If @c NULL bitmap is passed, previously set image is shown.
   119     *
   120     * @param  aBitmap      Bitmap to be set on the title pane.
   121     * @param  aMaskBitmap  Mask of the bitmap.
   122     */
   123     IMPORT_C void SetPicture( const CFbsBitmap* aBitmap,
   124                               const CFbsBitmap* aMaskBitmap = NULL );
   125     
   126     /**
   127     * Set a picture from file and show it in the status pane's title pane.
   128     *
   129     * @param  aFileName  Name of the bitmap file.
   130     * @param  aMainId    Index of the bitmap in the bitmap file.
   131     * @param  aMaskId    Index of the bitmap's mask in the bitmap file.
   132     */
   133     IMPORT_C void SetPictureFromFileL( const TDesC& aFileName,
   134                                        TInt aMainId,
   135                                        TInt aMaskId = -1 );
   136 
   137     /**
   138     * Set a small picture to the title pane and show it in the
   139     * status pane's title pane together with text.
   140     * 
   141     * Title pane object takes ownership of the picture.
   142     *
   143     * If @c NULL bitmap is passed, previously set image is used.
   144     *
   145     * @since 3.0
   146     *
   147     * @param  aBitmap      Bitmap to be set on the title pane.
   148     * @param  aMaskBitmap  Mask of the bitmap.
   149     * @param  aVisible     If @c ETrue, picture is set visible. Otherwise only text is shown.
   150     */
   151     IMPORT_C void SetSmallPicture( const CFbsBitmap* aBitmap,
   152                                    const CFbsBitmap* aMaskBitmap,
   153                                    TBool aVisible );
   154     
   155     /**
   156     * Set data from resource file and show it in the status pane's title pane.
   157     *
   158     * @param  aReader  Resource reader of the title pane data.
   159     */
   160     IMPORT_C void SetFromResourceL( TResourceReader& aReader );
   161     
   162     /**
   163     * Set default value to the status pane's title pane.
   164     * Default value is the name of currently active application.
   165     */
   166     IMPORT_C void SetTextToDefaultL();
   167     
   168     /**
   169     * Gets the maximum amount of text rows that title pane is able to display simultaneously
   170     * in the currently active status pane layout. Typically the return value is 
   171     * either 2 (default portrait mode layout) or 1 (landscape mode layouts).
   172     * In the extended status pane layouts the maximum number of lines is always 1.
   173     *
   174     * Since release 3.2, regardless of the status pane layout,
   175     * the maximum number of lines is always 1.
   176     *
   177     * @since 3.1
   178     *
   179     * @return Maximum number of visible text lines.
   180     */    
   181     IMPORT_C TInt MaxNumberOfVisibleTextRows() const;
   182 
   183     /**
   184     * Sets the number of text rows that can be used to display the text. 
   185     * The largest allowed value is the the value returned from MaxNumberOfVisibleTextRows() and 
   186     * the minimum value is always 1.
   187     *
   188     * @since 3.1
   189     *
   190     * @param  aRows  Number of rows that can be used to display the text.
   191     */    
   192     IMPORT_C void SetNumberOfVisibleTextRows( TInt aRows );
   193     
   194 public: // From base class @c MCoeControlContext.
   195 
   196     /** 
   197     * Allows to modify graphics context before @c Draw.
   198     *
   199     * @param  aGc  Graphics context to be modified.
   200     */
   201     IMPORT_C virtual void PrepareContext( CWindowGc& aGc ) const;
   202     
   203 protected: // From base class @c CCoeControl.
   204 
   205     /**
   206     * Handles the size change events.
   207     */
   208     IMPORT_C virtual void SizeChanged();
   209 
   210     /**
   211     * Handles the position change events.
   212     */
   213     IMPORT_C virtual void PositionChanged();
   214 
   215     /**
   216 	* Handles a change to the control's resources which are shared across
   217 	* the environment, e.g. skin change.
   218 	*
   219 	* @param  aType  Event type.
   220 	*/
   221     IMPORT_C virtual void HandleResourceChange( TInt aType );
   222 
   223     /**
   224     * Returns number of controls inside the title pane control.
   225     *
   226     * @return Number of component controls.
   227     */
   228     IMPORT_C virtual TInt CountComponentControls() const;
   229 
   230     /**
   231     * Returns a control determined by control index.
   232     *
   233     * @param  aIndex  Index of a control to be returned.
   234     *
   235     * @return Pointer to the control.
   236     */
   237     IMPORT_C virtual CCoeControl* ComponentControl(TInt aIndex) const;
   238     
   239 public: // From base class @c CCoeControl.
   240 
   241     /**
   242     * Handles pointer events.
   243     *
   244     * @param  aPointerEvent  Pointer event to be handled.
   245     */
   246     IMPORT_C void HandlePointerEventL( const TPointerEvent& aPointerEvent );
   247 
   248 public: // New methods
   249 
   250     /**
   251     * Sets observer for title pane events.
   252     *
   253     * @param  aObserver  Pointer to title pane observer.
   254     */
   255     IMPORT_C void SetTitlePaneObserver( MAknTitlePaneObserver* aObserver );
   256 
   257 private: // From base class @c CAknControl.
   258 
   259     IMPORT_C void* ExtensionInterface( TUid aInterface );
   260 
   261 public:
   262 
   263     /**
   264     * Gets title text label.
   265     * @internal
   266     */
   267     CEikLabel* TextLabel();
   268     
   269     /**
   270     * Gets the title image.
   271     * @internal
   272     */
   273     CEikImage* TitleImage();
   274 
   275 private:
   276 
   277     void CommonConstructL();
   278     TUid AppUid() const;
   279 
   280     TInt FormatTitlePaneLabelL( const TInt aOneLineLayoutWidth,
   281                                 const TInt aTwoLineLayoutWidth,
   282                                 const CFont* aOneLineFont,
   283                                 const CFont* aTwoLineFont );
   284 
   285     void ReadFromResourceFileL( TResourceReader& aReader );
   286     void SetSmallPictureFromFileL( const TDesC& aFileName, TInt aMainId, TInt aMaskId = -1 );
   287     
   288 private: // From base class @c CCoeControl.
   289 
   290     IMPORT_C virtual void Draw( const TRect& aRect ) const;
   291     
   292 protected:
   293 
   294     MAknTitlePaneObserver* iTitlePaneObserver;
   295     
   296 private:
   297     void SizeChangedInNormalStatusPane();
   298     void SizeChangedInExtendedStatusPane();
   299     void SizeChangedInFlatStatusPane();
   300     void SizeChangedInStaconPane();
   301     RWindow* StatuspaneContainerWindow() const;
   302     void SetupTitleLabelEffectL();
   303     void SetContainerWindowNonFading( TBool aNonFading );
   304     
   305     void SetupStaconPaneScrollEffectL();
   306     void SetupFlatStatusPaneScrollEffectL();
   307     void SetupNormalStatusPaneScrollEffectL();
   308     void SetupFlatStatusPaneFadeEffectL();
   309     void SetupExtendedStatusPaneScrollEffectL();
   310     void SetupNoEffectL();
   311     
   312     TBool TextFits( TAknTextLineLayout& aTextLayout );
   313 
   314 private: // Member data
   315 
   316     HBufC*                  iTitleText;
   317     HBufC*                  iDefaultTitleText;
   318     CAknTitlePaneLabel*     iTitleLabel;
   319     TBool                   iImageShown;
   320     CAknTitlePaneExtension* iExtension;
   321     };
   322 
   323 inline const TDesC* CAknTitlePane::Text() const
   324     {
   325     return( iTitleText );
   326     }
   327 
   328 #endif // C_AKNTITLE_H