📄 listview.cpp
字号:
/*
* ============================================================================
* Name : CListView from ListView.h
* Part of : MultiView
* Created : 03.12.2005 by ToBeReplacedByAuthor
* Implementation notes:
* Initial content was generated by Series 60 AppWizard.
* Version :
* Copyright: ToBeReplacedByCopyright
* ============================================================================
*/
// INCLUDE FILES
#include <aknviewappui.h>
#include <avkon.hrh>
#include <MultiView.rsg>
#include "MultiView.hrh"
#include "ListView.h"
#include "ListViewContainer.h"
#include <aknlists.h> // for Listbox
// ================= MEMBER FUNCTIONS =======================
// ---------------------------------------------------------
// CListView::ConstructL(const TRect& aRect)
// EPOC two-phased constructor
// ---------------------------------------------------------
//
void CListView::ConstructL()
{
BaseConstructL( R_MULTIVIEW_VIEW1 );
}
// ---------------------------------------------------------
// CListView::~CListView()
// destructor
// ---------------------------------------------------------
//
CListView::~CListView()
{
if ( iContainer )
{
AppUi()->RemoveFromViewStack( *this, iContainer );
}
delete iContainer;
}
// ---------------------------------------------------------
// TUid CListView::Id()
//
// ---------------------------------------------------------
//
TUid CListView::Id() const
{
return KViewId;
}
// ---------------------------------------------------------
// CListView::HandleCommandL(TInt aCommand)
// takes care of view command handling
// ---------------------------------------------------------
//
void CListView::HandleCommandL(TInt aCommand)
{
switch ( aCommand )
{
case EMultiViewCmdList:
{
iEikonEnv->InfoMsg( _L("Command from Listview") );
break;
}
case EAknSoftkeyBack:
{
AppUi()->HandleCommandL(EEikCmdExit);
break;
}
default:
{
AppUi()->HandleCommandL( aCommand );
break;
}
}
}
// ---------------------------------------------------------
// CListView::HandleClientRectChange()
// ---------------------------------------------------------
//
void CListView::HandleClientRectChange()
{
if ( iContainer )
{
iContainer->SetRect( ClientRect() );
}
}
// ---------------------------------------------------------
// CListView::DoActivateL(...)
//
// ---------------------------------------------------------
//
void CListView::DoActivateL(
const TVwsViewId& /*aPrevViewId*/,TUid aCustomMessageId,
const TDesC8& aCustomMessage)
{
if (!iContainer)
{
iContainer = new (ELeave) CListViewContainer;
iContainer->SetMopParent(this);
iContainer->ConstructL( ClientRect() );
AppUi()->AddToStackL( *this, iContainer );
}
if (aCustomMessageId == KCustomMessageUid)
{
//如果是需要捕获的消息,根据消息的内容,更改列表的初始选项
TUint index = aCustomMessage[0];
CAknSingleStyleListBox* listbox = iContainer->iListBox;
listbox->SetCurrentItemIndex(index);
//下面的代码显示一条消息,提示用户当前列表的缺省选项有变化,并不完成功能性操作
TBuf<32> buf;
_LIT(KFormat1,"The index is: %d");
buf.Format(KFormat1,index);
iEikonEnv->InfoMsg(buf);
}
}
// ---------------------------------------------------------
// CListView::DoDeactivate()
//
// ---------------------------------------------------------
//
void CListView::DoDeactivate()
{
if ( iContainer )
{
AppUi()->RemoveFromViewStack( *this, iContainer );
}
delete iContainer;
iContainer = NULL;
}
// End of File
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -