📄 shenxianthreecontainer.cpp
字号:
/*
* ============================================================================
* Name : CShenxianThreeContainer from CCoeControl, MCoeControlObserver
* Part of : ShenxianThree
* Copyright (c) 2003 Nokia. All rights reserved.
* ============================================================================
*/
// INCLUDE FILES
#include <Shenxian.rsg>
#include "Shenxian.hrh"
#include "ShenxianThreeContainer.h"
#include "ShenxianTowContainer.h"
#include <aknlists.h>
// ================= MEMBER FUNCTIONS =======================
// C++ default constructor can NOT contain any code, that
// might leave.
//
CShenxianThreeContainer::CShenxianThreeContainer()
{
m_pListBox = NULL;
m_pListArray = NULL;
}
// EPOC default constructor can leave.
void CShenxianThreeContainer::ConstructL(const TRect& aRect)
{
CreateWindowL();
/***************添加列表***********************************/
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_pListArray = new(ELeave) CDesCArrayFlat(10);
CleanupStack::PushL(m_pListArray);
CTextListBoxModel* model = m_pListBox->Model( );
/****************设置选项和权限*****************************************/
model->SetItemTextArray(m_pListArray);
model->SetOwnershipType(ELbmDoesNotOwnItemArray);
CleanupStack::Pop(2);
m_pListBox->ActivateL( );
m_pListBox->SetFocus(ETrue);
SetRect(aRect);
ActivateL();
}
// Destructor
CShenxianThreeContainer::~CShenxianThreeContainer()
{
DELPTR(m_pListBox);
DELPTR(m_pListArray);
}
// ---------------------------------------------------------
// CShenxianThreeContainer::FocusTo(TInt aCommand)
// Change foccused control.
// (other items were commented in a header).
// ---------------------------------------------------------
//
void CShenxianThreeContainer::FocusTo(TInt aCommand)
{
}
// ---------------------------------------------------------
// CShenxianThreeContainer::SizeChanged()
// Called by framework when the view size is changed
// (other items were commented in a header).
// ---------------------------------------------------------
//
void CShenxianThreeContainer::SizeChanged()
{
if(m_pListBox)
{
m_pListBox->SetRect(Rect( ) );
}
}
// ---------------------------------------------------------
// CShenxianThreeContainer::CountComponentControls() const
// (other items were commented in a header).
// ---------------------------------------------------------
//
TInt CShenxianThreeContainer::CountComponentControls() const
{
return 1; // return nbr of controls inside this container
}
// ---------------------------------------------------------
// CShenxianThreeContainer::ComponentControl(TInt aIndex) const
// (other items were commented in a header).
// ---------------------------------------------------------
//
CCoeControl* CShenxianThreeContainer::ComponentControl(TInt aIndex) const
{
return m_pListBox;
}
// ---------------------------------------------------------
// CShenxianThreeContainer::Draw(const TRect& aRect) const
// (other items were commented in a header).
// ---------------------------------------------------------
//
void CShenxianThreeContainer::Draw(const TRect& aRect) const
{
CWindowGc& gc = SystemGc();
gc.SetPenStyle(CGraphicsContext::ENullPen);
gc.SetBrushColor(KRgbGray);
gc.SetBrushStyle(CGraphicsContext::ESolidBrush);
gc.DrawRect(aRect);
// const CFont *nor = CEikonEnv::Static()->TitleFont();
// gc.UseFont(nor);
// gc.DrawText(*(message->GetName()),TPoint(20,60));
// gc.DrawText(*(message->GetTel()),TPoint(20,80));
// gc.DrawText(*(message->GetEmail()),TPoint(20,100));
// gc.DrawText(*(message->GetAddress()),TPoint(20,120));
// gc.DiscardFont();
}
// ---------------------------------------------------------
// CShenxianThreeContainer::OfferKeyEventL(...)
// Notify key events to editors.
// (other items were commented in a header).
// ---------------------------------------------------------
//
TKeyResponse CShenxianThreeContainer::OfferKeyEventL(
const TKeyEvent& aKeyEvent, TEventCode aType)
{
if(NULL != m_pListBox)
{
if((aType == EEventKey) && (aKeyEvent.iCode == EKeyDownArrow))
{
return m_pListBox->OfferKeyEventL(aKeyEvent, aType);
}
else if((aType == EEventKey) && (aKeyEvent.iCode == EKeyUpArrow))
{
return m_pListBox->OfferKeyEventL(aKeyEvent, aType);
}
return EKeyWasConsumed;
}
return EKeyWasNotConsumed;
}
// ---------------------------------------------------------
// CShenxianThreeContainer::HandleControlEventL(
// CCoeControl* aControl,TCoeEvent aEventType)
// (other items were commented in a header).
// ---------------------------------------------------------
//
void CShenxianThreeContainer::HandleControlEventL(
CCoeControl* /*aControl*/,TCoeEvent /*aEventType*/)
{
}
//////********往列表添加内蓉的方法,自己写的***************************/
void CShenxianThreeContainer::AddInfoToList(TInt aIndex,const TDesC& aText)
{
TBuf<64> sBuf;
sBuf.AppendNum(aIndex);
sBuf.Append(_L("\t"));
sBuf.Append(aText);
m_pListArray->AppendL(sBuf);
m_pListBox->HandleItemAdditionL( );//update listbox.
}
void CShenxianThreeContainer::DeleteInfoFromListL( TInt aIndex )
{
if(m_pListArray->MdcaCount())
{
m_pListArray->Delete(aIndex);
aIndex--;
}
return ;
}
//End of File
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -