First public contribution.
1 // Copyright (c) 2008-2009 Nokia Corporation and/or its subsidiary(-ies).
2 // All rights reserved.
3 // This component and the accompanying materials are made available
4 // under the terms of "Eclipse Public License v1.0"
5 // which accompanies this distribution, and is available
6 // at the URL "http://www.eclipse.org/legal/epl-v10.html".
8 // Initial Contributors:
9 // Nokia Corporation - initial contribution.
16 #include "debugbardrawer.h"
18 CDebugBarDrawer::~CDebugBarDrawer()
20 if(iFontStore && iFont)
21 iFontStore->ReleaseFont(iFont);
26 CDebugBarDrawer::CDebugBarDrawer(CWsRenderStage* aRenderStage, TInt aScreenWidth):
27 iRenderStage(aRenderStage), iScreenWidth(aScreenWidth)
30 void CDebugBarDrawer::ConstructL()
32 iGc = iRenderStage->ObjectInterface<MWsGraphicsContext>();
33 TFontSpec fspec(_L("DejaVu Sans Condensed"), KFontHeightInPixel);
34 iFontStore = CFbsTypefaceStore::NewL(NULL);
35 User::LeaveIfError(iFontStore->GetNearestFontToDesignHeightInPixels(iFont, fspec));
36 iBaseline = (iFont->BaselineOffsetInPixels() + iFont->AscentInPixels());
39 CDebugBarDrawer* CDebugBarDrawer::NewL(CWsRenderStage* aRenderStage, TInt aScreenWidth)
41 CDebugBarDrawer* self = new(ELeave) CDebugBarDrawer(aRenderStage, aScreenWidth);
42 CleanupStack::PushL(self);
44 CleanupStack::Pop(self);
48 void CDebugBarDrawer::DrawDebugBar(const TArray<TPtrC>& aDebugText)
50 if (iDebugBarRect.IsEmpty())
52 iDebugBarRect=TRect(TSize(iScreenWidth, KFontHeightInPixel*aDebugText.Count()));
54 TRegionFix<1> iBarRegion=TRegionFix<1>(iDebugBarRect);
55 iRenderStage->Begin(&iBarRegion);
57 iGc->SetDrawMode(MWsGraphicsContext::EDrawModePEN);
58 iGc->SetPenColor(KRgbWhite);
59 iGc->SetPenStyle(MWsGraphicsContext::ESolidPen);
60 iGc->SetBrushStyle(MWsGraphicsContext::ESolidBrush);
61 iGc->SetBrushColor(KRgbBlack);
62 iGc->DrawRect(iDebugBarRect);
64 for (TInt k = 0; k < aDebugText.Count(); k++)
66 iGc->DrawText(aDebugText[k], NULL, TPoint(0, iBaseline*(k+1)+2));
68 iRenderStage->End(NULL);