📄 aknexlistbasecontainer.cpp
字号:
/* Copyright (c) 2005, Nokia. All rights reserved */
// INCLUDE FILES
#include <eikclbd.h>
#include <aknlists.h>
#include <barsread.h>
#include <akniconarray.h>
#include <aknexlist.rsg>
#include <aknexlist.mbg>
#include <AknQueryDialog.h>
#include "AknExListBaseContainer.h"
#include "AknExListConst.h" // For name of bitmap file
// ================= MEMBER FUNCTIONS =========================================
// ----------------------------------------------------------------------------
// CAknExListBaseContainer::CAknExListBaseContainer()
// Default constructor.
// ----------------------------------------------------------------------------
//
CAknExListBaseContainer::CAknExListBaseContainer()
{
}
// ----------------------------------------------------------------------------
// CAknExListBaseContainer::~CAknExListBaseContainer()
// Destructor.
// ----------------------------------------------------------------------------
//
CAknExListBaseContainer::~CAknExListBaseContainer()
{
}
// ----------------------------------------------------------------------------
// CAknExListBaseContainer::SetListBoxFromResourceL()
// Sets listbox from resource using ConstructFromResourceL() of
// CEikColumnListBox class.
// ----------------------------------------------------------------------------
//
void CAknExListBaseContainer::SetListBoxFromResourceL(
CEikColumnListBox* aListBox, const TInt aResourceId )
{
if ( aListBox && aResourceId )
{
aListBox->SetContainerWindowL( *this );
TResourceReader reader;
CEikonEnv::Static()->CreateResourceReaderLC( reader, aResourceId );
aListBox->ConstructFromResourceL( reader );
CleanupStack::PopAndDestroy(); // resource stuffs.
// Creates scrollbar.
CreateScrollbarL( aListBox );
}
}
// ----------------------------------------------------------------------------
// CAknExListBaseContainer::SetListBoxFromResourceL()
// Sets listbox from resource using ConstructFromResourceL() of
// CEikFormattedCellListBox class.
// ----------------------------------------------------------------------------
//
void CAknExListBaseContainer::SetListBoxFromResourceL(
CEikFormattedCellListBox* aListBox,
const TInt aResourceId )
{
if ( aListBox && aResourceId )
{
aListBox->SetContainerWindowL( *this );
TResourceReader reader;
CEikonEnv::Static()->CreateResourceReaderLC( reader, aResourceId );
aListBox->ConstructFromResourceL( reader );
CleanupStack::PopAndDestroy(); // resource stuffs.
// Creates scrollbar.
CreateScrollbarL( aListBox );
}
}
// ----------------------------------------------------------------------------
// CAknExListBaseContainer::SetListBoxFromInnerDescriptionL()
// Sets listbox from inner description using ConstructL() of CEikColumnListBox
// class.
// ----------------------------------------------------------------------------
//
void CAknExListBaseContainer::SetListBoxFromInnerDescriptionL(
CEikColumnListBox* aListBox,
const TInt aFlags,
CDesCArray* textArray )
{
if ( aListBox )
{
// Constructs listbox.
aListBox->ConstructL( this, aFlags );
if ( textArray )
{
// Sets list item from resource.
aListBox->Model()->SetItemTextArray( textArray );
aListBox->Model()->SetOwnershipType( ELbmOwnsItemArray );
}
// Creates scrollbar.
CreateScrollbarL( aListBox );
}
}
// ----------------------------------------------------------------------------
// CAknExListBaseContainer::SetListBoxFromInnerDescriptionL()
// Sets listbox from inner description using ConstructL() of
// CEikFormattedCellListBox class.
// ----------------------------------------------------------------------------
//
void CAknExListBaseContainer::SetListBoxFromInnerDescriptionL(
CEikFormattedCellListBox* aListBox,
const TInt aFlags,
CDesCArray* textArray )
{
if ( aListBox )
{
// Constructs listbox.
aListBox->ConstructL( this, aFlags );
if ( textArray )
{
// Sets list item from resource.
aListBox->Model()->SetItemTextArray( textArray );
aListBox->Model()->SetOwnershipType( ELbmOwnsItemArray );
}
// Creates scrollbar.
CreateScrollbarL( aListBox );
}
}
// ----------------------------------------------------------------------------
// CAknExListBaseContainer::CreateFindBoxL()
// Creates FindBox and returns it's pointer.
// ----------------------------------------------------------------------------
//
CAknSearchField* CAknExListBaseContainer::CreateFindBoxL(
CEikListBox* aListBox,
CTextListBoxModel* aModel,
CAknSearchField::TSearchFieldStyle aStyle )
{
CAknSearchField* findbox = NULL;
if ( aListBox && aModel )
{
// Gets pointer of CAknFilteredTextListBoxModel.
CAknFilteredTextListBoxModel* model =
static_cast<CAknFilteredTextListBoxModel*>( aModel );
// Creates FindBox.
findbox = CAknSearchField::NewL( *this,
aStyle,
NULL,
KAknExListFindBoxTextLength );
CleanupStack::PushL( findbox );
// Creates CAknListBoxFilterItems class.
model->CreateFilterL( aListBox, findbox );
//Filter can get by model->Filter();
CleanupStack::Pop( findbox ); // findbox
}
return findbox;
}
// ----------------------------------------------------------------------------
// CAknExListBaseContainer::AutoNumberingL()
// Automatic numbering of list item.
// ----------------------------------------------------------------------------
//
void CAknExListBaseContainer::AutoNumberingL(
CEikTextListBox* aListBox )
{
// Change it because CListBoxNumbers will be removed on Sw 2.10.
// Source is replaced to the copy of Sw 2.05's CListBoxNumbers::UpdateL()
TInt itemCount( aListBox->Model()->NumberOfItems() );
MDesCArray* itemList = aListBox->Model()->ItemTextArray();
CDesCArray* itemArray = static_cast<CDesCArray*>( itemList );
for ( TInt i( 0 ); i < itemCount; i++ )
{
TPtrC item = ( *itemArray )[i];
TInt pos = item.Locate( KAknExListTab );
TBuf<256> data;
data.Num( i + 1 );
data += item.Right( item.Length() - pos );
itemArray->Delete( i );
itemArray->InsertL( i, data );
}
}
// ----------------------------------------------------------------------------
// CAknExListBaseContainer::SetGraphicIconL()
// Sets graphic icon using listbox as CEikColumnListBox.
// ----------------------------------------------------------------------------
//
void CAknExListBaseContainer::SetGraphicIconL( CEikColumnListBox* aListBox )
{
if ( aListBox )
{
// Creates gul icon.
CArrayPtr<CGulIcon>* icons =
new ( ELeave ) CAknIconArray(
KAknExListGraphicGulIconIndex );
CleanupStack::PushL( icons );
GraphicIconL( icons ); // Appends graphic data.
// Sets graphics as ListBox icon.
aListBox->ItemDrawer()->ColumnData()->SetIconArray( icons );
CleanupStack::Pop();
}
}
// ----------------------------------------------------------------------------
// CAknExListBaseContainer::SetGraphicIconL()
// Sets graphic icon using listbox as CEikFormattedCellListBox.
// ----------------------------------------------------------------------------
//
void CAknExListBaseContainer::SetGraphicIconL(
CEikFormattedCellListBox* aListBox )
{
if ( aListBox )
{
// Creates gul icon.
CArrayPtr<CGulIcon>* icons =
new ( ELeave ) CAknIconArray(
KAknExListGraphicGulIconIndex );
CleanupStack::PushL( icons );
GraphicIconL( icons ); // Appends graphic data.
// Sets graphics as ListBox icon.
aListBox->ItemDrawer()->FormattedCellData()->SetIconArrayL( icons );
// Drawing position of icon is left.
//aListBox->ItemDrawer()->FormattedCellData()->SetSubCellAlignmentL(
// 2, CGraphicsContext::ELeft );
CleanupStack::Pop();
}
}
// ---------------------------------------------------------------------------
// CAknExListBaseContainer::SetEmptyListL()
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -