uifw/AvKon/inc/akndiscreetpopupdrawer.h
changeset 0 2f259fa3e83a
child 14 3320e4e6e8bb
equal deleted inserted replaced
-1:000000000000 0:2f259fa3e83a
       
     1 /*
       
     2 * Copyright (c) 2009 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:  Discreet popup drawer
       
    15 *
       
    16 */
       
    17 
       
    18 #ifndef C_AKNDISCREETPOPUPDRAWER_H
       
    19 #define C_AKNDISCREETPOPUPDRAWER_H
       
    20 
       
    21 
       
    22 #include <e32base.h>
       
    23 #include <gdi.h>
       
    24 
       
    25 class CAknDiscreetPopupControl;
       
    26 class CGulIcon;
       
    27 class CFbsBitmap;
       
    28 class CFont;
       
    29 class TAknWindowComponentLayout;
       
    30 class TAknTextComponentLayout;
       
    31 
       
    32 /**
       
    33  *  Discreet popup text data class.
       
    34  */
       
    35 NONSHARABLE_CLASS( TAknDiscreetPopupTextData )
       
    36     {
       
    37 public:
       
    38 
       
    39     /**
       
    40      * Popup text field font.
       
    41      */
       
    42     const CFont* iTextFont;
       
    43 
       
    44     /**
       
    45      * Popup text field rect.
       
    46      */
       
    47     TRect iTextRect;
       
    48 
       
    49     /**
       
    50      * Popup text field alignment.
       
    51      */
       
    52     CGraphicsContext::TTextAlign iTextAlignment;
       
    53 
       
    54     };
       
    55 
       
    56 /**
       
    57  *  Discreet popup drawer.
       
    58  *
       
    59  *  @lib avkon
       
    60  *  @since S60 v5.2
       
    61  */
       
    62 NONSHARABLE_CLASS( CAknDiscreetPopupDrawer ) : public CBase
       
    63     {
       
    64 
       
    65 public:
       
    66 
       
    67     /**
       
    68      * Two-phased constructor.
       
    69      *
       
    70      * @param aControl Popup control.
       
    71      * @param aTitleText First line of text. 
       
    72      * @param aBodyText Second line of text.
       
    73      * @param aIcon Icon.
       
    74      * @param aSkinId Icon skin item id.
       
    75      * @param aBitmapFile Icon bitmap file.
       
    76      * @param aBitmapId Icon bitmap id.
       
    77      * @param aMaskId Icon mask id.
       
    78      * @param aAction ETrue if popup has action when tapped..
       
    79      */ 
       
    80     static CAknDiscreetPopupDrawer* NewL( CAknDiscreetPopupControl* aControl,
       
    81                                           const TDesC& aTitleText, 
       
    82                                           const TDesC& aBodyText, 
       
    83                                           CGulIcon* aIcon,
       
    84                                           const TAknsItemID& aSkinId,
       
    85                                           const TDesC& aBitmapFile,
       
    86                                           const TInt& aBitmapId,
       
    87                                           const TInt& aMaskId,
       
    88                                           const TBool& aAction );
       
    89 
       
    90     /**
       
    91      * Two-phased constructor.
       
    92      *
       
    93      * @param aControl Popup control.
       
    94      * @param aTitleText First line of text. 
       
    95      * @param aBodyText Second line of text.
       
    96      * @param aIcon Icon.
       
    97      * @param aSkinId Icon skin item id.
       
    98      * @param aBitmapFile Icon bitmap file.
       
    99      * @param aBitmapId Icon bitmap id.
       
   100      * @param aMaskId Icon mask id.
       
   101      * @param aAction ETrue if popup has action when tapped..
       
   102      */
       
   103     static CAknDiscreetPopupDrawer* NewLC( CAknDiscreetPopupControl* aControl,
       
   104                                            const TDesC& aTitleText, 
       
   105                                            const TDesC& aBodyText, 
       
   106                                            CGulIcon* aIcon,
       
   107                                            const TAknsItemID& aSkinId,
       
   108                                            const TDesC& aBitmapFile,
       
   109                                            const TInt& aBitmapId,
       
   110                                            const TInt& aMaskId,
       
   111                                            const TBool& aAction );
       
   112 
       
   113     /**
       
   114      * Destructor.
       
   115      */
       
   116     virtual ~CAknDiscreetPopupDrawer();
       
   117 
       
   118     /**
       
   119      * Sets popup and its components size and position.
       
   120      *
       
   121      * @return Popup rect.
       
   122      */
       
   123     TRect LayoutPopup();
       
   124 
       
   125     /**
       
   126      * Draws popup to given graphics context.
       
   127      * 
       
   128      * @param aGc Graphics context.
       
   129      * @param aRect Rectangle where popup is drawn to.
       
   130      */
       
   131     void Draw( CWindowGc& aGc, const TRect& aRect ) const;
       
   132 
       
   133 private:
       
   134 
       
   135     /**
       
   136      * C++ constructor.
       
   137      */
       
   138     CAknDiscreetPopupDrawer( CAknDiscreetPopupControl* aControl, 
       
   139                              CGulIcon* aIcon,
       
   140                              const TBool& aAction );
       
   141 
       
   142     /**
       
   143      * Symbian second-phase constructor.
       
   144      */
       
   145     void ConstructL( const TDesC& aTitleText, 
       
   146                      const TDesC& aBodyText,
       
   147                      const TAknsItemID& aSkinId,
       
   148                      const TDesC& aBitmapFile,
       
   149                      const TInt& aBitmapId,
       
   150                      const TInt& aMaskId );
       
   151 
       
   152     /**
       
   153      * Draws the texts.
       
   154      *
       
   155      * @param aGc Graphics context.
       
   156      */
       
   157     void DrawTexts( CWindowGc* aGc ) const;
       
   158 
       
   159     /**
       
   160      * Resolves popup layout type.
       
   161      */
       
   162     void ResolvePopupLayout();
       
   163 
       
   164     /**
       
   165      * Provides control eikon env.
       
   166      *
       
   167      * @return Control eikon env.
       
   168      */
       
   169     CEikonEnv* EikonEnv() const;
       
   170 
       
   171     /**
       
   172      * Returns ETrue if title text needs wrapping.
       
   173      * 
       
   174      * @param aLayoutType Current popup layout type. 
       
   175      * @return ETrue if title text needs wrapping.
       
   176      */
       
   177     TBool TitleTextNeedsWrapping( const TInt& aLayoutType );
       
   178 
       
   179     /**
       
   180      * Wraps long text to two lines.
       
   181      */
       
   182     void WrapTitleTextL();
       
   183 
       
   184     /**
       
   185      * Draws aText to aGc (in bidi enabled text rect location).
       
   186      *
       
   187      * @param aGc Graphics context.
       
   188      * @param aTextData Text data.
       
   189      * @param aText Text to be drawn.
       
   190      */
       
   191     void DrawBidiEnabledText(
       
   192             CWindowGc* aGc,
       
   193             const TAknDiscreetPopupTextData& aTextData,
       
   194             const TDesC& aText ) const;
       
   195 
       
   196     /**
       
   197      * Creates icon of given parameters.
       
   198      *
       
   199      * @param aSkinId Icon skin id.
       
   200      * @param aBitmapFile Bitmap file.
       
   201      * @param aBitmapId Bitmap id.
       
   202      * @param aMaskId Mask id.
       
   203      */
       
   204     static CGulIcon* CreatePopupIconL(
       
   205             const TAknsItemID& aSkinId,
       
   206             const TDesC& aBitmapFile,
       
   207             const TInt& aBitmapId,
       
   208             const TInt& aMaskId );
       
   209 
       
   210     /**
       
   211      * Returns ETrue if image information is available
       
   212      * with given parameters.
       
   213      *
       
   214      * @param aSkinId Icon skin id.
       
   215      * @param aBitmapFile Bitmap file.
       
   216      * @param aBitmapId Bitmap id.
       
   217      */
       
   218     static TBool ImageInfoAvailable(
       
   219             const TAknsItemID& aSkinId,
       
   220             const TDesC& aBitmapFile,
       
   221             const TInt& aBitmapId );
       
   222 
       
   223     /**
       
   224      * Returns the specified layout rectangle.
       
   225      *
       
   226      * @param Component parent rect.
       
   227      * @param Component layout.
       
   228      * @return Layout rect.
       
   229      */
       
   230     static TRect RectFromLayout( 
       
   231         const TRect& aParent, 
       
   232         const TAknWindowComponentLayout& aComponentLayout );
       
   233 
       
   234     /**
       
   235      * Fills text data according to text layout.
       
   236      *
       
   237      * @param aTextData Text data.
       
   238      * @param aParent Component parent rect.
       
   239      * @param aComponentLayout Component layout.
       
   240      */
       
   241     static void TextDataFromLayout(
       
   242             TAknDiscreetPopupTextData& aTextData,
       
   243             const TRect& aParent, 
       
   244             const TAknTextComponentLayout& aComponentLayout );
       
   245 
       
   246     /**
       
   247      * Returns the specified text layout font.
       
   248      *
       
   249      * @param Component parent rect.
       
   250      * @param Component layout.
       
   251      * @param Text layout rect.
       
   252      * @return Text layout font.
       
   253      */
       
   254     static const CFont* FontFromLayout( 
       
   255         const TRect& aParent, 
       
   256         const TAknTextComponentLayout& aComponentLayout,
       
   257         TRect& aTextRect );
       
   258 
       
   259     /**
       
   260      * Provides popup rect.
       
   261      * 
       
   262      * @param aWindowVariety Window variety.
       
   263      * @param aRect Layout defined popup rect.
       
   264      */
       
   265     static void GetPopupRect( const TInt& aWindowVariety, TRect& aRect );
       
   266 
       
   267 private: // data
       
   268 
       
   269     /**
       
   270      * Popup control of this drawer.
       
   271      * Not own.
       
   272      */
       
   273     CAknDiscreetPopupControl* iControl;
       
   274 
       
   275     /**
       
   276      * First line of text.
       
   277      * Own.
       
   278      */
       
   279     HBufC* iTitleText;
       
   280 
       
   281     /**
       
   282      * Second line of text, can be null.
       
   283      * Own.
       
   284      */
       
   285     HBufC* iBodyText;
       
   286 
       
   287     /**
       
   288      * Icon, can be null.
       
   289      * Own.
       
   290      */
       
   291     CGulIcon* iIcon;
       
   292 
       
   293     /**
       
   294      * Popup layout type.
       
   295      */
       
   296     TInt iPopupLayoutType;
       
   297 
       
   298     /**
       
   299      * Icon rect.
       
   300      */
       
   301     TRect iIconRect;
       
   302 
       
   303     /**
       
   304      * Title text field data.
       
   305      */
       
   306     TAknDiscreetPopupTextData iTitleTextData;
       
   307 
       
   308     /**
       
   309      * Body text field data.
       
   310      */
       
   311     TAknDiscreetPopupTextData iBodyTextData;
       
   312 
       
   313     /**
       
   314      * ETrue if popup has action when tapped.
       
   315      */
       
   316     TBool iAction;
       
   317 
       
   318     };
       
   319 
       
   320 
       
   321 #endif // C_AKNDISCREETPOPUPDRAWER_H