sl@0
|
1 |
// Copyright (c) 2008-2009 Nokia Corporation and/or its subsidiary(-ies).
|
sl@0
|
2 |
// All rights reserved.
|
sl@0
|
3 |
// This component and the accompanying materials are made available
|
sl@0
|
4 |
// under the terms of "Eclipse Public License v1.0"
|
sl@0
|
5 |
// which accompanies this distribution, and is available
|
sl@0
|
6 |
// at the URL "http://www.eclipse.org/legal/epl-v10.html".
|
sl@0
|
7 |
//
|
sl@0
|
8 |
// Initial Contributors:
|
sl@0
|
9 |
// Nokia Corporation - initial contribution.
|
sl@0
|
10 |
//
|
sl@0
|
11 |
// Contributors:
|
sl@0
|
12 |
//
|
sl@0
|
13 |
// Description:
|
sl@0
|
14 |
//
|
sl@0
|
15 |
|
sl@0
|
16 |
#include "debugbardrawer.h"
|
sl@0
|
17 |
|
sl@0
|
18 |
CDebugBarDrawer::~CDebugBarDrawer()
|
sl@0
|
19 |
{
|
sl@0
|
20 |
if(iFontStore && iFont)
|
sl@0
|
21 |
iFontStore->ReleaseFont(iFont);
|
sl@0
|
22 |
delete iFontStore;
|
sl@0
|
23 |
iGc=NULL;
|
sl@0
|
24 |
}
|
sl@0
|
25 |
|
sl@0
|
26 |
CDebugBarDrawer::CDebugBarDrawer(CWsRenderStage* aRenderStage, TInt aScreenWidth):
|
sl@0
|
27 |
iRenderStage(aRenderStage), iScreenWidth(aScreenWidth)
|
sl@0
|
28 |
{}
|
sl@0
|
29 |
|
sl@0
|
30 |
void CDebugBarDrawer::ConstructL()
|
sl@0
|
31 |
{
|
sl@0
|
32 |
iGc = iRenderStage->ObjectInterface<MWsGraphicsContext>();
|
sl@0
|
33 |
TFontSpec fspec(_L("DejaVu Sans Condensed"), KFontHeightInPixel);
|
sl@0
|
34 |
iFontStore = CFbsTypefaceStore::NewL(NULL);
|
sl@0
|
35 |
User::LeaveIfError(iFontStore->GetNearestFontToDesignHeightInPixels(iFont, fspec));
|
sl@0
|
36 |
iBaseline = (iFont->BaselineOffsetInPixels() + iFont->AscentInPixels());
|
sl@0
|
37 |
}
|
sl@0
|
38 |
|
sl@0
|
39 |
CDebugBarDrawer* CDebugBarDrawer::NewL(CWsRenderStage* aRenderStage, TInt aScreenWidth)
|
sl@0
|
40 |
{
|
sl@0
|
41 |
CDebugBarDrawer* self = new(ELeave) CDebugBarDrawer(aRenderStage, aScreenWidth);
|
sl@0
|
42 |
CleanupStack::PushL(self);
|
sl@0
|
43 |
self->ConstructL();
|
sl@0
|
44 |
CleanupStack::Pop(self);
|
sl@0
|
45 |
return self;
|
sl@0
|
46 |
}
|
sl@0
|
47 |
|
sl@0
|
48 |
void CDebugBarDrawer::DrawDebugBar(const TArray<TPtrC>& aDebugText)
|
sl@0
|
49 |
{
|
sl@0
|
50 |
if (iDebugBarRect.IsEmpty())
|
sl@0
|
51 |
{
|
sl@0
|
52 |
iDebugBarRect=TRect(TSize(iScreenWidth, KFontHeightInPixel*aDebugText.Count()));
|
sl@0
|
53 |
}
|
sl@0
|
54 |
TRegionFix<1> iBarRegion=TRegionFix<1>(iDebugBarRect);
|
sl@0
|
55 |
iRenderStage->Begin(&iBarRegion);
|
sl@0
|
56 |
iGc->Reset();
|
sl@0
|
57 |
iGc->SetDrawMode(MWsGraphicsContext::EDrawModePEN);
|
sl@0
|
58 |
iGc->SetPenColor(KRgbWhite);
|
sl@0
|
59 |
iGc->SetPenStyle(MWsGraphicsContext::ESolidPen);
|
sl@0
|
60 |
iGc->SetBrushStyle(MWsGraphicsContext::ESolidBrush);
|
sl@0
|
61 |
iGc->SetBrushColor(KRgbBlack);
|
sl@0
|
62 |
iGc->DrawRect(iDebugBarRect);
|
sl@0
|
63 |
iGc->SetFont(iFont);
|
sl@0
|
64 |
for (TInt k = 0; k < aDebugText.Count(); k++)
|
sl@0
|
65 |
{
|
sl@0
|
66 |
iGc->DrawText(aDebugText[k], NULL, TPoint(0, iBaseline*(k+1)+2));
|
sl@0
|
67 |
}
|
sl@0
|
68 |
iRenderStage->End(NULL);
|
sl@0
|
69 |
}
|
sl@0
|
70 |
|
sl@0
|
71 |
|