|
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". |
|
7 // |
|
8 // Initial Contributors: |
|
9 // Nokia Corporation - initial contribution. |
|
10 // |
|
11 // Contributors: |
|
12 // |
|
13 // Description: |
|
14 // |
|
15 |
|
16 #include "debugbardrawer.h" |
|
17 |
|
18 CDebugBarDrawer::~CDebugBarDrawer() |
|
19 { |
|
20 if(iFontStore && iFont) |
|
21 iFontStore->ReleaseFont(iFont); |
|
22 delete iFontStore; |
|
23 iGc=NULL; |
|
24 } |
|
25 |
|
26 CDebugBarDrawer::CDebugBarDrawer(CWsRenderStage* aRenderStage, TInt aScreenWidth): |
|
27 iRenderStage(aRenderStage), iScreenWidth(aScreenWidth) |
|
28 {} |
|
29 |
|
30 void CDebugBarDrawer::ConstructL() |
|
31 { |
|
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()); |
|
37 } |
|
38 |
|
39 CDebugBarDrawer* CDebugBarDrawer::NewL(CWsRenderStage* aRenderStage, TInt aScreenWidth) |
|
40 { |
|
41 CDebugBarDrawer* self = new(ELeave) CDebugBarDrawer(aRenderStage, aScreenWidth); |
|
42 CleanupStack::PushL(self); |
|
43 self->ConstructL(); |
|
44 CleanupStack::Pop(self); |
|
45 return self; |
|
46 } |
|
47 |
|
48 void CDebugBarDrawer::DrawDebugBar(const TArray<TPtrC>& aDebugText) |
|
49 { |
|
50 if (iDebugBarRect.IsEmpty()) |
|
51 { |
|
52 iDebugBarRect=TRect(TSize(iScreenWidth, KFontHeightInPixel*aDebugText.Count())); |
|
53 } |
|
54 TRegionFix<1> iBarRegion=TRegionFix<1>(iDebugBarRect); |
|
55 iRenderStage->Begin(&iBarRegion); |
|
56 iGc->Reset(); |
|
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); |
|
63 iGc->SetFont(iFont); |
|
64 for (TInt k = 0; k < aDebugText.Count(); k++) |
|
65 { |
|
66 iGc->DrawText(aDebugText[k], NULL, TPoint(0, iBaseline*(k+1)+2)); |
|
67 } |
|
68 iRenderStage->End(NULL); |
|
69 } |
|
70 |
|
71 |