extras/about/src/AboutImage.cpp
branchRCL_3
changeset 21 10c6e6d6e4d9
child 22 bec11adf88f9
equal deleted inserted replaced
20:41b775cdc0c8 21:10c6e6d6e4d9
       
     1 /*
       
     2 * Copyright (c) 2002 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: offer bitmap for application.
       
    15 *
       
    16 */
       
    17 
       
    18 
       
    19 // INCLUDE FILES
       
    20 #include <fbs.h>
       
    21 #include "AboutImage.h"
       
    22 #include <AknIconUtils.h>
       
    23 #include <aknenv.h>
       
    24 #include <AknUtils.h>
       
    25 #include <aknconsts.h>
       
    26 #include <AknBidiTextUtils.h>
       
    27 #include <AknsDrawUtils.h> 
       
    28 #include <AknsBasicBackgroundControlContext.h>
       
    29 #include <AknsConstants.h>
       
    30 #include <AknDef.h>
       
    31 
       
    32 
       
    33 const TInt QtnJavaLogoWidth  = 46;
       
    34 const TInt QtnJavaLogoHeight = 70;
       
    35 
       
    36 // ================= MEMBER FUNCTIONS ==========================================
       
    37 
       
    38 CAboutImage::CAboutImage()
       
    39     {
       
    40     }
       
    41 
       
    42 CAboutImage::~CAboutImage()
       
    43     {
       
    44     delete iBitmap;
       
    45     delete iBitmapMask;
       
    46     }
       
    47 
       
    48 CAboutImage* CAboutImage::NewLC( const TDesC& aFileName,
       
    49                                  TInt aBitmapId,
       
    50                                  TInt aStartLine,
       
    51                                  TInt aBaseLineDelta,
       
    52                                  TBool aTypeFlag )
       
    53     {
       
    54     CAboutImage* self = new( ELeave ) CAboutImage();
       
    55     CleanupStack::PushL( self );
       
    56 
       
    57     if( aTypeFlag )
       
    58     	{
       
    59     	// bmp files
       
    60 	self->iBitmap  = AknIconUtils::CreateIconL(aFileName, aBitmapId );
       
    61     	}
       
    62     else
       
    63     	{
       
    64     	// svg files
       
    65     	MAknsSkinInstance* skinInstance = AknsUtils::SkinInstance();
       
    66     	AknsUtils::CreateIconL( skinInstance, KAknsIIDQgnMenuSmsvoLst, self->iBitmap, self->iBitmapMask, 
       
    67 					aFileName, aBitmapId, aBitmapId + 1 );
       
    68     	AknIconUtils::SetSize( self->iBitmap, TSize( QtnJavaLogoWidth, QtnJavaLogoHeight ) );
       
    69     	AknIconUtils::SetSize( self->iBitmapMask, TSize( QtnJavaLogoWidth, QtnJavaLogoHeight ) );
       
    70     	}
       
    71     self->iStartLine = aStartLine;
       
    72 
       
    73     // enough lines so that image and margins fit in them.
       
    74 
       
    75     TInt lines( ( self->HeightInPixels() + 
       
    76                   KImageTopMargin + 
       
    77                   KImageBottomMargin +
       
    78                   aBaseLineDelta - 1 ) / aBaseLineDelta );
       
    79 
       
    80     self->iEndLine = aStartLine + lines - 1;
       
    81     return self;
       
    82     }
       
    83 
       
    84 // -----------------------------------------------------------------------------
       
    85 // CAboutImage::HeightInPixels()
       
    86 // -----------------------------------------------------------------------------
       
    87 
       
    88 TInt CAboutImage::HeightInPixels() const
       
    89     {
       
    90     return iBitmap->SizeInPixels().iHeight;
       
    91     }
       
    92 
       
    93 // -----------------------------------------------------------------------------
       
    94 // CAboutImage::WidthInPixels()
       
    95 // -----------------------------------------------------------------------------
       
    96 
       
    97 TInt CAboutImage::WidthInPixels() const
       
    98     {
       
    99     return iBitmap->SizeInPixels().iWidth;
       
   100     }
       
   101 
       
   102 // -----------------------------------------------------------------------------
       
   103 // CAboutImage::StartLine()
       
   104 // -----------------------------------------------------------------------------
       
   105 
       
   106 TInt CAboutImage::StartLine() const
       
   107     {
       
   108     return iStartLine;
       
   109     }
       
   110 
       
   111 // -----------------------------------------------------------------------------
       
   112 // CAboutImage::EndLine()
       
   113 // -----------------------------------------------------------------------------
       
   114 
       
   115 TInt CAboutImage::EndLine() const
       
   116     {
       
   117     return iEndLine;
       
   118     }
       
   119 
       
   120 // -----------------------------------------------------------------------------
       
   121 // CAboutImage::Lines()
       
   122 // -----------------------------------------------------------------------------
       
   123 
       
   124 TInt CAboutImage::Lines() const
       
   125     {
       
   126     return iEndLine - iStartLine + 1;
       
   127     }
       
   128 
       
   129 // -----------------------------------------------------------------------------
       
   130 // CAboutImage::Bitmap()
       
   131 // -----------------------------------------------------------------------------
       
   132 
       
   133 const CFbsBitmap* CAboutImage::Bitmap() const
       
   134     {
       
   135     return iBitmap;
       
   136     }
       
   137 
       
   138 // -----------------------------------------------------------------------------
       
   139 // CAboutImage::BitmapMask()
       
   140 // -----------------------------------------------------------------------------
       
   141 
       
   142 const CFbsBitmap* CAboutImage::BitmapMask() const
       
   143 	{
       
   144 	return iBitmapMask;
       
   145 	}
       
   146 // End of File