sl@0: // Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies). sl@0: // All rights reserved. sl@0: // This component and the accompanying materials are made available sl@0: // under the terms of "Eclipse Public License v1.0" sl@0: // which accompanies this distribution, and is available sl@0: // at the URL "http://www.eclipse.org/legal/epl-v10.html". sl@0: // sl@0: // Initial Contributors: sl@0: // Nokia Corporation - initial contribution. sl@0: // sl@0: // Contributors: sl@0: // sl@0: // Description: sl@0: // sl@0: sl@0: /** sl@0: @file sl@0: @test sl@0: @internalComponent - Internal Symbian test code sl@0: */ sl@0: sl@0: sl@0: #include "tsmallwindowraster.h" sl@0: sl@0: sl@0: _LIT(KBitmapPattern, "*.mbm"); sl@0: sl@0: sl@0: CTSmallWindowRaster::CTSmallWindowRaster(const TPoint& aStartingPoint, const TSize& aWindowSize) : sl@0: CTWindow(aStartingPoint, aWindowSize) sl@0: { sl@0: // empty sl@0: } sl@0: sl@0: CTSmallWindowRaster::~CTSmallWindowRaster() sl@0: { sl@0: if (iGc) sl@0: { sl@0: iGc->Deactivate(); sl@0: delete iGc; sl@0: } sl@0: delete iSourceBitmap; sl@0: delete iScreenDev; sl@0: } sl@0: sl@0: CTWindow* CTSmallWindowRaster::NewL(RWsSession &aWs, sl@0: const RWindowTreeNode &aParent, sl@0: const TPoint& aStartingPoint, sl@0: const TSize& aWindowSize) sl@0: { sl@0: CTSmallWindowRaster* self = new (ELeave) CTSmallWindowRaster(aStartingPoint, aWindowSize); sl@0: CleanupStack::PushL(self); sl@0: self->ConstructL(aWs, aParent); sl@0: CleanupStack::Pop(self); sl@0: return self; sl@0: } sl@0: sl@0: void CTSmallWindowRaster::ConstructL(RWsSession &aWs, const RWindowTreeNode &aParent) sl@0: { sl@0: CTWindow::ConstructL(aWs, aParent); sl@0: iScreenDev = new (ELeave) CWsScreenDevice(aWs); sl@0: User::LeaveIfError(iScreenDev->Construct()); sl@0: iGc = new (ELeave)CWindowGc(iScreenDev); sl@0: User::LeaveIfError(iGc->Construct()); sl@0: iGc->Activate(iWindow); sl@0: } sl@0: sl@0: void CTSmallWindowRaster::LoadL(CSurfaceUtility* /*aUtility*/, TPtrC aFileName) sl@0: { sl@0: iLoaded = ETrue; sl@0: if (aFileName.Match(KBitmapPattern()) != KErrNotFound) // it's a Bitmap sl@0: { sl@0: iSourceBitmap = new(ELeave) CFbsBitmap(); sl@0: User::LeaveIfError(iSourceBitmap->Load(aFileName, 0)); sl@0: } sl@0: else sl@0: { sl@0: iSourceBitmap = CreateBitmapFromFileL(aFileName); sl@0: } sl@0: iSourceRect = iSourceBitmap->SizeInPixels(); sl@0: iDestRect = TRect(Size()); sl@0: } sl@0: sl@0: void CTSmallWindowRaster::DrawBitmap(TRect& aSourceRect) sl@0: { sl@0: iWindow.BeginRedraw(); sl@0: iGc->DrawBitmap(iDestRect, iSourceBitmap, aSourceRect); sl@0: iWindow.EndRedraw(); sl@0: } sl@0: sl@0: void CTSmallWindowRaster::RenderL() sl@0: { sl@0: CTWindow::RenderL(); sl@0: if (iLoaded) sl@0: { sl@0: DrawBitmap(iSourceRect); sl@0: } sl@0: }