📄 lookcontainer.cpp
字号:
#include <gulicon.h>
#include <aknutils.h>
#include <avkon.hrh>
#include <akntitle.h>
#include <eiklabel.h>
#include <eikedwin.h>
#include "LookContainer.h"
#include "LDFUCK.rsg"
CLookContainer::CLookContainer()
{
m_pLookText = NULL;
m_pLooktitle = NULL;
}
// EPOC default constructor can leave.
void CLookContainer::ConstructL(const TRect& aRect, const TDesC& aName, const TDesC& aContent)
{
CreateWindowL();
//添加标签姓名
m_pLooklabelname = new (ELeave) CEikLabel;
m_pLooklabelname->SetContainerWindowL( *this );
// m_pLooklabelname->SetTextL( _L("姓名:") );
TBuf<32> buf_look;
CEikonEnv::Static()->ReadResource(buf_look, R_QTN_LF_LOOKNUM);
m_pLooklabelname->SetTextL(buf_look);
m_pLooklabelname->SetExtent( TPoint(10,12), m_pLooklabelname->MinimumSize() );
//添加标签内容
m_pLooklabelcontent = new (ELeave) CEikLabel;
m_pLooklabelcontent->SetContainerWindowL( *this );
// m_pLooklabelcontent->SetTextL( _L("信息:") );
CEikonEnv::Static()->ReadResource(buf_look, R_QTN_LF_LOOKCON);;
m_pLooklabelcontent->SetTextL(buf_look);
m_pLooklabelcontent->SetExtent( TPoint(10,40), m_pLooklabelcontent->MinimumSize() );
//添加姓名输入
m_pLookText = new (ELeave) CEikEdwin(TGulBorder::ESingleBlack);
m_pLookText->SetContainerWindowL(*this);
m_pLookText->ConstructL(EEikEdwinNoAutoSelection | EEikEdwinIgnoreVirtualCursor, 13, 32, 1);
m_pLookText->SetExtent(TPoint(50, 10), TSize(110, 20));
m_pLookText->EReadOnly;
m_pLookText->SetTextL(&aName);
//set Focus
m_pLookText->SetFocus(EFalse);
//添加内容输入
m_pLooktitle = new (ELeave) CEikEdwin(TGulBorder::ESingleBlack);
m_pLooktitle->SetContainerWindowL(*this);
m_pLooktitle->ConstructL(EEikEdwinNoAutoSelection | EEikEdwinIgnoreVirtualCursor, 13, 32, 1);
m_pLooktitle->SetExtent(TPoint(50, 40), TSize(110, 90));
m_pLooktitle->EReadOnly;
m_pLooktitle->SetTextL(&aContent);
//set Focus
m_pLooktitle->SetFocus(EFalse);
SetRect( aRect );
ActivateL();
}
// destructor
CLookContainer::~CLookContainer()
{
if(m_pLookText)
{
delete m_pLookText;
m_pLookText = NULL;
}
if(m_pLooktitle)
{
delete m_pLooktitle;
m_pLooktitle = NULL;
}
if (m_pLooklabelname)
{
delete m_pLooklabelname;
m_pLooklabelname = NULL;
}
if (m_pLooklabelcontent)
{
delete m_pLooklabelcontent;
m_pLooklabelcontent = NULL;
}
}
void CLookContainer::SizeChanged()
{
}
// ---------------------------------------------------------
// CLookContainer::CountComponentControls() const
// return the number of controls
// ---------------------------------------------------------
//
TInt CLookContainer::CountComponentControls() const
{
// return number of controls inside this container
return 4;
}
// ---------------------------------------------------------
// CLookContainer::ComponentControl(TInt aIndex) const
// return the pointer to specified control.
// ---------------------------------------------------------
//
CCoeControl* CLookContainer::ComponentControl( TInt aIndex ) const
{
switch(aIndex)
{
case 0 :
return m_pLookText;
break;
case 1 :
return m_pLooktitle;
break;
case 2 :
return m_pLooklabelname;
break;
case 3 :
return m_pLooklabelcontent;
break;
default:
return NULL;
break;
}
}
// ---------------------------------------------------------
// CLookContainer::Draw(const TRect& aRect) const
// handle the message when client region must be redrawn.
// ---------------------------------------------------------
//
void CLookContainer::Draw( const TRect& aRect ) const
{
CWindowGc& gc = SystemGc();
gc.SetPenStyle(CGraphicsContext::ENullPen);
gc.SetBrushColor(KRgbGray);
gc.SetBrushStyle(CGraphicsContext::ESolidBrush);
gc.DrawRect(aRect);
gc.Clear(Rect());
// gc.DrawRect(TRect(TPoint(10, 10), TSize(20, 20)));
}
// ---------------------------------------------------------
// CAknExGridContainer::OfferKeyEventL(
// const TKeyEvent& aKeyEvent, TEventCode aType )
// Handles the key events.
// ---------------------------------------------------------
//
TKeyResponse CLookContainer::OfferKeyEventL(const TKeyEvent& /*aKeyEvent*/, TEventCode /*aType*/ )
{
return EKeyWasNotConsumed;
}
// End of File
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -