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

📄 allmlistscontainer.cpp

📁 《基于Symbian OS的手机开发与应用实践》这本书的配套源码。
💻 CPP
字号:
/*
* ============================================================================
*  Name     : CAllMListsContainer from ALLMLISTSsContainer.h
*  Part of  : ALLMLISTSs
*  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 <AllMLists.rsg>
#include <AllMLists.mbg>

#include "AllMListsContainer.h"



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

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

    ShowListBoxL(R_ALLMLISTS_SINGLE_LISTBOX);

    SetRect(aRect);
    ActivateL();
    }

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

// New functions
void CAllMListsContainer::ShowListBoxL(TInt aResourceId)
    {
    delete iListBox;
    iListBox = NULL;
    switch(aResourceId)
        {
        case R_ALLMLISTS_SINGLENUMBER_LISTBOX:
            {
            iListBox = new(ELeave) CAknSingleNumberStyleListBox;
            break;
            }
        case R_ALLMLISTS_SINGLEHEADING_LISTBOX:
            {
            iListBox = new(ELeave) CAknSingleHeadingStyleListBox;
            break;
            }
        case R_ALLMLISTS_SINGLEGRAPHIC_LISTBOX:
            {
            iListBox = new(ELeave) CAknSingleGraphicStyleListBox;
            break;
            }
        case R_ALLMLISTS_SINGLEGRAPHICHEADING_LISTBOX:
            {
            iListBox = new(ELeave) CAknSingleGraphicHeadingStyleListBox;
            break;
            }
        case R_ALLMLISTS_SINGLENUMBERHEADING_LISTBOX:
            {
            iListBox = new(ELeave) CAknSingleNumberHeadingStyleListBox;
            break;
            }
        case R_ALLMLISTS_SINGLELARGE_LISTBOX:
            {
            iListBox = new(ELeave) CAknSingleLargeStyleListBox;
            break;
            }
        case R_ALLMLISTS_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, EMbmAllmlistsTick, EMbmAllmlistsTickmask));
        icons->AppendL(eikonEnv->CreateIconL(mbmFile, EMbmAllmlistsG1, EMbmAllmlistsGm1));
        icons->AppendL(eikonEnv->CreateIconL(mbmFile, EMbmAllmlistsG2, EMbmAllmlistsGm2));
        icons->AppendL(eikonEnv->CreateIconL(mbmFile, EMbmAllmlistsG3, EMbmAllmlistsGm3));
        CleanupStack::Pop(icons);
         // Transfer ownership
        iListBox->ItemDrawer()->ColumnData()->SetIconArray(icons);
    }

/**
* Handles marking commands for all currently selected games, by passing them 
* to the AknSelectionService
*/
void CAllMListsContainer::HandleMarkCommandL(TInt aCommand)
    {
    AknSelectionService::HandleMarkableListProcessCommandL (aCommand, iListBox);
    }

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

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

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

// ---------------------------------------------------------
// CAllMListsContainer::Draw(const TRect& aRect) const
// ---------------------------------------------------------
//
void CAllMListsContainer::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 CAllMListsContainer::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 + -