Nokia N97 SDK
Example Applications Guide

localizationappview.cpp

00001 /*
00002 * ==============================================================================
00003 *  Name        : localizationappview.cpp
00004 *  Part of     : localization
00005 *  Interface   :
00006 *  Description : 
00007 *  Version     :
00008 *
00009 *  Copyright (c) 2005 - 2007 Nokia Corporation.
00010 *  This material, including documentation and any related
00011 *  computer programs, is protected by copyright controlled by
00012 *  Nokia Corporation.
00013 * ==============================================================================
00014 */
00015 
00016 
00017 
00018 // INCLUDE FILES
00019 #include <coemain.h>
00020 #include "LocalizationAppView.h"
00021 
00022 // ============================ MEMBER FUNCTIONS ===============================
00023 
00024 // -----------------------------------------------------------------------------
00025 // CLocalizationAppView::NewL()
00026 // Two-phased constructor.
00027 // -----------------------------------------------------------------------------
00028 //
00029 CLocalizationAppView* CLocalizationAppView::NewL( const TRect& aRect )
00030     {
00031     CLocalizationAppView* self = CLocalizationAppView::NewLC( aRect );
00032     CleanupStack::Pop( self );
00033     return self;
00034     }
00035 
00036 // -----------------------------------------------------------------------------
00037 // CLocalizationAppView::NewLC()
00038 // Two-phased constructor.
00039 // -----------------------------------------------------------------------------
00040 //
00041 CLocalizationAppView* CLocalizationAppView::NewLC( const TRect& aRect )
00042     {
00043     CLocalizationAppView* self = new ( ELeave ) CLocalizationAppView;
00044     CleanupStack::PushL( self );
00045     self->ConstructL( aRect );
00046     return self;
00047     }
00048 
00049 // -----------------------------------------------------------------------------
00050 // CLocalizationAppView::ConstructL()
00051 // Symbian 2nd phase constructor can leave.
00052 // -----------------------------------------------------------------------------
00053 //
00054 void CLocalizationAppView::ConstructL( const TRect& aRect )
00055     {
00056     // Create a window for this application view
00057     CreateWindowL();
00058 
00059     // Set the windows size
00060     SetRect( aRect );
00061 
00062     // Activate the window, which makes it ready to be drawn
00063     ActivateL();
00064     }
00065 
00066 // -----------------------------------------------------------------------------
00067 // CLocalizationAppView::CLocalizationAppView()
00068 // C++ default constructor can NOT contain any code, that might leave.
00069 // -----------------------------------------------------------------------------
00070 //
00071 CLocalizationAppView::CLocalizationAppView()
00072 : iImage(0)
00073     {
00074     // No implementation required
00075     }
00076 
00077 
00078 // -----------------------------------------------------------------------------
00079 // CLocalizationAppView::~CLocalizationAppView()
00080 // Destructor.
00081 // -----------------------------------------------------------------------------
00082 //
00083 CLocalizationAppView::~CLocalizationAppView()
00084     {
00085     // No implementation required
00086     delete iImage;
00087     }
00088 
00089 
00090 // ---------------------------------------------------------------------------
00091 // CLocalizationAppView::DrawImage()
00092 // Draw the image on the display.
00093 // ---------------------------------------------------------------------------
00094 //
00095 void CLocalizationAppView::DrawImage(CFbsBitmap* aImage)
00096     {
00097     delete iImage;
00098     iImage = aImage;
00099     DrawNow();
00100     }
00101 
00102 // -----------------------------------------------------------------------------
00103 // CLocalizationAppView::Draw()
00104 // Draws the display.
00105 // -----------------------------------------------------------------------------
00106 //
00107 void CLocalizationAppView::Draw( const TRect& /*aRect*/ ) const
00108     {
00109     // Get the standard graphics context
00110     CWindowGc& gc = SystemGc();
00111 
00112     // Gets the control's extent
00113     TRect drawRect( Rect());
00114     
00115     // Clears the screen
00116     gc.Clear( drawRect );
00117     
00118     if(iImage)
00119         {
00120         // Show the bitmap double size and centered to screen
00121         TInt scrWidth = Rect().Width();
00122         TInt scrHeight = Rect().Height();
00123         TInt bmpWidth = iImage->SizeInPixels().iWidth;
00124         TInt bmpHeight = iImage->SizeInPixels().iHeight;
00125         TInt aX = ( scrWidth - bmpWidth * 2 ) / 2;
00126         TInt aY = ( scrHeight - bmpHeight * 2 ) / 2;
00127         TInt bX = aX + bmpWidth * 2;
00128         TInt bY = aY + bmpHeight * 2;
00129         
00130         drawRect.SetRect( aX, aY, bX, bY );
00131         gc.DrawBitmap ( drawRect, iImage );
00132         }
00133         }
00134 
00135 // -----------------------------------------------------------------------------
00136 // CLocalizationAppView::SizeChanged()
00137 // Called by framework when the view size is changed.
00138 // -----------------------------------------------------------------------------
00139 //
00140 void CLocalizationAppView::SizeChanged()
00141     {  
00142     DrawNow();
00143     }
00144 // End of File

© Nokia 2009

Back to top