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