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

📄 alllistscontainer.cpp

📁 《基于Symbian OS的手机开发与应用实践》这本书的配套源码。
💻 CPP
字号:
/*
* ============================================================================
*  Name     : CAllListsContainer from ALLLISTSsContainer.h
*  Part of  : ALLLISTSs
*  Created  : 16.03.2006 by ToBeReplacedByAuthor
*  Implementation notes:
*     Initial content was generated by Series 60 Application Wizard.
*  Version  :
*  Copyright: ToBeReplacedByCopyright
* ============================================================================
*/

// INCLUDE FILES
#include <barsread.h>       // for TResourceReader
#include <eikclbd.h>        // for CColumnListBoxData
#include <eikclb.h>         // for CEikColumnListBox
#include <eikapp.h>
#include <aknlists.h>
#include <akniconarray.h>
#include <AllLists.rsg>
#include <AllLists.mbg>

#include "AllListsContainer.h"



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

// ---------------------------------------------------------
// CAllListsContainer::ConstructL(const TRect& aRect)
// EPOC two phased constructor
// ---------------------------------------------------------
//
void CAllListsContainer::ConstructL(const TRect& aRect)
    {
    CreateWindowL();

    ShowListBoxL(R_ALLLISTS_SINGLE_LISTBOX);

    SetRect(aRect);
    ActivateL();
    }

// Destructor
CAllListsContainer::~CAllListsContainer()
    {
    delete iListBox;
    }

// New functions
void CAllListsContainer::ShowListBoxL(TInt aResourceId)
    {
    delete iListBox;
    iListBox = NULL;
    switch(aResourceId)
        {
        case R_ALLLISTS_SINGLENUMBER_LISTBOX:
            {
            iListBox = new(ELeave) CAknSingleNumberStyleListBox;
            break;
            }
        case R_ALLLISTS_SINGLEHEADING_LISTBOX:
            {
            iListBox = new(ELeave) CAknSingleHeadingStyleListBox;
            break;
            }
        case R_ALLLISTS_SINGLEGRAPHIC_LISTBOX:
            {
            iListBox = new(ELeave) CAknSingleGraphicStyleListBox;
            break;
            }
        case R_ALLLISTS_SINGLEGRAPHICHEADING_LISTBOX:
            {
            iListBox = new(ELeave) CAknSingleGraphicHeadingStyleListBox;
            break;
            }
        case R_ALLLISTS_SINGLENUMBERHEADING_LISTBOX:
            {
            iListBox = new(ELeave) CAknSingleNumberHeadingStyleListBox;
            break;
            }
        case R_ALLLISTS_SINGLELARGE_LISTBOX:
            {
            iListBox = new(ELeave) CAknSingleLargeStyleListBox;
            break;
            }
        case R_ALLLISTS_SINGLE_LISTBOX:
        default:
            {
            iListBox = new(ELeave) CAknSingleStyleListBox;
            break;
            }
        }

        // Create listbox
        iListBox->SetContainerWindowL( *this );
        TResourceReader reader;
        CEikonEnv::Static()->CreateResourceReaderLC( reader, aResourceId );
        iListBox->ConstructFromResourceL( reader );
        CleanupStack::PopAndDestroy();

        // Creates scrollbar.
        iListBox->CreateScrollBarFrameL( ETrue );
        iListBox->ScrollBarFrame()->SetScrollBarVisibilityL(
            CEikScrollBarFrame::EOff, CEikScrollBarFrame::EAuto );

        SizeChanged();

        // Create an array of icons, reading them from the file
        CEikonEnv* eikonEnv = CEikonEnv::Static();
        TFileName mbmFile = eikonEnv->EikAppUi()->Application()->BitmapStoreName();
        CArrayPtr<CGulIcon>* icons = new(ELeave) CAknIconArray(4);
        CleanupStack::PushL(icons);
        icons->AppendL(eikonEnv->CreateIconL(mbmFile, EMbmAlllistsG1, EMbmAlllistsGm1));
        icons->AppendL(eikonEnv->CreateIconL(mbmFile, EMbmAlllistsG2, EMbmAlllistsGm2));
        icons->AppendL(eikonEnv->CreateIconL(mbmFile, EMbmAlllistsG3, EMbmAlllistsGm3));
        CleanupStack::Pop(icons);
         // Transfer ownership
        iListBox->ItemDrawer()->ColumnData()->SetIconArray(icons);
    }


// ---------------------------------------------------------
// CAllListsContainer::SizeChanged()
// Called by framework when the view size is changed
// ---------------------------------------------------------
//
void CAllListsContainer::SizeChanged()
    {
    // TODO: Add here control resize code etc.
    iListBox->SetRect(Rect());
    }

// ---------------------------------------------------------
// CAllListsContainer::CountComponentControls() const
// ---------------------------------------------------------
//
TInt CAllListsContainer::CountComponentControls() const
    {
    return 1; // return nbr of controls inside this container
    }

// ---------------------------------------------------------
// CAllListsContainer::ComponentControl(TInt aIndex) const
// ---------------------------------------------------------
//
CCoeControl* CAllListsContainer::ComponentControl(TInt aIndex) const
    {
    switch ( aIndex )
        {
        case 0:
            return iListBox;
        default:
            return NULL;
        }
    }

// ---------------------------------------------------------
// CAllListsContainer::Draw(const TRect& aRect) const
// ---------------------------------------------------------
//
void CAllListsContainer::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 );
    }

TKeyResponse CAllListsContainer::OfferKeyEventL(const TKeyEvent& aKeyEvent,TEventCode aType)
    {
    if((aKeyEvent.iCode == EKeyLeftArrow) ||
       (aKeyEvent.iCode == EKeyRightArrow))
       {
       return EKeyWasNotConsumed;
       }

    return iListBox->OfferKeyEventL(aKeyEvent, aType);
    }

// End of File  

⌨️ 快捷键说明

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