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

📄 aknexlistbasecontainer.cpp

📁 Symbian手机编程
💻 CPP
📖 第 1 页 / 共 2 页
字号:
/*
* =============================================================================
*  Name     : CAknExListBaseContainer
*  Part of  : AknExList
*  Copyright (c) 2003 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

// CONSTANTS
#define KAknExListGray TRgb(0xaaaaaa)
#define KAknExListTab '\t'

const TInt KAknExListFindBoxTextLength(20); // for findbox.
// for lenght.
const TInt KAknExListEmptyListBufLength(256);
const TInt KAknExListAddItemBufLength(256);
const TInt KAknExListInfoMessageBufLength(256);
const TInt KAknExListCountMessageBufLength(256);
const TInt KAknTAListShowMessageBufLength(256);

// ================= MEMBER FUNCTIONS =========================================

// ----------------------------------------------------------------------------
// CAknExListBaseContainer::CAknExListBaseContainer()
// Default constructor.
// ----------------------------------------------------------------------------
//
CAknExListBaseContainer::CAknExListBaseContainer()
    {
    }

// ----------------------------------------------------------------------------
// CAknExListBaseContainer::~CAknExListBaseContainer()
// Destructor.
// ----------------------------------------------------------------------------
//
CAknExListBaseContainer::~CAknExListBaseContainer()
    {
    }

// ----------------------------------------------------------------------------
// void CAknExListBaseContainer::SetListBoxFromResourceL( CEikColumnListBox*,
//  const TInt )
// 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 );
        }
    }

// ----------------------------------------------------------------------------
// void CAknExListBaseContainer::SetListBoxFromResourceL(
//  CEikFormattedCellListBox*, const TInt )
// 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 );
        }
    }

// ----------------------------------------------------------------------------
// void CAknExListBaseContainer::SetListBoxFromInnerDescriptionL(
//  CEikColumnListBox*, const TInt, CDesCArray* )
// 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 );
        }
    }

// ----------------------------------------------------------------------------
// void CAknExListBaseContainer::SetListBoxFromInnerDescriptionL(
//  CEikFormattedCellListBox*, const TInt, CDesCArray* )
// 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 );
        }
    }

// ----------------------------------------------------------------------------
// CAknSearchField* 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;
    }

// ----------------------------------------------------------------------------
// void CAknExListBaseContainer::AutoNumberingL( CEikTextListBox* )
// 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);
        }   
    }

// ----------------------------------------------------------------------------
// void CAknExListBaseContainer::SetGraphicIconL( CEikColumnListBox* )
// 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();

        }
    }

// ----------------------------------------------------------------------------
// void CAknExListBaseContainer::SetGraphicIconL( CEikFormattedCellListBox* )
// 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(

⌨️ 快捷键说明

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