00001 /* 00002 Copyright (c) 2002-2011 Nokia Corporation and/or its subsidiary(-ies). All rights reserved. 00003 00004 Redistribution and use in source and binary forms, with or without 00005 modification, are permitted provided that the following conditions are met: 00006 00007 * Redistributions of source code must retain the above copyright notice, this 00008 list of conditions and the following disclaimer. 00009 * Redistributions in binary form must reproduce the above copyright notice, 00010 this list of conditions and the following disclaimer in the documentation 00011 and/or other materials provided with the distribution. 00012 * Neither the name of Nokia Corporation nor the names of its contributors 00013 may be used to endorse or promote products derived from this software 00014 without specific prior written permission. 00015 00016 THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" 00017 AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 00018 IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 00019 DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE 00020 FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 00021 DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR 00022 SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER 00023 CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, 00024 OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 00025 OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 00026 00027 Description: 00028 */ 00029 #include <eiklabel.h> 00030 #include <eikenv.h> 00031 00032 #include "ImageContainer.h" 00033 #include <aknutils.h> 00034 00035 /* 00036 ----------------------------------------------------------------------------- 00037 ----------------------------------------------------------------------------- 00038 */ 00039 CImageContainer* CImageContainer::NewL( const TRect& aRect,const TDesC& aFileName) 00040 { 00041 CImageContainer* self = CImageContainer::NewLC( aRect,aFileName); 00042 CleanupStack::Pop( self ); 00043 return self; 00044 } 00045 /* 00046 ----------------------------------------------------------------------------- 00047 ----------------------------------------------------------------------------- 00048 */ 00049 CImageContainer* CImageContainer::NewLC( const TRect& aRect,const TDesC& aFileName) 00050 { 00051 CImageContainer* self = new ( ELeave ) CImageContainer; 00052 CleanupStack::PushL( self ); 00053 self->ConstructL( aRect,aFileName); 00054 return self; 00055 } 00056 /* 00057 ----------------------------------------------------------------------------- 00058 ----------------------------------------------------------------------------- 00059 */ 00060 CImageContainer::~CImageContainer() 00061 { 00062 delete iImage_Reader; 00063 } 00064 /* 00065 ----------------------------------------------------------------------------- 00066 ----------------------------------------------------------------------------- 00067 */ 00068 void CImageContainer::ConstructL( const TRect& aRect,const TDesC& aFileName) 00069 { 00070 CreateWindowL(); 00071 SetRect( aRect ); 00072 ActivateL(); 00073 DrawNow(); 00074 00075 // start image reader.. 00076 iImage_Reader = CImage_Reader::NewL(*this,aFileName); 00077 } 00078 00079 /* 00080 ----------------------------------------------------------------------------- 00081 MImageReaderCallBack callback function which CImage_Reader uses to tell 00082 this container that the image is processed. 00083 aError would tell if it succeeded or failed. 00084 ----------------------------------------------------------------------------- 00085 */ 00086 void CImageContainer::ImageReadDoneL(TInt /*aError*/) 00087 { // simply try drawing it 00088 DrawNow(); 00089 } 00090 /* 00091 ----------------------------------------------------------------------------- 00092 normal Draw funtion for CCoeControl, which is used to draw to the screen 00093 ----------------------------------------------------------------------------- 00094 */ 00095 void CImageContainer::Draw( const TRect& /*aRect*/ ) const 00096 { 00097 CWindowGc& gc = SystemGc(); 00098 00099 // clear the screen with default brush (solid white) 00100 gc.Clear(Rect()); 00101 00102 if(iImage_Reader)// check that we have image reader constructed 00103 { 00104 if(iImage_Reader->Bitmap())// check that it has constructed the bitmap 00105 { 00106 // and that the bitmap has valid data for drawing 00107 if(iImage_Reader->Bitmap()->Handle()) 00108 { 00109 // just draw the image to the whole screen 00110 // without caring about the scaling issues 00111 gc.DrawBitmap(Rect(),iImage_Reader->Bitmap()); 00112 } 00113 } 00114 } 00115 } 00116 00117 00118 /* 00119 ----------------------------------------------------------------------------- 00120 used for informinging about resource changes, 00121 in S60 one usage is to know when the layout of the screen has been changed 00122 ----------------------------------------------------------------------------- 00123 */ 00124 void CImageContainer::HandleResourceChange(TInt aType) 00125 { 00126 TRect rect; 00127 00128 if ( aType==KEikDynamicLayoutVariantSwitch )// layout change event 00129 { // get new main panel rect and set it 00130 AknLayoutUtils::LayoutMetricsRect(AknLayoutUtils::EMainPane, rect); 00131 SetRect(rect); 00132 } 00133 00134 // forward events for CCoeControl's base class handler 00135 CCoeControl::HandleResourceChange(aType); 00136 } 00137 00138 00139 00140 // End of File