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

📄 listviewcontainer.cpp

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

// INCLUDE FILES
#include "ListViewContainer.h"

#include <eiklabel.h>  // for label control
#include <barsread.h>  // BAFL, for resource reader
#include <aknlists.h>  // for Listbox
#include <multiview.rsg>

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

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

    iListBox = new(ELeave)CAknSingleStyleListBox();
    iListBox->SetContainerWindowL(*this);
    TResourceReader reader;
    CEikonEnv::Static()->CreateResourceReaderLC(reader, R_AKNTALIST_SINGLE);
    iListBox->ConstructFromResourceL( reader );
    CleanupStack::PopAndDestroy(); // resource stuffs. 

    SetRect(aRect);
    ActivateL();
    }

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

// ---------------------------------------------------------
// CListViewContainer::SizeChanged()
// Called by framework when the view size is changed
// ---------------------------------------------------------
//
void CListViewContainer::SizeChanged()
    {
    // TODO: Add here control resize code etc.
    iListBox->SetExtent( TPoint(0,0), iListBox->MinimumSize() );
    }

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

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

// ---------------------------------------------------------
// CListViewContainer::Draw(const TRect& aRect) const
// ---------------------------------------------------------
//
void CListViewContainer::Draw(const TRect& aRect) const
    {
    CWindowGc& gc = SystemGc();
    gc.Clear();
    }

// ----------------------------------------------------------------------------
// void CListViewContainer::HandleListBoxEventL( CEikListBox*,
//  TListBoxEvent )
// Handles listbox event.
// ----------------------------------------------------------------------------
void CListViewContainer::HandleListBoxEventL(
    CEikListBox* /*aListBox*/,
    TListBoxEvent aEventType )
    {
    //TInt currentItem( iListBox->CurrentItemIndex() );
    //CDesCArray* array = static_cast<CDesCArray*>(iListBox->Model()->ItemTextArray());
    if ( aEventType == MEikListBoxObserver::EEventEnterKeyPressed  ||
         aEventType == MEikListBoxObserver::EEventItemClicked )
        {
        
        }
    }

// ---------------------------------------------------------
// CListViewContainer::OfferKeyEventL(...)
// Notify key events to editors.
// ---------------------------------------------------------
//
TKeyResponse CListViewContainer::OfferKeyEventL(
    const TKeyEvent& aKeyEvent, TEventCode aType)
    {
    if ( aType != EEventKey ) // Is not key event?
        {
        return EKeyWasNotConsumed;
        }
    if (aKeyEvent.iCode == EKeyRightArrow)
        {
        return EKeyWasNotConsumed;
        }
    if (iListBox)
        {
        return iListBox->OfferKeyEventL(aKeyEvent, aType);
        }
    return EKeyWasNotConsumed;
    }

// End of File  

⌨️ 快捷键说明

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