📄 hellocontainer.cpp
字号:
/*
* ============================================================================
* Name : CHelloContainer from CCoeControl, MCoeControlObserver
* Part of : Hello
* Copyright (c) 2003 Nokia. All rights reserved.
* ============================================================================
*/
// INCLUDE FILES
#include <Ldcno17song.rsg>
#include "Ldcno17song.hrh"
#include "HelloContainer.h"
#include "AddressBook.h" // 增加头文件;
#include "eikenv.h" // 增加头文件;
#include "Ldcno17songDocument.h" // 增加头文件;
// ================= MEMBER FUNCTIONS =======================
// C++ default constructor can NOT contain any code, that
// might leave.
//
CHelloContainer::CHelloContainer()
{
}
// EPOC default constructor can leave.
void CHelloContainer::ConstructL(const TRect& aRect)
{
CreateWindowL();
SetRect(aRect);
ActivateL();
}
// Destructor
CHelloContainer::~CHelloContainer()
{
}
// ---------------------------------------------------------
// CHelloContainer::FocusTo(TInt aCommand)
// Change foccused control.
// (other items were commented in a header).
// ---------------------------------------------------------
//
void CHelloContainer::FocusTo(TInt aCommand)
{
}
// ---------------------------------------------------------
// CHelloContainer::SizeChanged()
// Called by framework when the view size is changed
// (other items were commented in a header).
// ---------------------------------------------------------
//
void CHelloContainer::SizeChanged()
{
}
// ---------------------------------------------------------
// CHelloContainer::CountComponentControls() const
// (other items were commented in a header).
// ---------------------------------------------------------
//
TInt CHelloContainer::CountComponentControls() const
{
return 0; // return nbr of controls inside this container
}
// ---------------------------------------------------------
// CHelloContainer::ComponentControl(TInt aIndex) const
// (other items were commented in a header).
// ---------------------------------------------------------
//
CCoeControl* CHelloContainer::ComponentControl(TInt aIndex) const
{
return NULL;
}
// ---------------------------------------------------------
// CHelloContainer::Draw(const TRect& aRect) const
// (other items were commented in a header).
// ---------------------------------------------------------
//
void CHelloContainer::Draw(const TRect& aRect) const
{
CWindowGc& gc = SystemGc();
gc.SetPenStyle(CGraphicsContext::ENullPen);
gc.SetBrushColor(KRgbYellow);
gc.SetBrushStyle(CGraphicsContext::ESolidBrush);
gc.DrawRect(aRect);
TPoint text(5, 20);
const CFont* nor = CEikonEnv::Static()->NormalFont();
gc.UseFont(nor);
CAddressBook* m_p = m_pDoc->GetAddRess();
//LIT(K, "KFJD");
//CAddressBook*m = NewL(K, ......);
_LIT(K1, "Name:");
_LIT(K2, "Tel:");
_LIT(K3, "Email:");
_LIT(K4, "Address:");
_LIT(K5, "AddLength:");
_LIT(K6, "MaxName:");
_LIT(K7, "Find zhi:");
_LIT(KING, "zhi");
TBuf<32> buf(K1);
gc.DrawText(buf, text);
TPoint p(text.iX+31, text.iY);
gc.DrawText(*(m_p->GetName()), p);
buf.Copy(K2);
text.iY += 15;
gc.DrawText(buf, text);
p.iX = text.iX + 18;
p.iY = text.iY;
gc.DrawText(*(m_p->GetTel()), p);
buf.Copy(K3);
text.iY += 15;
gc.DrawText(buf, text);
p.iX = text.iX + 28;
p.iY = text.iY;
gc.DrawText(*(m_p->GetEmail()), p);
text.iY += 15;
buf.Copy(K4);
gc.DrawText(buf, text);
p.iX = text.iX + 43;
p.iY = text.iY;
gc.DrawText(*(m_p->GetAddress()), p);
text.iY += 15;
buf.Copy(K5);
buf.AppendNum(m_p->GetLength());
gc.DrawText(buf, text);
text.iY += 15;
buf.Copy(K6);
buf.AppendNum(m_p->GetMaxLength());
gc.DrawText(buf, text);
text.iY += 15;
buf.Copy(K7);
TBuf<32> b(KING);
buf.AppendNum(m_p->Find(b));
gc.DrawText(buf, text);
gc.DiscardFont();
}
// ---------------------------------------------------------
// CHelloContainer::OfferKeyEventL(...)
// Notify key events to editors.
// (other items were commented in a header).
// ---------------------------------------------------------
//
TKeyResponse CHelloContainer::OfferKeyEventL(
const TKeyEvent& aKeyEvent, TEventCode aType)
{
return EKeyWasNotConsumed;
}
// ---------------------------------------------------------
// CHelloContainer::HandleControlEventL(
// CCoeControl* aControl,TCoeEvent aEventType)
// (other items were commented in a header).
// ---------------------------------------------------------
//
void CHelloContainer::HandleControlEventL(
CCoeControl* /*aControl*/,TCoeEvent /*aEventType*/)
{
}
void CHelloContainer::Model(CLdcno17songDocument* pDoc) // 增加!!
{
m_pDoc = pDoc;
}
// End of File
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -