📄 orcselcontainer.cpp
字号:
#include <aknnotedialog.h> // CAknWaitNoteWrapper
#include <gulicon.h>
#include <aknutils.h>
#include <avkon.hrh>
#include <akntitle.h>
#include <eiklabel.h>
#include <aknlists.h>
#include <barsread.h>
#include <AknIconArray.h>
#include <eikclbd.h>
#include <AknQueryDialog.h>
#include "OrcerAppUi.h"
#include "ORCSelContainer.h"
#include "Orcer.rsg"
#include "ORCOperBook.h"
const TInt KNumberOfIcons(2);
CORCSelContainer::CORCSelContainer()
{
iOrcerListBox = NULL;
m_pNoteLtboxArray = NULL;
}
// EPOC default constructor can leave.
void CORCSelContainer::ConstructL(const TRect& aRect)
{
CreateWindowL();
// m_pOperBook = aOperBook;
CreateListL(aRect);
SetupListIconsL();
AddListInfo();
SetRect( aRect );
ActivateL();
}
void CORCSelContainer::CreateListL(const TRect& aRect)
{
iOrcerListBox = new( ELeave ) CAknSingleGraphicStyleListBox();
CleanupStack::PushL(iOrcerListBox);
iOrcerListBox->ConstructL(this, EAknListBoxMarkableList);
iOrcerListBox->SetContainerWindowL( *this );
iOrcerListBox->SetRect(aRect);
iOrcerListBox->CreateScrollBarFrameL( ETrue );
iOrcerListBox->ScrollBarFrame()->SetScrollBarVisibilityL(CEikScrollBarFrame::EOff, CEikScrollBarFrame::EAuto );
CleanupStack::Pop();
}
void CORCSelContainer::SetupListIconsL()
{
COrcerAppUi* pApp = (COrcerAppUi*)CEikonEnv::Static()->AppUi();
CArrayPtr<CGulIcon>* icons = new( ELeave ) CAknIconArray(KNumberOfIcons);
CleanupStack::PushL( icons );
icons->AppendL(pApp->LoadGraphicsL(0));
icons->AppendL(pApp->LoadGraphicsL(1));
icons->AppendL(pApp->LoadGraphicsL(2));
iOrcerListBox->ItemDrawer()->ColumnData()->SetIconArray(icons);
CleanupStack::Pop();
}
void CORCSelContainer::AddListInfo()
{
m_pNoteLtboxArray = new (ELeave) CDesCArrayFlat(10);
CleanupStack::PushL(m_pNoteLtboxArray);
CTextListBoxModel* model = iOrcerListBox->Model();
model->SetItemTextArray( m_pNoteLtboxArray );
model->SetOwnershipType(ELbmOwnsItemArray);
CleanupStack::Pop();
}
//destructor
CORCSelContainer::~CORCSelContainer()
{
MEMORY_FREE(iOrcerListBox);
copyIndices.Close();
copyIndices.Reset();
}
void CORCSelContainer::SizeChanged()
{
iOrcerListBox->SetRect(Rect());
}
// ---------------------------------------------------------
// CAppleContainer::CountComponentControls() const
// return the number of controls
// ---------------------------------------------------------
//
TInt CORCSelContainer::CountComponentControls() const
{
// return number of controls inside this container
return 1;
}
// ---------------------------------------------------------
// CAppleContainer::ComponentControl(TInt aIndex) const
// return the pointer to specified control.
// ---------------------------------------------------------
//
CCoeControl* CORCSelContainer::ComponentControl( TInt aIndex ) const
{
switch (aIndex)
{
case 0:
return iOrcerListBox;
default:
return NULL;
}
}
// ---------------------------------------------------------
// CAppleContainer::Draw(const TRect& aRect) const
// handle the message when client region must be redrawn.
// ---------------------------------------------------------
//
void CORCSelContainer::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 CORCSelContainer::OfferKeyEventL(const TKeyEvent& aKeyEvent, TEventCode aType )
{
if (iOrcerListBox)
return iOrcerListBox->OfferKeyEventL(aKeyEvent, aType );
else
return EKeyWasNotConsumed;
}
void CORCSelContainer::HandleListBoxEventL(CEikListBox* /*aListBox*/, TListBoxEvent aListBoxEvent)
{
// if the Select Key has been pressed
if ((aListBoxEvent == MEikListBoxObserver::EEventEnterKeyPressed) ||
(aListBoxEvent == MEikListBoxObserver::EEventItemClicked))
{
// GetListInfo();
}
}
void CORCSelContainer::addInfotolist(const TDesC& aIcon, const TDesC& aName)
{
TBuf<64> sTmpBuf;
sTmpBuf.Copy(aIcon);
sTmpBuf.Append(_L("\t"));
sTmpBuf.Append(aName);
m_pNoteLtboxArray->AppendL(sTmpBuf);
iOrcerListBox->HandleItemAdditionL();
}
void CORCSelContainer::HandleMarkCommandL(TInt aCommand)
{
if (iOrcerListBox)
{
AknSelectionService::HandleMarkableListProcessCommandL(aCommand, iOrcerListBox);
}
}
void CORCSelContainer::GetListInfo()
{
if (iOrcerListBox)
{
CTextListBoxModel* model = iOrcerListBox->Model();
if (model->NumberOfItems() > 0)
{
// Create a copy of the currently selected items (copyIndices) in numeric order
const CListBoxView::CSelectionIndexArray* selectionIndices = iOrcerListBox->SelectionIndexes();
// CleanupClosePushL(copyIndices);
TInt numberSelectedGames = selectionIndices->Count();
for (TInt i=0; i< numberSelectedGames; i++)
{
TInt k = selectionIndices->At(i);
copyIndices.Append(k);
// copyIndices.InsertInOrder ((*selectionIndices)[i]);
}
}
}
}
RArray<TInt> CORCSelContainer::GetListBoxIndex()
{
return copyIndices;
}
// End of File
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -