📄 biaofengbasecontrol.cpp
字号:
/*
* BiaofengBaseControl.cpp
*
* Created on: 2009-4-24
* Author: IBM
*/
#include "BiaofengBaseControl.h"
#include "BiaoCommContainer.h"
//////////////////////////////////////////////////////////////////////////////
//
// -----> CSmileyDialog(implementation)
//
//////////////////////////////////////////////////////////////////////////////
TBool CSmileyDialog::RunDlgLD()
{
// CEikDialog* dialog = new (ELeave) CSmileyDialog();
// return (dialog->ExecuteLD(R_SMILEY_DIALOG));
}
// This function is used by CEikForm::ConstructByTypeL() to create the custom
// control within the dialog.
SEikControlInfo CSmileyDialog::CreateCustomControlL(TInt aControlType)
{
SEikControlInfo controlInfo;
controlInfo.iControl = NULL;
controlInfo.iTrailerTextId = 0;
controlInfo.iFlags = 0;
switch (aControlType)
{
case ESmileyControl:
controlInfo.iControl = new(ELeave) CSmileyContainer;
break;
default:
break;
}
return controlInfo;
}
//////////////////////////////////////////////////////////////////////////////
//
// -----> CSmiley (implementation)
//
//////////////////////////////////////////////////////////////////////////////
// CSmiley doesn't need a ConstructL() because it's a simple control.
CSmiley::CSmiley(TBool aSmiling) : iSmiling(aSmiling)
{
}
CSmiley::~CSmiley()
{
}
TBool CSmiley::IsSmiling()
{
return iSmiling;
}
void CSmiley::Draw(const TRect& aRect) const
{
CWindowGc& gc=SystemGc();
if (IsFocused())
{
gc.SetPenColor(KRgbBlack);
}
else
{
gc.SetPenColor(KRgbWhite);
}
gc.SetBrushColor(KRgbWhite);
gc.Clear(Rect());
gc.DrawRect(Rect());
gc.SetClippingRect(aRect);
// Draw the smiley face, smiling or looking sad
gc.SetPenColor(KRgbBlack);
// Draw a circle for the face
gc.DrawEllipse(iSmileyRect);
// Draw the eyes
TPoint leftEye(iSmileyWidth/3, iSmileyHeight/3);
TPoint rightEye(iSmileyWidth*2/3, iSmileyHeight/3);
gc.SetPenSize(TSize(5,5));
gc.Plot(iSmileyRect.iTl+leftEye);
gc.Plot(iSmileyRect.iTl+rightEye);
//Draw the mouth, smiling or looking sad.
gc.SetPenSize(TSize(1,1));
gc.SetPenColor(KRgbWhite);
if (iSmiling)
gc.DrawArc(iFrownRect, iFrownRect.iTl+TPoint(iSmileyWidth/2,iFrownRect.Height()/2),
iFrownRect.iTl+TPoint(0,iFrownRect.Height()/2));
else
gc.DrawArc(iSmileRect, iSmileRect.iTl+TPoint(0,iSmileRect.Height()/2),
iSmileRect.iTl+TPoint(iSmileyWidth/2,iSmileRect.Height()/2));
gc.SetPenColor(KRgbBlack);
if (iSmiling)
gc.DrawArc(iSmileRect, iSmileRect.iTl+TPoint(0,iSmileRect.Height()/2),
iSmileRect.iTl+TPoint(iSmileyWidth/2,iSmileRect.Height()/2));
else
gc.DrawArc(iFrownRect, iFrownRect.iTl+TPoint(iSmileyWidth/2,iFrownRect.Height()/2),
iFrownRect.iTl+TPoint(0,iFrownRect.Height()/2));
}
void CSmiley::SizeChanged()
{
// Calculate sizes of rectangles for drawing face and mouth
iSmileyRect=Rect();
// Allow room for the focus rectangle round the outside
iSmileyRect.Shrink(3,3);
iSmileyWidth=iSmileyRect.Width();
iSmileyHeight=iSmileyRect.Height();
iSmileRect.SetRect(iSmileyRect.iTl+TPoint(iSmileyWidth/4, iSmileyHeight/2),
TSize(iSmileyWidth/2, iSmileyHeight/3));
iFrownRect.SetRect(iSmileyRect.iTl+TPoint(iSmileyWidth/4, iSmileyHeight*2/3),
TSize(iSmileyWidth/2, iSmileyHeight/3));
}
void CSmiley::FocusChanged(TDrawNow aDrawNow)
{
if (aDrawNow)
DrawNow();
}
void CSmiley::HandlePointerEventL(const TPointerEvent& aPointerEvent)
{
if (aPointerEvent.iType==TPointerEvent::EButton1Down)
{
iSmiling = !iSmiling;
DrawNow();
}
}
TKeyResponse CSmiley::OfferKeyEventL(const TKeyEvent& aKeyEvent,TEventCode aType)
{
// The space bar changes the "mood" of the CSmiley.
if (aType==EEventKey && aKeyEvent.iScanCode==EStdKeySpace)
{
iSmiling = !iSmiling;
DrawNow();
return EKeyWasConsumed;
}
else
{
return EKeyWasNotConsumed;
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -