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

📄 notecontainer.cpp

📁 自己做的Symbian小项目 可给大家参考
💻 CPP
字号:

#include <gulicon.h>
#include <aknutils.h>
#include <avkon.hrh>
#include <akntitle.h>
#include <eiklabel.h>

#include <eikfrlb.h>
#include <aknlists.h>
#include <AknIconArray.h>

#include "NoteContainer.h"
#include "LDFUCKAppUi.h"
//#include "OperateInfo.h"

CNoteContainer::CNoteContainer()
{
	m_pNoteLtboxArray = NULL;
	m_pNoteLtbox = NULL;
//	m_pOperateInfo = new COperateInfo();
}


// EPOC default constructor can leave.
void CNoteContainer::ConstructL(const TRect& aRect)
{
    CreateWindowL();

//createlistbox
	m_pNoteLtbox = new( ELeave ) CAknDoubleGraphicStyleListBox();								//创建列表对象指针
	CleanupStack::PushL(m_pNoteLtbox);
	m_pNoteLtbox->ConstructL(this, EAknListBoxMarkableList | EAknListBoxMultiselectionList);		
	m_pNoteLtbox->SetContainerWindowL( *this );													//设置容器窗口
	m_pNoteLtbox->SetRect(aRect);
    m_pNoteLtbox->CreateScrollBarFrameL( ETrue );												//启动列表的滚动条
    m_pNoteLtbox->ScrollBarFrame()->SetScrollBarVisibilityL(CEikScrollBarFrame::EOff, CEikScrollBarFrame::EAuto );															//关闭了水平的滚动条,垂直的滚动条设置为自动

//	添加新图标列表

	CLDFUCKAppUi* pApp = (CLDFUCKAppUi*)CEikonEnv::Static()->AppUi();
	CArrayPtr<CGulIcon>* icons = new( ELeave ) CAknIconArray(2);
	CleanupStack::PushL( icons );
	icons->AppendL(pApp->LoadGraphicsL(1));
	icons->AppendL(pApp->LoadGraphicsL(0));
	m_pNoteLtbox->ItemDrawer()->ColumnData()->SetIconArray(icons);	

//	添加项目列表
	m_pNoteLtboxArray = new (ELeave) CDesCArrayFlat(10);
	CleanupStack::PushL(m_pNoteLtboxArray);
	CTextListBoxModel* model = m_pNoteLtbox->Model();
	model->SetItemTextArray( m_pNoteLtboxArray );
	model->SetOwnershipType(ELbmDoesNotOwnItemArray);
	CleanupStack::Pop(3);
    SetRect( aRect );
    ActivateL();
}

// destructor
CNoteContainer::~CNoteContainer()
{
	if(m_pNoteLtbox)
	{
		delete m_pNoteLtbox;
		m_pNoteLtbox = NULL;
	}

	if(m_pNoteLtboxArray)
	{
		delete m_pNoteLtboxArray;
		m_pNoteLtboxArray = NULL;
	}
}

void CNoteContainer::SizeChanged()
{
	m_pNoteLtbox->SetRect(Rect()); 
}

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

// ---------------------------------------------------------
// CNoteContainer::ComponentControl(TInt aIndex) const
// return the pointer to specified control.
// ---------------------------------------------------------
//
CCoeControl* CNoteContainer::ComponentControl( TInt /*aIndex*/ ) const
{
	return m_pNoteLtbox;
}

// ---------------------------------------------------------
// CNoteContainer::Draw(const TRect& aRect) const
// handle the message when client region must be redrawn.
// ---------------------------------------------------------
//
void CNoteContainer::Draw( const TRect& /*aRect*/ ) const
{
	CWindowGc& gc = SystemGc();
	gc.Clear(Rect());

//	gc.DrawRect(TRect(TPoint(10, 10), TSize(20, 20)));
}

// ---------------------------------------------------------
// CAknExGridContainer::OfferKeyEventL(
//           const TKeyEvent& aKeyEvent, TEventCode aType )
// Handles the key events.
// ---------------------------------------------------------
//
TKeyResponse CNoteContainer::OfferKeyEventL(const TKeyEvent& aKeyEvent, TEventCode aType )
{
	if (m_pNoteLtbox) 
	{
		return m_pNoteLtbox->OfferKeyEventL(aKeyEvent, aType );
	}
	
	else
	{
		return EKeyWasNotConsumed;
 	}

	return EKeyWasNotConsumed;
}

void CNoteContainer::addInfotolist(const TDesC& aIcon, const TDesC& aName, const TDesC& aContent)
{
	TBuf<64> sTmpBuf;
	sTmpBuf.Copy(aIcon);
	sTmpBuf.Append(_L("\t"));
	sTmpBuf.Append(aName);
	sTmpBuf.Append(_L("\t"));
	sTmpBuf.Append(aContent);
	m_pNoteLtboxArray->AppendL(sTmpBuf);
	m_pNoteLtbox->HandleItemAdditionL();	
}


void CNoteContainer::delInfofromlist()
{
	nIndex=m_pNoteLtbox->CurrentItemIndex();
	if (nIndex==-1) 
		return;
	m_pNoteLtboxArray->Delete(nIndex);
	AknListBoxUtils::HandleItemRemovalAndPositionHighlightL(m_pNoteLtbox,nIndex,ETrue);
}


TInt CNoteContainer::OptionGetId()
{
	return m_pNoteLtbox->CurrentItemIndex();	
}


void CNoteContainer::setCurrentIndex(TInt aIndex)
{
	m_pNoteLtbox->SetCurrentItemIndexAndDraw(aIndex);
}


void CNoteContainer::GetEditinfro()
{

}

TInt CNoteContainer::ReturnIndex()
{
	sendIndex = m_pNoteLtbox->CurrentItemIndex();
	return sendIndex;
}
// End of File  

⌨️ 快捷键说明

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