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

📄 aknexlistformcontainer.cpp

📁 Symbian手机编程
💻 CPP
📖 第 1 页 / 共 2 页
字号:
/*
* =============================================================================
*  Name     : CAknExListFormContainer
*  Part of  : AknExList
*  Copyright (c) 2003 Nokia. All rights reserved.
* =============================================================================
*/

// INCLUDE FILES
#include <aknlists.h> // for avrell style listbox
#include <akntabgrp.h>
#include <aknexlist.rsg>
#include <aknexlist.mbg>
#include "AknExList.hrh"
#include "AknExListConst.h"
#include "AknExListFormView.h"
#include "AknExListFormContainer.h"

// CONSTANTS
const TInt KAknExListInitCount = 0; // for initialization.

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

// ----------------------------------------------------------------------------
// CAknExListFormContainer::CAknExListFormContainer( CAknExListFormView* )
// Copy constructor.
// ----------------------------------------------------------------------------
//
CAknExListFormContainer::CAknExListFormContainer( CAknExListFormView* aView )
:   iListBox( NULL ),
    iView( aView ),
    iFindBox( NULL ),
    iOutlineId( KAknExListInitOutlineId )
    {
    }

// ----------------------------------------------------------------------------
// void CAknExListFormContainer::ConstructL( const TRect& )
// EPOC two phased constructor.
// ----------------------------------------------------------------------------
//
void CAknExListFormContainer::ConstructL( const TRect& aRect )
    {
    CreateWindowL(); // Creates window.
    SetRect( aRect ); // Sets rectangle of frame.
    ActivateL(); // Activates window. (Ready to draw)
    }

// ----------------------------------------------------------------------------
// CAknExListFormContainer::~CAknExListFormContainer()
// Destructor.
// ----------------------------------------------------------------------------
//
CAknExListFormContainer::~CAknExListFormContainer()
    {
    delete iListBox; // Deletes listbox object.
    delete iFindBox; // Deletes findbox object.
    }

// ----------------------------------------------------------------------------
// void CAknExListFormContainer::DisplayListBoxL( const TInt )
// Displays listbox.
// ----------------------------------------------------------------------------
//
void CAknExListFormContainer::DisplayListBoxL( const TInt aOutlineId )
    {
    // Sets outlineId.
    iOutlineId = aOutlineId;

    // Deletes listbox object.
    if ( iListBox )
        {
        delete iListBox;
        iListBox = NULL;
        }

    // Deletes findbox object.
    if ( iFindBox )
        {
        delete iFindBox;
        iFindBox = NULL;
        }

    TInt resourceId( KAknExListInitListResourceId ); // For listbox.
    TInt emptyResourceId( KAknExListInitEmptyResourceId ); // For empty text.
    TInt messageId( KAknExListMessageInitId ); // For displaying message.
    TBool flagsOfGraphic( EFalse ); // Flag for graphic.
    TBool flagsOfNumber( EFalse ); // Flag for auto numbering.
    TBool flagsOfFindBox( EFalse ); // Flag for findbox.
    CAknTabGroup* tabGroup = iView->TabGroup();

    // Creates ListBox control object and sets resource ID.
    switch ( iOutlineId ) // Outline ID is...
        {
        case EAknExListCmdOutline16: // OUTLINE16 screen.
            resourceId = R_AKNEXLIST_BIG_SINGLE;
            iListBox = new( ELeave ) CAknDoubleStyleListBox();
            break;
        case EAknExListCmdOutline17: // OUTLINE17 screen.
            resourceId = R_AKNEXLIST_BIG_SINGLE_NUMBER;
            if ( tabGroup )
                {
                flagsOfNumber = ETrue;
                }
            else
                {
                messageId = R_AKNEXLIST_USER_DEFINED_NUMBERING_MSG;
                }
            iListBox = new( ELeave ) CAknDoubleNumberStyleListBox();
            break;
        case EAknExListCmdOutline18: // OUTLINE18 screen.
            resourceId = R_AKNEXLIST_BIG_SINGLE_GRAPHIC;
            iListBox = new( ELeave ) CAknDoubleLargeStyleListBox();
            flagsOfGraphic = ETrue;
            break;
        case EAknExListCmdOutline19: // OUTLINE19 screen.
            resourceId = R_AKNEXLIST_DOUBLE;
            iListBox = new( ELeave ) CAknDoubleStyleListBox();
            break;
        case EAknExListCmdOutline20: // OUTLINE20 screen.
            resourceId = R_AKNEXLIST_DOUBLE_NUMBER;
            if ( tabGroup )
                {
                flagsOfNumber = ETrue;
                }
            else
                {
                messageId = R_AKNEXLIST_USER_DEFINED_NUMBERING_MSG;
                }
            iListBox = new( ELeave ) CAknDoubleNumberStyleListBox();
            break;
        case EAknExListCmdOutline21: // OUTLINE21 screen.
            resourceId = R_AKNEXLIST_DOUBLE_LARGE_GRAPHIC;
            iListBox = new( ELeave ) CAknDoubleLargeStyleListBox();
            flagsOfGraphic = ETrue;
            break;
        case EAknExListCmdOutline41T3: // Popup findbox of OUTLINE41 screen.
            resourceId = R_AKNEXLIST_DOUBLE;
            flagsOfFindBox = ETrue;
            iListBox = new( ELeave ) CAknDoubleStyleListBox();
            break;
        case EAknExListCmdOutline53: // OUTLINE53 screen.
            resourceId = R_AKNEXLIST_DOUBLE_NUMBER;
            flagsOfNumber = ETrue;
            iListBox = new( ELeave ) CAknDoubleNumberStyleListBox();
            break;
        case EAknExListCmdOutline54: // OUTLINE54 screen.
            resourceId = R_AKNEXLIST_BIG_SINGLE_NUMBER;
            flagsOfNumber = ETrue;
            iListBox = new( ELeave ) CAknDoubleNumberStyleListBox();
            break;
        case EAknExListCmdOutline55: // OUTLINE55 screen.
            resourceId = R_AKNEXLIST_DOUBLE_GRAPHIC;
            iListBox = new( ELeave ) CAknDoubleGraphicStyleListBox();
            flagsOfGraphic = ETrue;
            break;
        case EAknExListCmdOutline57: // OUTLINE57 screen.
            resourceId = R_AKNEXLIST_DOUBLE_LARGE_GRAPHIC;
            iListBox = new( ELeave ) CAknDoubleLargeStyleListBox();
            flagsOfGraphic = ETrue;
            break;
        case EAknExListCmdOutline58: // OUTLINE58 screen.
            resourceId = R_AKNEXLIST_BIG_SINGLE_GRAPHIC;
            iListBox = new( ELeave ) CAknDoubleLargeStyleListBox();
            flagsOfGraphic = ETrue;
            break;
        case EAknExListCmdOutline67: // OUTLINE67 screen.
            resourceId = R_AKNEXLIST_DOUBLE;
            iListBox = new( ELeave ) CAknDoubleStyleListBox();
            break;
        case EAknExListCmdOutline68: // OUTLINE68 screen.
            iListBox = new( ELeave ) CAknDoubleStyleListBox();
            break;
        case EAknExListCmdOutline71: // OUTLINE71 screen.
            emptyResourceId = R_AKNEXLIST_TWO_LINES_EMPTY_LABEL;
            iListBox = new( ELeave ) CAknDoubleStyleListBox();
            break;
        default:
            break;
        }

    if ( iListBox )
        {
        // Sets ListBox.
        if ( resourceId )
            {
            SetListBoxFromResourceL( iListBox, resourceId );
            }
        else
            {
            SetListBoxFromInnerDescriptionL( iListBox );
            }

        if ( flagsOfFindBox )
            {
            // Creates FindBox as popup.
            iFindBox = CreateFindBoxL(
                iListBox, iListBox->Model(), CAknSearchField::EPopup );

            if ( iFindBox )
                {
                // Popup findbox is not shown when listbox display initial.
                iFindBox->MakeVisible( EFalse );
                }
            }

        SizeChanged();

        if ( flagsOfNumber )
            {
            // Automatic numbering.
            AutoNumberingL( iListBox );
            }

        if ( flagsOfGraphic )
            {
            // Creates graphic.
            SetGraphicIconL( iListBox );
            }

        if ( emptyResourceId )
            {
            // Sets empty text.
            SetEmptyListL( iListBox, emptyResourceId );
            }

        iListBox->ActivateL();

        if ( iFindBox )
            {
            // For window owning overlay control when findbox is popup.
            iFindBox->ActivateL();
            }
        // Update scrollbar in order to draw correct scroll bar.
        UpdateScrollBar(iListBox);
        
        }

    DrawNow();

    if ( messageId )
        {
        InfoMessage( messageId ); // Displays information message.
        }
    }

// ----------------------------------------------------------------------------
// TKeyResponse CAknExListFormContainer::OfferKeyEventL( const TKeyEvent&,
//  TEventCode )
// Handles the key events.
// ----------------------------------------------------------------------------
//
TKeyResponse CAknExListFormContainer::OfferKeyEventL(
    const TKeyEvent& aKeyEvent,
    TEventCode aType )
    {
    if ( aType != EEventKey ) // Is not key event?
        {
        return EKeyWasNotConsumed;
        }

    CAknTabGroup* tabGroup = iView->TabGroup();
    TChar charCode(aKeyEvent.iCode);

    switch ( charCode ) // The code of key event is...
        {
        case EKeySpace: // Space key.
            iView->DisplayNextOutlineL();
            return EKeyWasConsumed;
        // Switches tab.
        case EKeyLeftArrow: // Left key.
        case EKeyRightArrow: // Right Key.
            if ( tabGroup ) // Is tab group created?
                {
                if ( tabGroup->OfferKeyEventL( aKeyEvent, aType ) ==
                     EKeyWasConsumed )
                    {
                    iView->SwitchDisplayOutlineL(

⌨️ 快捷键说明

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