sl@0: // Copyright (c) 2008-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: #include "debugbardrawer.h" sl@0: sl@0: CDebugBarDrawer::~CDebugBarDrawer() sl@0: { sl@0: if(iFontStore && iFont) sl@0: iFontStore->ReleaseFont(iFont); sl@0: delete iFontStore; sl@0: iGc=NULL; sl@0: } sl@0: sl@0: CDebugBarDrawer::CDebugBarDrawer(CWsRenderStage* aRenderStage, TInt aScreenWidth): sl@0: iRenderStage(aRenderStage), iScreenWidth(aScreenWidth) sl@0: {} sl@0: sl@0: void CDebugBarDrawer::ConstructL() sl@0: { sl@0: iGc = iRenderStage->ObjectInterface(); sl@0: TFontSpec fspec(_L("DejaVu Sans Condensed"), KFontHeightInPixel); sl@0: iFontStore = CFbsTypefaceStore::NewL(NULL); sl@0: User::LeaveIfError(iFontStore->GetNearestFontToDesignHeightInPixels(iFont, fspec)); sl@0: iBaseline = (iFont->BaselineOffsetInPixels() + iFont->AscentInPixels()); sl@0: } sl@0: sl@0: CDebugBarDrawer* CDebugBarDrawer::NewL(CWsRenderStage* aRenderStage, TInt aScreenWidth) sl@0: { sl@0: CDebugBarDrawer* self = new(ELeave) CDebugBarDrawer(aRenderStage, aScreenWidth); sl@0: CleanupStack::PushL(self); sl@0: self->ConstructL(); sl@0: CleanupStack::Pop(self); sl@0: return self; sl@0: } sl@0: sl@0: void CDebugBarDrawer::DrawDebugBar(const TArray& aDebugText) sl@0: { sl@0: if (iDebugBarRect.IsEmpty()) sl@0: { sl@0: iDebugBarRect=TRect(TSize(iScreenWidth, KFontHeightInPixel*aDebugText.Count())); sl@0: } sl@0: TRegionFix<1> iBarRegion=TRegionFix<1>(iDebugBarRect); sl@0: iRenderStage->Begin(&iBarRegion); sl@0: iGc->Reset(); sl@0: iGc->SetDrawMode(MWsGraphicsContext::EDrawModePEN); sl@0: iGc->SetPenColor(KRgbWhite); sl@0: iGc->SetPenStyle(MWsGraphicsContext::ESolidPen); sl@0: iGc->SetBrushStyle(MWsGraphicsContext::ESolidBrush); sl@0: iGc->SetBrushColor(KRgbBlack); sl@0: iGc->DrawRect(iDebugBarRect); sl@0: iGc->SetFont(iFont); sl@0: for (TInt k = 0; k < aDebugText.Count(); k++) sl@0: { sl@0: iGc->DrawText(aDebugText[k], NULL, TPoint(0, iBaseline*(k+1)+2)); sl@0: } sl@0: iRenderStage->End(NULL); sl@0: } sl@0: sl@0: