⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 smsdisplaycontainer.cpp

📁 symbian 2rd 备忘录
💻 CPP
字号:

// System includes

#include <gulicon.h>
#include <aknutils.h>    // definition of AKN_LAF_COLOR()
#include <avkon.hrh>
#include <akntitle.h>
#include <aknnotewrappers.h>
#include <akntitle.h>  //CAknDoubleLargeStyleListBox();
#include <aknlists.h>	//CAknDoubleLargeStyleListBox();


#include "SMSDisplayContainer.h"
#include "Assistant.hrh"
#include "SMSDisplayView.h"
#include "Assistant.rsg"

//////////////////////////////////////////////////////////////////////////


CSMSDisplayContainer::CSMSDisplayContainer()
{
	m_pListBox		= NULL;
	m_pListBoxArray = NULL;
	m_pMessageDisplayView = NULL;

}

// EPOC default constructor can leave.
void CSMSDisplayContainer::ConstructL(const TRect& aRect,CSMSDisplayView* aView)
{

	CreateWindowL();
	m_pMessageDisplayView = aView;
	//  create list box
	m_pListBox = new( ELeave ) CAknDoubleStyleListBox();
	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
CSMSDisplayContainer::~CSMSDisplayContainer()
{
	MEMORY_FREE(m_pListBox);
	
	m_pListBoxArray->Reset();
	MEMORY_FREE(m_pListBoxArray);

}

void CSMSDisplayContainer::SizeChanged()
{
	if(m_pListBox)
	{
		m_pListBox->SetRect(Rect());
	}



}

// ---------------------------------------------------------
// CSMSDisplayContainer::CountComponentControls() const
// return the number of controls
// ---------------------------------------------------------
//
TInt CSMSDisplayContainer::CountComponentControls() const
{
	// return number of controls inside this container
	return 1; 
}

// ---------------------------------------------------------
// CSMSDisplayContainer::ComponentControl(TInt aIndex) const
// return the pointer to specified control.
// ---------------------------------------------------------
//
CCoeControl* CSMSDisplayContainer::ComponentControl( TInt /*aIndex*/ ) const
{

	return 	m_pListBox;

}

// ---------------------------------------------------------
// CSMSDisplayContainer::Draw(const TRect& aRect) const
// handle the SMSDisplay when client region must be redrawn.
// ---------------------------------------------------------
//
void CSMSDisplayContainer::Draw( const TRect&  aRect ) const
{

	CWindowGc& gc = SystemGc();
//	gc.Clear(aRect);
// 	gc.SetBrushStyle(CGraphicsContext::ESolidBrush);
// 	gc.SetBrushColor(KRgbWhite);
//	gc.DrawRect(Rect());

}

// ---------------------------------------------------------
// CAknExGridContainer::OfferKeyEventL(
//           const TKeyEvent& aKeyEvent, TEventCode aType )
// Handles the key events.
// ---------------------------------------------------------
//
TKeyResponse CSMSDisplayContainer::OfferKeyEventL(const TKeyEvent& aKeyEvent, TEventCode aType )
{
//     m_pListBox->HandleItemAdditionL();
// 	DrawNow();
	if(aKeyEvent.iCode == 0XF845)
	{
		m_pMessageDisplayView->HandleCommandL(EAssistantOpen);
		return EKeyWasConsumed;
	}

	return m_pListBox->OfferKeyEventL(aKeyEvent, aType);

}

void CSMSDisplayContainer::AddInfoToList(const TDesC& aMobile, const TDesC& aContent)
{
	TBuf<128> sContent;
	sContent.Copy(_L("\t"));
	sContent.Append(aMobile);
	sContent.Append(_L("\t"));
	sContent.Append(aContent);
	
	//add info to list
	m_pListBoxArray->AppendL(sContent);
	m_pListBox->HandleItemAdditionL();
}
TInt CSMSDisplayContainer::GetIndex()
{
	return m_pListBox->CurrentItemIndex();
}


void CSMSDisplayContainer::DelInforFromList( TInt aIndex)
{
	m_pListBoxArray->Delete(aIndex);		//从list数组中删除
	m_pListBox->HandleItemRemovalL();		//从list中删除全部数据
	m_pListBox->HandleItemAdditionL();		//重新往listbox中添加数据
}
//delete 
void CSMSDisplayContainer::DelAllInforFromList()
{
	m_pListBoxArray->Reset();		//把list数组中的内容全部清空
	m_pListBox->HandleItemRemovalL();
	m_pListBox->HandleItemAdditionL();
}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -