emailuis/emailui/inc/FreestyleEmailUiAknStatusIndicator.h
branchRCL_3
changeset 25 3533d4323edc
equal deleted inserted replaced
24:d189ee25cf9d 25:3533d4323edc
       
     1 /*
       
     2 * Copyright (c) 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: Definition for status indicator
       
    15 *
       
    16 */ 
       
    17 
       
    18 
       
    19 #ifndef __FREESTYLEEMAILUI_AKN_STATUS_INDICATOR_H__
       
    20 #define __FREESTYLEEMAILUI_AKN_STATUS_INDICATOR_H__
       
    21 
       
    22 #include <coecntrl.h>
       
    23 
       
    24 #include "FreestyleEmailUiUtilities.h"  // FSEmailUiGenericTimer
       
    25 
       
    26 const TInt KStatusIndicatorAutomaticHidingDuration = 3000;
       
    27 const TInt KStatusIndicatorDefaultDuration = -1;
       
    28 
       
    29 class CFreestyleEmailUiAknStatusIndicator : public CCoeControl,
       
    30                                             protected MFSEmailUiGenericTimerCallback
       
    31     {
       
    32 public:
       
    33     IMPORT_C static CFreestyleEmailUiAknStatusIndicator* NewL( const TRect& aRect, const CCoeControl* aParent = NULL );
       
    34     
       
    35     IMPORT_C static CFreestyleEmailUiAknStatusIndicator* NewLC( const TRect& aRect, const CCoeControl* aParent = NULL );
       
    36     
       
    37     ~CFreestyleEmailUiAknStatusIndicator();
       
    38     
       
    39     // The ownships of aBitmap, aMaskBitmap and aText are transferred in.
       
    40     // The status indicator is display for aDuration millisecond if aDuration is not negative;
       
    41     // otherwise, it is diplayed forever until it is manually hidden.
       
    42     void ShowIndicatorL( CFbsBitmap* aBitmap, 
       
    43                          CFbsBitmap* aMaskBitmap,
       
    44                          TDesC* aText,
       
    45                          TInt aDuration,
       
    46                          const TBool aAnimate = EFalse );
       
    47 
       
    48     void HideIndicator( TInt aDelayBeforeHidingInMs = 0 );
       
    49     void StartTimer( const TInt aTimeOut );
       
    50     
       
    51     // The ownship of aText is transferred in.
       
    52     void SetTextL( TDesC* aText );
       
    53     
       
    54     // CCoeControl
       
    55     CCoeControl* ComponentControl( TInt aIndex ) const;
       
    56     TInt CountComponentControls() const;
       
    57     void Draw( const TRect& aRect ) const;
       
    58     void SizeChanged();
       
    59     
       
    60     inline const CFbsBitmap* Image() const 
       
    61         {
       
    62         return iBitmap;
       
    63         }
       
    64     
       
    65     inline const CFbsBitmap* ImageMask() const 
       
    66         {
       
    67         return iMaskBitmap;
       
    68         }
       
    69     
       
    70     inline const TDesC* Text() const
       
    71         {
       
    72         return iText;
       
    73         }
       
    74     
       
    75 protected:    
       
    76     CFreestyleEmailUiAknStatusIndicator();
       
    77     void ConstructL( const TRect& aRect, const CCoeControl* aParent );
       
    78 
       
    79     void TimerEventL( CFSEmailUiGenericTimer* aTriggeredTimer );
       
    80 
       
    81 private:
       
    82     TRect ImageRect( const TRect& aRect ) const;
       
    83     TRect TextRect( const TRect& aRect ) const;
       
    84     void CalculateLayout( const TRect& aRect ) const;
       
    85     
       
    86     void SetTextFont() const;
       
    87     void CalculateVisualText() const;
       
    88 
       
    89     TRgb BackgroundColor() const;
       
    90     TRgb BorderColor() const;
       
    91     TRgb FontColor() const;
       
    92 
       
    93     void DrawBoundary( const TRect& aRect ) const;
       
    94     void DrawImage( const TRect& aRect ) const;
       
    95     void DrawText( const TRect& aRect ) const;
       
    96     
       
    97     void SetImage( CFbsBitmap* aBitmap, CFbsBitmap* aMaskBitmap );
       
    98     void ScaleImage() const;
       
    99     
       
   100     void ClearImage();
       
   101     void ClearText();
       
   102     
       
   103 private:
       
   104     CFbsBitmap*                 iBitmap; 
       
   105     CFbsBitmap*                 iMaskBitmap;
       
   106     TDesC*                      iText;
       
   107 
       
   108     CFSEmailUiGenericTimer*     iTimer;
       
   109     
       
   110     mutable TRect               iImageRect;
       
   111     mutable TRect               iTextRect;
       
   112     
       
   113     mutable HBufC*              iVisualText;
       
   114     mutable CFont*              iTextFont;
       
   115     mutable TInt                iVisualTextWidth;            
       
   116     
       
   117     TInt iHideTimeout;
       
   118     TInt iAngle;
       
   119     TBool iAnimate;
       
   120     };
       
   121 
       
   122 #endif // __FREESTYLEEMAILUI_AKN_STATUS_INDICATOR_H__