1.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
1.2 +++ b/os/graphics/windowing/windowserverplugins/openwfc/src/debugbardrawer.cpp Fri Jun 15 03:10:57 2012 +0200
1.3 @@ -0,0 +1,71 @@
1.4 +// Copyright (c) 2008-2009 Nokia Corporation and/or its subsidiary(-ies).
1.5 +// All rights reserved.
1.6 +// This component and the accompanying materials are made available
1.7 +// under the terms of "Eclipse Public License v1.0"
1.8 +// which accompanies this distribution, and is available
1.9 +// at the URL "http://www.eclipse.org/legal/epl-v10.html".
1.10 +//
1.11 +// Initial Contributors:
1.12 +// Nokia Corporation - initial contribution.
1.13 +//
1.14 +// Contributors:
1.15 +//
1.16 +// Description:
1.17 +//
1.18 +
1.19 +#include "debugbardrawer.h"
1.20 +
1.21 +CDebugBarDrawer::~CDebugBarDrawer()
1.22 + {
1.23 + if(iFontStore && iFont)
1.24 + iFontStore->ReleaseFont(iFont);
1.25 + delete iFontStore;
1.26 + iGc=NULL;
1.27 + }
1.28 +
1.29 +CDebugBarDrawer::CDebugBarDrawer(CWsRenderStage* aRenderStage, TInt aScreenWidth):
1.30 + iRenderStage(aRenderStage), iScreenWidth(aScreenWidth)
1.31 + {}
1.32 +
1.33 +void CDebugBarDrawer::ConstructL()
1.34 + {
1.35 + iGc = iRenderStage->ObjectInterface<MWsGraphicsContext>();
1.36 + TFontSpec fspec(_L("DejaVu Sans Condensed"), KFontHeightInPixel);
1.37 + iFontStore = CFbsTypefaceStore::NewL(NULL);
1.38 + User::LeaveIfError(iFontStore->GetNearestFontToDesignHeightInPixels(iFont, fspec));
1.39 + iBaseline = (iFont->BaselineOffsetInPixels() + iFont->AscentInPixels());
1.40 + }
1.41 +
1.42 +CDebugBarDrawer* CDebugBarDrawer::NewL(CWsRenderStage* aRenderStage, TInt aScreenWidth)
1.43 + {
1.44 + CDebugBarDrawer* self = new(ELeave) CDebugBarDrawer(aRenderStage, aScreenWidth);
1.45 + CleanupStack::PushL(self);
1.46 + self->ConstructL();
1.47 + CleanupStack::Pop(self);
1.48 + return self;
1.49 + }
1.50 +
1.51 +void CDebugBarDrawer::DrawDebugBar(const TArray<TPtrC>& aDebugText)
1.52 + {
1.53 + if (iDebugBarRect.IsEmpty())
1.54 + {
1.55 + iDebugBarRect=TRect(TSize(iScreenWidth, KFontHeightInPixel*aDebugText.Count()));
1.56 + }
1.57 + TRegionFix<1> iBarRegion=TRegionFix<1>(iDebugBarRect);
1.58 + iRenderStage->Begin(&iBarRegion);
1.59 + iGc->Reset();
1.60 + iGc->SetDrawMode(MWsGraphicsContext::EDrawModePEN);
1.61 + iGc->SetPenColor(KRgbWhite);
1.62 + iGc->SetPenStyle(MWsGraphicsContext::ESolidPen);
1.63 + iGc->SetBrushStyle(MWsGraphicsContext::ESolidBrush);
1.64 + iGc->SetBrushColor(KRgbBlack);
1.65 + iGc->DrawRect(iDebugBarRect);
1.66 + iGc->SetFont(iFont);
1.67 + for (TInt k = 0; k < aDebugText.Count(); k++)
1.68 + {
1.69 + iGc->DrawText(aDebugText[k], NULL, TPoint(0, iBaseline*(k+1)+2));
1.70 + }
1.71 + iRenderStage->End(NULL);
1.72 + }
1.73 +
1.74 +