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

📄 allmlistscontainer2.cpp

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

#include "AllMListsContainer2.h"




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

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

    ShowListBoxL(R_ALLMLISTS_DOUBLE_LISTBOX);

    SetRect(aRect);
    ActivateL();
    }

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

// New functions
void CAllMListsContainer2::ShowListBoxL(TInt aResourceId)
    {
    delete iListBox;
    iListBox = NULL;
    switch(aResourceId)
        {
        case R_ALLMLISTS_FORMDOUBLE_LISTBOX:
            {
            iListBox = new(ELeave) CAknFormDoubleStyleListBox;
            break;
            }
        case R_ALLMLISTS_DOUBLE2_LISTBOX:
            {
            iListBox = new(ELeave) CAknDoubleStyle2ListBox;
            break;
            }
        case R_ALLMLISTS_DOUBLENUMBER_LISTBOX:
            {
            iListBox = new(ELeave) CAknDoubleNumberStyleListBox;
            break;
            }
        case R_ALLMLISTS_DOUBLETIME_LISTBOX:
            {
            iListBox = new(ELeave) CAknDoubleTimeStyleListBox;
            break;
            }
        case R_ALLMLISTS_DOUBLELARGE_LISTBOX:
            {
            iListBox = new(ELeave) CAknDoubleLargeStyleListBox;
            break;
            }
        case R_ALLMLISTS_DOUBLEGRAPHIC_LISTBOX:
            {
            iListBox = new(ELeave) CAknDoubleGraphicStyleListBox;
            break;
            }
        case R_ALLMLISTS_FORMDOUBLEGRAPHIC_LISTBOX:
            {
            iListBox = new(ELeave) CAknFormDoubleGraphicStyleListBox;
            break;
            }
        case R_ALLMLISTS_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(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()->FormattedCellData()->SetIconArray( icons );
    }

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

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

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

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

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