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

📄 allslistscontainer2.cpp

📁 《基于Symbian OS的手机开发与应用实践》这本书的配套源码。
💻 CPP
字号:
/*
* ============================================================================
*  Name     : CAllSListsContainer2 from AllSListsContainer2.cpp
*  Part of  : AllSLists
*  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 <eikfrlbd.h>       // for CFormattedCellListBoxData
#include <eikfrlb.h>        // for CEikFormattedCellListBox
#include <eikapp.h>
#include <aknlists.h>
#include <akniconarray.h>
#include <AllSLists.rsg>
#include <AllSLists.mbg>

#include "AllSListsContainer2.h"




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

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

    ShowListBoxL(R_ALLSLISTS_DOUBLE_LISTBOX);

    SetRect(aRect);
    ActivateL();
    }

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

// New functions
void CAllSListsContainer2::ShowListBoxL(TInt aResourceId)
    {
    delete iListBox;
    iListBox = NULL;
    switch(aResourceId)
        {
        case R_ALLSLISTS_FORMDOUBLE_LISTBOX:
            {
            iListBox = new(ELeave) CAknFormDoubleStyleListBox;
            break;
            }
        case R_ALLSLISTS_DOUBLE2_LISTBOX:
            {
            iListBox = new(ELeave) CAknDoubleStyle2ListBox;
            break;
            }
        case R_ALLSLISTS_DOUBLENUMBER_LISTBOX:
            {
            iListBox = new(ELeave) CAknDoubleNumberStyleListBox;
            break;
            }
        case R_ALLSLISTS_DOUBLETIME_LISTBOX:
            {
            iListBox = new(ELeave) CAknDoubleTimeStyleListBox;
            break;
            }
        case R_ALLSLISTS_DOUBLELARGE_LISTBOX:
            {
            iListBox = new(ELeave) CAknDoubleLargeStyleListBox;
            break;
            }
        case R_ALLSLISTS_DOUBLEGRAPHIC_LISTBOX:
            {
            iListBox = new(ELeave) CAknDoubleGraphicStyleListBox;
            break;
            }
        case R_ALLSLISTS_FORMDOUBLEGRAPHIC_LISTBOX:
            {
            iListBox = new(ELeave) CAknFormDoubleGraphicStyleListBox;
            break;
            }
        case R_ALLSLISTS_DOUBLE_LISTBOX:
        default:
            {
            iListBox = new(ELeave) CAknDoubleStyleListBox;
            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(5);
        CleanupStack::PushL(icons);
        icons->AppendL(eikonEnv->CreateIconL(mbmFile, EMbmAllslistsCheck, EMbmAllslistsCheckmask));
        icons->AppendL(eikonEnv->CreateIconL(mbmFile, EMbmAllslistsUncheck, EMbmAllslistsUncheckmask));
        icons->AppendL(eikonEnv->CreateIconL(mbmFile, EMbmAllslistsG1, EMbmAllslistsGm1));
        icons->AppendL(eikonEnv->CreateIconL(mbmFile, EMbmAllslistsG2, EMbmAllslistsGm2));
        icons->AppendL(eikonEnv->CreateIconL(mbmFile, EMbmAllslistsG3, EMbmAllslistsGm3));
        CleanupStack::Pop(icons);

         // Transfer ownership
        iListBox->ItemDrawer()->FormattedCellData()->SetIconArray( icons );
    }

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

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

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

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

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