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

📄 allslistscontainer4.cpp

📁 各种Symbian ListBox的真实案例: 已经齐了
💻 CPP
字号:
/*
* ============================================================================
*  Name     : CAllSListsContainer4 from AllSListsContainer4.cpp
*  Part of  : AllSLists
*  Created  : 16.03.4006 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 "AllSListsContainer4.h"


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

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

    ShowListBoxL(R_ALLSLISTS_SINGLEPOPUP_LISTBOX);

    SetRect(aRect);
    ActivateL();
    }

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

// New functions
void CAllSListsContainer4::ShowListBoxL(TInt aResourceId)
    {
    delete iListBox;
    iListBox = NULL;
    switch(aResourceId)
        {
        case R_ALLSLISTS_SINGLEGRAPHICPOPUP_LISTBOX:
            {
            iListBox = new(ELeave) CAknSingleGraphicPopupMenuStyleListBox;
            break;
            }
        case R_ALLSLISTS_SINGLEGRAPHICPOPUPBT_LISTBOX:
            {
            iListBox = new(ELeave) CAknSingleGraphicBtPopupMenuStyleListBox;
            break;
            }
        case R_ALLSLISTS_SINGLEHEADINGPOPUP_LISTBOX:
            {
            iListBox = new(ELeave) CAknSingleHeadingPopupMenuStyleListBox;
            break;
            }
        case R_ALLSLISTS_SINGLEGRAPHICHEADINGPOPUP_LISTBOX:
            {
            iListBox = new(ELeave) CAknSingleGraphicHeadingPopupMenuStyleListBox;
            break;
            }
        case R_ALLSLISTS_DOUBLEPOPUP_LISTBOX:
            {
            iListBox = new(ELeave) CAknDoublePopupMenuStyleListBox;
            break;
            }
        case R_ALLSLISTS_DOUBLELARGEGRAPHICPOPUP_LISTBOX:
            {
            iListBox = new(ELeave) CAknDoubleLargeGraphicPopupMenuStyleListBox;
            break;
            }
        case R_ALLSLISTS_DOUBLE2POPUP_LISTBOX:
            {
            iListBox = new(ELeave) CAknDouble2PopupMenuStyleListBox;
            break;
            }
        case R_ALLSLISTS_SET_LISTBOX:
            {
            iListBox = new(ELeave) CAknSetStyleListBox;
            break;
            }
        case R_ALLSLISTS_FORMGRAPHIC_LISTBOX:
            {
            iListBox = new(ELeave) CAknFormGraphicStyleListBox;
            break;
            }
        case R_ALLSLISTS_FORMGRAPHICWIDE_LISTBOX:
            {
            iListBox = new(ELeave) CAknFormGraphicWideStyleListBox;
            break;
            }
        case R_ALLSLISTS_SINGLEPOPUP_LISTBOX:
        default:
            {
            iListBox = new(ELeave) CAknSinglePopupMenuStyleListBox;
            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 CAllSListsContainer4::HandleMarkCommandL(TInt aCommand)
    {
    AknSelectionService::HandleMarkableListProcessCommandL (aCommand, iListBox);
    }

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

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

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

// ---------------------------------------------------------
// CAllSListsContainer4::Draw(const TRect& aRect) const
// ---------------------------------------------------------
//
void CAllSListsContainer4::Draw(const TRect& aRect) const
    {
    CWindowGc& gc = SystemGc();
    // TODO: Add your drawing code here
    // example code...
    gc.SetPenStyle( CGraphicsContext::ENullPen );
    gc.SetBrushColor( KRgbWhite );
    gc.SetBrushStyle( CGraphicsContext::ESolidBrush );
    gc.DrawRect( aRect );
    }

TKeyResponse CAllSListsContainer4::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 + -