📄 singlelistcontainer.cpp
字号:
/*
* ============================================================================
* Name : CSingleListContainer from CCoeControl, MCoeControlObserver
* Part of : Hello
* Copyright (c) 2003 Nokia. All rights reserved.
* ============================================================================
*/
// INCLUDE FILES
#include <MyHello.rsg>
#include "MyHello.hrh"
#include "SingleListContainer.h"
#include "common.h"
#include <aknlists.h>
// ================= MEMBER FUNCTIONS =======================
// C++ default constructor can NOT contain any code, that
// might leave.
//
CSingleListContainer::CSingleListContainer()
{
m_pSingleListBox = NULL;
m_pListBoxArray = NULL;
}
// EPOC default constructor can leave.
void CSingleListContainer::ConstructL(const TRect& aRect)
{
CreateWindowL();
//Single ListBox
m_pSingleListBox = new( ELeave ) CAknSingleNumberStyleListBox();
CleanupStack::PushL(m_pSingleListBox);
m_pSingleListBox->ConstructL(this, EAknListBoxMarkableList | EAknListBoxMultiselectionList);
m_pSingleListBox->SetContainerWindowL(*this);
m_pSingleListBox->SetRect(aRect);
m_pSingleListBox->CreateScrollBarFrameL( ETrue );
m_pSingleListBox->ScrollBarFrame()->SetScrollBarVisibilityL(CEikScrollBarFrame::EOff, CEikScrollBarFrame::EAuto);
// construct listbox item array
m_pListBoxArray = new (ELeave) CDesCArrayFlat(10);
CleanupStack::PushL(m_pListBoxArray);
CTextListBoxModel* model = m_pSingleListBox->Model();
// set items and ownership
model->SetItemTextArray( m_pListBoxArray );
model->SetOwnershipType(ELbmDoesNotOwnItemArray);
CleanupStack::Pop(2); // !!! (2);
m_pSingleListBox->ActivateL();
// m_pListBox->MakeVisible(ETrue);
m_pSingleListBox->SetFocus( ETrue );
// m_pListBox->DrawNow();
//End Single ListBox
SetRect(aRect);
ActivateL();
}
// Destructor
CSingleListContainer::~CSingleListContainer()
{
MEM_FREE(m_pSingleListBox);
MEM_FREE(m_pListBoxArray);
}
// ---------------------------------------------------------
// CSingleListContainer::FocusTo(TInt aCommand)
// Change foccused control.
// (other items were commented in a header).
// ---------------------------------------------------------
//
void CSingleListContainer::FocusTo(TInt aCommand)
{
}
// ---------------------------------------------------------
// CSingleListContainer::SizeChanged()
// Called by framework when the view size is changed
// (other items were commented in a header).
// ---------------------------------------------------------
//
void CSingleListContainer::SizeChanged()
{
if (m_pSingleListBox)
{
m_pSingleListBox->SetRect(Rect());
}
}
// ---------------------------------------------------------
// CSingleListContainer::CountComponentControls() const
// (other items were commented in a header).
// ---------------------------------------------------------
//
TInt CSingleListContainer::CountComponentControls() const
{
//return 0; // return nbr of controls inside this container
return 1;
}
// ---------------------------------------------------------
// CSingleListContainer::ComponentControl(TInt aIndex) const
// (other items were commented in a header).
// ---------------------------------------------------------
//
CCoeControl* CSingleListContainer::ComponentControl(TInt aIndex) const
{
return m_pSingleListBox;//return NULL;
}
// ---------------------------------------------------------
// CSingleListContainer::Draw(const TRect& aRect) const
// (other items were commented in a header).
// ---------------------------------------------------------
//
void CSingleListContainer::Draw(const TRect& aRect) const
{
CWindowGc& gc = SystemGc();
gc.SetPenStyle(CGraphicsContext::ENullPen);
gc.SetBrushColor(KRgbGray);
gc.SetBrushStyle(CGraphicsContext::ESolidBrush);
gc.DrawRect(aRect);
}
// ---------------------------------------------------------
// CSingleListContainer::OfferKeyEventL(...)
// Notify key events to editors.
// (other items were commented in a header).
// ---------------------------------------------------------
//
TKeyResponse CSingleListContainer::OfferKeyEventL(
const TKeyEvent& aKeyEvent, TEventCode aType)
{
return EKeyWasNotConsumed;
}
// ---------------------------------------------------------
// CSingleListContainer::HandleControlEventL(
// CCoeControl* aControl,TCoeEvent aEventType)
// (other items were commented in a header).
// ---------------------------------------------------------
//
void CSingleListContainer::HandleControlEventL(
CCoeControl* /*aControl*/,TCoeEvent /*aEventType*/)
{
}
// append items to the listbox
void CSingleListContainer::AddInfoToList(TInt aIndex, const TDesC& aText)
{
TBuf<64> sBuf;
sBuf.AppendNum(aIndex);
sBuf.Append(_L("\t"));
sBuf.Append(aText);
m_pListBoxArray->AppendL(sBuf);
// update listbox
m_pSingleListBox->HandleItemAdditionL();
}
// End of File
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -