// EIKFPREV.CPP
//
// Copyright (c) 1997-1999 Symbian Ltd.  All rights reserved.
//

#include <eikfprev.h>
#include <barsread.h>
#include <w32std.h>

EXPORT_C CEikFontPreviewLabel::CEikFontPreviewLabel()
	{
	iBackgroundColor=KRgbWhite;
	iPenColor=KRgbBlack;
	}

EXPORT_C CEikFontPreviewLabel::~CEikFontPreviewLabel()
	{
	}

EXPORT_C void CEikFontPreviewLabel::ConstructFromResourceL(TResourceReader& aReader)
	{
	TInt width=aReader.ReadInt16();
	TInt height=aReader.ReadInt16();
	iMinSize=TSize(width,height);
	SetTextL(aReader.ReadTPtrC());
	}

EXPORT_C TSize CEikFontPreviewLabel::MinimumSize()
	{
	if (iMinSize.iWidth && iMinSize.iHeight)
		return iMinSize;
	return CEikLabel::MinimumSize();
	}

EXPORT_C void CEikFontPreviewLabel::SetUnderline(TFontUnderline aUnderline)
	{
	if (aUnderline==EUnderlineOn)
		iLabFlags|=EUnderline;
	else
		iLabFlags&=~EUnderline;
	}

EXPORT_C void CEikFontPreviewLabel::SetStrikethrough(TFontStrikethrough aStrikethrough)
	{
	if (aStrikethrough==EStrikethroughOn)
		iLabFlags|=EStrikethrough;
	else
		iLabFlags&=~EStrikethrough;
	}

EXPORT_C void CEikFontPreviewLabel::Draw(const TRect& /*aRect*/) const
	{
	CWindowGc& gc=SystemGc();
	gc.UseFont(iFont);
	gc.SetBrushStyle(CGraphicsContext::ESolidBrush);
	gc.SetBrushColor(iBackgroundColor);
	gc.SetPenColor(iPenColor);
	if (iLabFlags&EUnderline)
		gc.SetUnderlineStyle(EUnderlineOn);
	if (iLabFlags&EStrikethrough)
		gc.SetStrikethroughStyle(EStrikethroughOn);
	TRect rect=Rect();
	TInt ascent=iFont->AscentInPixels()+(rect.iBr.iY-rect.iTl.iY-iFont->HeightInPixels())/2;
	gc.DrawText(*iText,rect,ascent,CGraphicsContext::ELeft);
	}
