📄 notedisplaycontainer.cpp
字号:
#include <gulicon.h>
#include <aknutils.h> // definition of AKN_LAF_COLOR()
#include <avkon.hrh>
#include <akntitle.h>
#include <aknnotewrappers.h>
#include <aknlists.h>
#include <barsread.h>
#include "NoteDisplayContainer.h"
#include "Assistant.hrh"
#include "Assistant.rsg"
//////////////////////////////////////////////////////////////////////////
CNoteDisplayContainer::CNoteDisplayContainer()
{
m_pListBox = NULL;
m_pListBoxArray = NULL;
}
// EPOC default constructor can leave.
void CNoteDisplayContainer::ConstructL(const TRect& aRect)
{
CreateWindowL();
// create list box
m_pListBox = new( ELeave ) CAknSingleHeadingStyleListBox();
m_pListBox->SetContainerWindowL( *this );
m_pListBox->ConstructL(this, EAknListBoxSelectionList);
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(1);
SetRect( aRect );
ActivateL();
}
// destructor
CNoteDisplayContainer::~CNoteDisplayContainer()
{
MEMORY_FREE(m_pListBox);
m_pListBoxArray->Reset();
MEMORY_FREE(m_pListBoxArray);
}
void CNoteDisplayContainer::SizeChanged()
{
if(m_pListBox)
{
m_pListBox->SetRect(Rect());
}
}
// ---------------------------------------------------------
// CNoteDisplayContainer::CountComponentControls() const
// return the number of controls
// ---------------------------------------------------------
//
TInt CNoteDisplayContainer::CountComponentControls() const
{
// return number of controls inside this container
return 1;
}
// ---------------------------------------------------------
// CNoteDisplayContainer::ComponentControl(TInt aIndex) const
// return the pointer to specified control.
// ---------------------------------------------------------
//
CCoeControl* CNoteDisplayContainer::ComponentControl( TInt /*aIndex*/ ) const
{
return m_pListBox;
}
// ---------------------------------------------------------
// CNoteDisplayContainer::Draw(const TRect& aRect) const
// handle the message when client region must be redrawn.
// ---------------------------------------------------------
//
void CNoteDisplayContainer::Draw( const TRect& /*aRect*/ ) const
{
CWindowGc& gc = SystemGc();
gc.SetBrushStyle(CGraphicsContext::ESolidBrush);
gc.SetBrushColor(KRgbWhite);
gc.DrawRect(Rect());
}
// ---------------------------------------------------------
// CAknExGridContainer::OfferKeyEventL(
// const TKeyEvent& aKeyEvent, TEventCode aType )
// Handles the key events.
// ---------------------------------------------------------
//
TKeyResponse CNoteDisplayContainer::OfferKeyEventL(const TKeyEvent& aKeyEvent, TEventCode aType )
{
return m_pListBox->OfferKeyEventL(aKeyEvent, aType);
}
void CNoteDisplayContainer::AddInfoToList(const TDesC& aTitle, const TDesC& aContent)
{
TBuf<32> sContent;
sContent.Copy(aTitle);
sContent.Append(_L("\t"));
sContent.Append(aContent);
m_pListBoxArray->AppendL(sContent);
m_pListBox->HandleItemAdditionL();
}
TInt CNoteDisplayContainer::GetIndex()
{
return m_pListBox->CurrentItemIndex();
}
void CNoteDisplayContainer::DelTnforFromList(TInt aIndex)
{
m_pListBoxArray->Delete(aIndex, 1);
m_pListBox->HandleItemRemovalL();
m_pListBox->HandleItemAdditionL();
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -