📄 selectcardcontainer.cpp
字号:
#include <FrMes.rsg>
#include "FrMes.hrh"
#include "SelectCardContainer.h"
#include "FrMesAppUi.h"
#include "BookEngine.h"
#include <aknlists.h>
// ================= MEMBER FUNCTIONS =======================
// C++ default constructor can NOT contain any code, that
// might leave.
//
CSelectCardContainer::CSelectCardContainer()
{
m_pListBox = NULL;
m_pListBoxArray = NULL;
}
// EPOC default constructor can leave.
void CSelectCardContainer::ConstructL(const TRect& aRect)
{
CreateWindowL();
//listbox
m_pListBox = new( ELeave ) CAknSingleNumberStyleListBox();
CleanupStack::PushL(m_pListBox);
m_pListBox->ConstructL(this, EAknListBoxMarkableList | EAknListBoxMultiselectionList);
m_pListBox->SetContainerWindowL( *this );
m_pListBox->SetRect(aRect);
m_pListBox->CreateScrollBarFrameL( ETrue );
m_pListBox->ScrollBarFrame()->SetScrollBarVisibilityL(CEikScrollBarFrame::EOff, CEikScrollBarFrame::EAuto);
//添加项目列表
m_pListBoxArray = new (ELeave) CDesCArrayFlat(10);
CleanupStack::PushL(m_pListBoxArray);
CTextListBoxModel* model = m_pListBox->Model();
model->SetItemTextArray( m_pListBoxArray );
model->SetOwnershipType(ELbmDoesNotOwnItemArray);
CleanupStack::Pop(2);
m_pListBox->SetFocus( ETrue );
SetRect(aRect);
ActivateL();
}
// Destructor
CSelectCardContainer::~CSelectCardContainer()
{
if(m_pListBox)
{
delete m_pListBox;
m_pListBox = NULL;
}
if(m_pListBoxArray)
{
delete m_pListBoxArray;
m_pListBoxArray = NULL;
}
}
// ---------------------------------------------------------
// CAknExEditorContainer::FocusTo(TInt aCommand)
// Change foccused control.
// (other items were commented in a header).
// ---------------------------------------------------------
//
void CSelectCardContainer::FocusTo(TInt aCommand)
{
}
// ---------------------------------------------------------
// CSelectCardContainer::SizeChanged()
// Called by framework when the view size is changed
// (other items were commented in a header).
// ---------------------------------------------------------
//
void CSelectCardContainer::SizeChanged()
{
if (m_pListBox)
{
m_pListBox->SetRect(Rect());
}
}
// ---------------------------------------------------------
// CSelectCardContainer::CountComponentControls() const
// (other items were commented in a header).
// ---------------------------------------------------------
//
TInt CSelectCardContainer::CountComponentControls() const
{
return 1; // return nbr of controls inside this container
}
// ---------------------------------------------------------
// CSelectCardContainer::ComponentControl(TInt aIndex) const
// (other items were commented in a header).
// ---------------------------------------------------------
//
CCoeControl* CSelectCardContainer::ComponentControl(TInt aIndex) const
{
switch(aIndex)
{
case 0:
return m_pListBox;
break;
default:
return NULL;
break;
}
}
// ---------------------------------------------------------
// CSelectCardContainer::Draw(const TRect& aRect) const
// (other items were commented in a header).
// ---------------------------------------------------------
//
void CSelectCardContainer::Draw(const TRect& aRect) const
{
CWindowGc& gc = SystemGc();
gc.SetPenStyle(CGraphicsContext::ENullPen);
gc.SetBrushColor(KRgbYellow);
gc.SetBrushStyle(CGraphicsContext::ESolidBrush);
gc.DrawRect(aRect);
}
// ---------------------------------------------------------
// CSelectCardContainer::OfferKeyEventL(...)
// Notify key events to editors.
// (other items were commented in a header).
// ---------------------------------------------------------
//
TKeyResponse CSelectCardContainer::OfferKeyEventL(
const TKeyEvent& aKeyEvent, TEventCode aType)
{
if (m_pListBox)
return m_pListBox->OfferKeyEventL (aKeyEvent, aType);
else
return EKeyWasNotConsumed;
}
// ---------------------------------------------------------
// CSelectCardContainer::HandleControlEventL(
// CCoeControl* aControl,TCoeEvent aEventType)
// (other items were commented in a header).
// ---------------------------------------------------------
//
void CSelectCardContainer::HandleControlEventL(
CCoeControl* /*aControl*/,TCoeEvent /*aEventType*/)
{
}
// End of File
void CSelectCardContainer::AddInfoToList(const TDesC& aText)
{
TBuf<16> sBuf;
sBuf.Append(_L("\t"));
sBuf.Append(aText);
m_pListBoxArray->AppendL(sBuf);
m_pListBox->HandleItemAdditionL();
}
void CSelectCardContainer::DisplayList()
{
CFrMesAppUi* pApp = (CFrMesAppUi*)CEikonEnv::Static()->AppUi();
TInt aCount = pApp->iPhoneBookArray->Count();
m_pListBoxArray->Reset();
if(aCount>0)
{
for(int i=0;i<aCount;i++)
{
HBufC* aFamilyName = NULL;
HBufC* aFirstName = NULL;
HBufC* aTelephone = NULL;
aFamilyName = pApp->iPhoneBookArray->At(i)->GetLastName();
aFirstName = pApp->iPhoneBookArray->At(i)->GetFirstName();
aTelephone = pApp->iPhoneBookArray->At(i)->GetTelephone();
TBuf<16> aText;
aText.Append(*aFamilyName);
aText.Append(*aFirstName);
AddInfoToList(aText);
}
m_pListBox->SetCurrentItemIndex(0);
}
}
TInt CSelectCardContainer::GetCurrentItemIndex()
{
return m_pListBox->CurrentItemIndex();
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -