📄 orcfuncontainer.cpp
字号:
#include <gulicon.h> //Martin
#include <aknutils.h>
#include <avkon.hrh>
#include <akntitle.h>
#include <eiklabel.h>
#include <barsread.h> //Martin
#include <StringLoader.h> //Martin
#include <gdi.h> //Martin
#include "ORCFunContainer.h"
#include "orcer.rsg"
#include "RichTextEditorRichTextEditor.h" //Martin
CORCFunContainer::CORCFunContainer()
{
}
//Martin
CORCFunContainer* CORCFunContainer::NewL(const TRect& aRect)
{
CORCFunContainer* self = CORCFunContainer::NewLC(aRect);
CleanupStack::Pop(self);
return self;
}
CORCFunContainer* CORCFunContainer::NewLC(const TRect& aRect)
{
CORCFunContainer* self = new (ELeave) CORCFunContainer;
CleanupStack::PushL(self);
self->ConstructL(aRect);
return self;
}
//
// EPOC default constructor can leave.
void CORCFunContainer::ConstructL(const TRect& aRect)
{
CreateWindowL();
//Martin
m_pExplain = CRichTextEditorRichTextEditor::NewL();
m_pExplain->SetContainerWindowL(*this);
AddExplainEditorL();
SetRect(aRect);
ActivateL();
m_pExplain->DisplayStartOfHelpTextL();
}
// destructor
CORCFunContainer::~CORCFunContainer()
{//Martin
if (m_pExplain) {
delete m_pExplain;
}
}
void CORCFunContainer::SizeChanged()
{//Martin
m_pExplain->SetExtent(TPoint(5,5),TSize(176,90));
}
// ---------------------------------------------------------
// CORCFunContainer::CountComponentControls() const
// return the number of controls
// ---------------------------------------------------------
//
TInt CORCFunContainer::CountComponentControls() const
{
// return number of controls inside this container
return 1; //Martin
}
// ---------------------------------------------------------
// CORCFunContainer::ComponentControl(TInt aIndex) const
// return the pointer to specified control.
// ---------------------------------------------------------
//
CCoeControl* CORCFunContainer::ComponentControl( TInt aIndex ) const
{//Martin
switch(aIndex) {
case 0:
return m_pExplain;
break;
default:
return NULL;
break;
};
}
// ---------------------------------------------------------
// CORCFunContainer::Draw(const TRect& aRect) const
// handle the message when client region must be redrawn.
// ---------------------------------------------------------
//
void CORCFunContainer::Draw( const TRect& aRect ) const
{
CWindowGc& gc = SystemGc();
gc.Clear(Rect());
//Martin
gc.SetBrushStyle(CGraphicsContext::ESolidBrush);
gc.SetBrushColor(KRgbYellow);
gc.DrawRect(TRect(TPoint(5,100),TSize(166,40)));
//画字
gc.SetPenStyle( CGraphicsContext::ENullPen );
gc.SetPenColor(KRgbBlack);
gc.SetBrushStyle( CGraphicsContext::ESolidBrush );
if (nAlmond == 0) {
TPoint textPoint(50,130); //准备
TBuf<20> text;
StringLoader::Load(text,R_ORCER_FUN_READY);
const CFont* normalFont=iEikonEnv->NormalFont();
gc.UseFont(normalFont);
gc.DrawText(text,textPoint);
gc.DiscardFont();
}
else if(nAlmond == 1)
{
TPoint textPoint1(40,130); //下载稍后
TBuf<20> text1;
StringLoader::Load(text1,R_ORCER_FUN_LATER);
const CFont* normalFont1=iEikonEnv->NormalFont();
gc.UseFont(normalFont1);
gc.DrawText(text1,textPoint1);
gc.DiscardFont();
}
else if (nAlmond == 2)
{
TPoint textPoint2(50,130); //下载成功
TBuf<20> text;
StringLoader::Load(text,R_ORCER_FUN_SUCCEED);
const CFont* normalFont=iEikonEnv->NormalFont();
gc.UseFont(normalFont);
gc.DrawText(text,textPoint2);
gc.DiscardFont();
}
else if (nAlmond == 3)
{
TPoint textPoint3(40,130); //下载失败
TBuf<20> text;
StringLoader::Load(text,R_ORCER_FUN_ERROR);
const CFont* normalFont=iEikonEnv->NormalFont();
gc.UseFont(normalFont);
gc.DrawText(text,textPoint3);
gc.DiscardFont();
}
else if (nAlmond == 4)
{
TPoint textPoint4(40,130); //更新稍后
TBuf<20> text;
StringLoader::Load(text,R_ORCER_FUN_UPLATER);
const CFont* normalFont=iEikonEnv->NormalFont();
gc.UseFont(normalFont);
gc.DrawText(text,textPoint4);
gc.DiscardFont();
}
else if (nAlmond == 5)
{
TPoint textPoint5(50,130); //连接超时
TBuf<20> text;
StringLoader::Load(text,R_ORCER_FUN_CONTIME);
const CFont* normalFont=iEikonEnv->NormalFont();
gc.UseFont(normalFont);
gc.DrawText(text,textPoint5);
gc.DiscardFont();
}
else if (nAlmond == 6)
{
TPoint textPoint6(50,130); //更新成功
TBuf<20> text;
StringLoader::Load(text,R_ORCER_FUN_UPSUCCEED);
const CFont* normalFont=iEikonEnv->NormalFont();
gc.UseFont(normalFont);
gc.DrawText(text,textPoint6);
gc.DiscardFont();
}
else if (nAlmond == 7)
{
TPoint textPoint6(50,130); //连接超时
TBuf<20> text;
StringLoader::Load(text,R_ORCER_FUN_UPFAIL);
const CFont* normalFont=iEikonEnv->NormalFont();
gc.UseFont(normalFont);
gc.DrawText(text,textPoint6);
gc.DiscardFont();
}
}
// ---------------------------------------------------------
// CAknExGridContainer::OfferKeyEventL(
// const TKeyEvent& aKeyEvent, TEventCode aType )
// Handles the key events.
// ---------------------------------------------------------
//
TKeyResponse CORCFunContainer::OfferKeyEventL(const TKeyEvent& aKeyEvent, TEventCode aType )
{
// return EKeyWasNotConsumed;//Martin
if (m_pExplain)
return m_pExplain->OfferKeyEventL(aKeyEvent, aType);
else
return CCoeControl::OfferKeyEventL(aKeyEvent, aType);
}
void CORCFunContainer::AddExplainEditorL()
{//Martin
if (m_pExplain)
{
HBufC* explain = StringLoader::LoadLC (R_ORCER_FUN_EXPLAIN);
m_pExplain->AddTextL (*explain);
m_pExplain->ApplyCharFormatL();
m_pExplain->ApplyCharFormatL();
CleanupStack::PopAndDestroy(explain);
HBufC* download = StringLoader::LoadLC (R_ORCER_FUN_DOWNLOAD);
m_pExplain->AddTextL (*download);
m_pExplain->ApplyCharFormatL();
m_pExplain->ApplyCharFormatL();
CleanupStack::PopAndDestroy(download);
HBufC* update = StringLoader::LoadLC (R_ORCER_FUN_UPDATE);
m_pExplain->AddTextL (*update);
m_pExplain->ApplyCharFormatL();
m_pExplain->ApplyCharFormatL();
CleanupStack::PopAndDestroy(update);
HBufC* choose = StringLoader::LoadLC (R_ORCER_FUN_CHOOSE);
m_pExplain->AddTextL (*choose);
m_pExplain->ApplyCharFormatL();
m_pExplain->ApplyCharFormatL();
CleanupStack::PopAndDestroy(choose);
}
}
// End of File
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -