📄 marklistcontainer.cpp
字号:
/*
* ============================================================================
* Name : CMarkListContainer from MarkListContainer.h
* Part of : MarkList
* Created : 16.03.2006 by ToBeReplacedByAuthor
* Implementation notes:
* Initial content was generated by Series 60 Application Wizard.
* Version :
* Copyright: ToBeReplacedByCopyright
* ============================================================================
*/
// INCLUDE FILES
#include <eikapp.h> // for CEikApplication
#include <eikfrlbd.h> // for CFormattedCellListBoxData
#include <eikfrlb.h> // for CEikFormattedCellListBox
#include <akniconarray.h> // for CAknIconArray
#include <aknlists.h> // for CAknDoubleStyleListBox
#include <MarkList.mbg> // for EMbmMarkListStar
#include <MarkList.rsg>
#include "MarkListContainer.h"
// ================= MEMBER FUNCTIONS =======================
// ---------------------------------------------------------
// CMarkListContainer::ConstructL(const TRect& aRect)
// EPOC two phased constructor
// ---------------------------------------------------------
//
void CMarkListContainer::ConstructL(const TRect& aRect)
{
CreateWindowL();
// Create listbox
iListBox = new(ELeave) CAknDoubleGraphicStyleListBox;
iListBox->SetContainerWindowL( *this );
iListBox->ConstructL(this, EAknListBoxMarkableList);
iListBox->SetListBoxObserver(this);
// Load items
CTextListBoxModel* model = iListBox->Model();
CDesCArray* array = static_cast<CDesCArray*>(model->ItemTextArray());
_LIT(KItemFormat, "1\tRecord%d\t%d"); // "Icon1\tLabel1\tLabel2"
TBuf<32> record;
TInt i = 1;
for (i = 1; i<9 ; i++)
{
record.Format(KItemFormat(), i, 100-i, 1);
array->AppendL(record);
}
// Load icons
CEikonEnv* eikonEnv = CEikonEnv::Static();
TFileName mbmFile = eikonEnv->EikAppUi()->Application()->BitmapStoreName();
CArrayPtr<CGulIcon>* icons = new(ELeave) CAknIconArray(3);
CleanupStack::PushL(icons);
icons->AppendL(eikonEnv->CreateIconL(mbmFile, EMbmMarklistTick, EMbmMarklistTickmask));
icons->AppendL(eikonEnv->CreateIconL(mbmFile, EMbmMarklistStar, EMbmMarklistStarmask));
CleanupStack::Pop(icons);
iListBox->ItemDrawer()->FormattedCellData()->SetIconArray(icons);
// Create scrollbar
iListBox->CreateScrollBarFrameL(ETrue);
iListBox->ScrollBarFrame()->SetScrollBarVisibilityL(
CEikScrollBarFrame::EOff, CEikScrollBarFrame::EAuto );
SetRect(aRect);
ActivateL();
}
// Destructor
CMarkListContainer::~CMarkListContainer()
{
delete iListBox;
}
// New methods
TInt CMarkListContainer::SelectionCount()
{
return iListBox->SelectionIndexes()->Count();
}
void CMarkListContainer::AddRecordL(const TDesC& aDesC)
{
CTextListBoxModel* model = iListBox->Model();
CDesCArray* array = static_cast<CDesCArray*>(model->ItemTextArray());
_LIT(KItemFormat, "1\t%S\t?");
TBuf<32> record;
record.Format(KItemFormat(), &aDesC);
TInt index = iListBox->CurrentItemIndex();
if(index<0)
array->AppendL(record);
else
array->InsertL(index, record);
iListBox->HandleItemAdditionL();
}
void CMarkListContainer::DeleteRecordL()
{
CTextListBoxModel* model = iListBox->Model();
CDesCArray* array = static_cast<CDesCArray*>(model->ItemTextArray());
TInt index = iListBox->CurrentItemIndex();
TBool deleted = iListBox->View()->ItemIsSelected(index);
const CListBoxView::CSelectionIndexArray* selection = iListBox->SelectionIndexes();
TInt i = selection->Count()-1;
for(i;i>=0;i--)
{
if(index>=(*selection)[i])
{
index--;
}
array->Delete((*selection)[i]);
}
if(index<0)
{
index=0;
}
AknListBoxUtils::HandleItemRemovalAndPositionHighlightL(iListBox, index, deleted);
}
void CMarkListContainer::HandleMarkCommandL(TInt aCommand)
{
AknSelectionService::HandleMarkableListProcessCommandL(aCommand, iListBox);
}
// ---------------------------------------------------------
// CMarkListContainer::SizeChanged()
// Called by framework when the view size is changed
// ---------------------------------------------------------
//
void CMarkListContainer::SizeChanged()
{
// TODO: Add here control resize code etc.
iListBox->SetRect(Rect());
}
// ---------------------------------------------------------
// CMarkListContainer::CountComponentControls() const
// ---------------------------------------------------------
//
TInt CMarkListContainer::CountComponentControls() const
{
return 1; // return nbr of controls inside this container
}
// ---------------------------------------------------------
// CMarkListContainer::ComponentControl(TInt aIndex) const
// ---------------------------------------------------------
//
CCoeControl* CMarkListContainer::ComponentControl(TInt aIndex) const
{
switch ( aIndex )
{
case 0:
return iListBox;
default:
return NULL;
}
}
// ---------------------------------------------------------
// CMarkListContainer::Draw(const TRect& aRect) const
// ---------------------------------------------------------
//
void CMarkListContainer::Draw(const TRect& aRect) const
{
CWindowGc& gc = SystemGc();
// TODO: Add your drawing code here
// example code...
gc.SetPenStyle( CGraphicsContext::ENullPen );
gc.SetBrushColor( KRgbGray );
gc.SetBrushStyle( CGraphicsContext::ESolidBrush );
gc.DrawRect( aRect );
}
// ---------------------------------------------------------
// CMarkListContainer::OfferKeyEventL()
// @param aKeyEvent Event to handled.
// @param aType Type of the key event.
// @return Response code (EKeyWasConsumed, EKeyWasNotConsumed).
// ---------------------------------------------------------
//
TKeyResponse CMarkListContainer::OfferKeyEventL(const TKeyEvent& aKeyEvent,TEventCode aType)
{
return iListBox->OfferKeyEventL(aKeyEvent, aType);
}
// ---------------------------------------------------------
// CMarkListContainer::HandleListBoxEventL(
// CEikListBox* aListBox, TListBoxEvent aListBoxEvent)
// ---------------------------------------------------------
//
void CMarkListContainer::HandleListBoxEventL(CEikListBox*/*aListBox*/, TListBoxEvent aListBoxEvent)
{
if((aListBoxEvent == MEikListBoxObserver::EEventEnterKeyPressed) ||
(aListBoxEvent == MEikListBoxObserver::EEventItemClicked)) // for emulator
{
CEikonEnv::Static()->InfoWinL(R_QTN_APP_NODETAIL);
}
}
// End of File
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -