📄 labelcontainer.cpp
字号:
/*
* ============================================================================
* Name : CLabelContainer from LabelContainer.h
* Part of : Label
* Created : 22.02.2006 by ToBeReplacedByAuthorToBeReplacedByAuthor
* Implementation notes:
* Initial content was generated by Series 60 Application Wizard.
* Version :
* Copyright: ToBeReplacedByCopyright
* ============================================================================
*/
// INCLUDE FILES
#include "LabelContainer.h"
#include <eiklabel.h> // for example label control
#include <AknUtils.h> // for font
// ================= MEMBER FUNCTIONS =======================
// ---------------------------------------------------------
// CLabelContainer::ConstructL(const TRect& aRect)
// EPOC two phased constructor
// ---------------------------------------------------------
//
void CLabelContainer::ConstructL(const TRect& aRect)
{
CreateWindowL();
//iStartPoint = TPoint (10, 10);
//rectLabel.iBr= TPoint(150, 30);
iLabel = new (ELeave) CEikLabel;
iLabel->SetContainerWindowL( *this );
iLabel->SetTextL( _L("Simple Label") );
iLabel->SetExtent( TPoint(10, 10), TSize (150, 30));
SetLabelStyle(1);
SetRect(aRect);
ActivateL();
}
// Destructor
CLabelContainer::~CLabelContainer()
{
delete iLabel;
}
// ---------------------------------------------------------
// CLabelContainer::SizeChanged()
// Called by framework when the view size is changed
// ---------------------------------------------------------
//
void CLabelContainer::SizeChanged()
{
// TODO: Add here control resize code etc.
//iLabel->SetExtent( TPoint(10,10), iLabel->MinimumSize() );
iLabel->SetExtent( TPoint(10, 10), TSize (150, 30));
}
// ---------------------------------------------------------
// CLabelContainer::CountComponentControls() const
// ---------------------------------------------------------
//
TInt CLabelContainer::CountComponentControls() const
{
return 1; // return nbr of controls inside this container
}
// ---------------------------------------------------------
// CLabelContainer::ComponentControl(TInt aIndex) const
// ---------------------------------------------------------
//
CCoeControl* CLabelContainer::ComponentControl(TInt aIndex) const
{
switch ( aIndex )
{
case 0:
return iLabel;
default:
return NULL;
}
}
// ---------------------------------------------------------
// CLabelContainer::Draw(const TRect& aRect) const
// ---------------------------------------------------------
//
void CLabelContainer::Draw(const TRect& aRect) const
{
CWindowGc& gc = SystemGc();
// TODO: Add your drawing code here
// example code...
gc.SetPenStyle( CGraphicsContext::ENullPen );
gc.SetBrushColor( KRgbGray );
gc.SetBrushStyle( CGraphicsContext::ESolidBrush );
gc.DrawRect( aRect );
gc.SetBrushColor( KRgbWhite);
TRect rect;
rect.iTl = TPoint (10, 10);
rect.SetSize(TSize (150, 30 ));
gc.SetPenStyle ( CGraphicsContext::ESolidPen);
gc.DrawRect (rect );
}
// ---------------------------------------------------------
// CLabelContainer::HandleControlEventL(
// CCoeControl* aControl,TCoeEvent aEventType)
// ---------------------------------------------------------
//
void CLabelContainer::HandleControlEventL(
CCoeControl* /*aControl*/,TCoeEvent /*aEventType*/)
{
// TODO: Add your control event handler code here
}
void CLabelContainer::HandleCommandL(TInt aCommand)
{
SetLabelStyle(aCommand);
}
void CLabelContainer::SetLabelStyle (TInt aStyle)
{
switch (aStyle)
{
case 1:
{
iLabel ->SetAlignment (EHLeftVTop) ;
iLabel->SetFont( LatinBold12() );
iLabel->SetStrikethrough(EFalse);
iLabel->SetUnderlining(EFalse);
break;
}
case 2:
{
iLabel ->SetAlignment( EHCenterVCenter );
iLabel->SetFont( LatinBold19() );
iLabel->SetStrikethrough(EFalse);
iLabel->SetUnderlining(ETrue);
break;
}
case 3:
{
iLabel ->SetAlignment( EHRightVBottom );
iLabel->SetFont( LatinBold17() );
iLabel->SetStrikethrough(ETrue);
iLabel->SetUnderlining(EFalse);
break;
}
}
}
// End of File
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -