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

📄 aknexlistsettingcontainer.cpp

📁 symbian ui的 例子 初学者可以 好好看看,这个是培训的资料,应该比较宝贵
💻 CPP
📖 第 1 页 / 共 2 页
字号:
/*  Copyright (c) 2005, Nokia. All rights reserved */

// INCLUDE FILES
#include <aknlists.h> // for avrell style listbox
#include <akntabgrp.h>
#include <akndef.h>
#include <aknexlist.rsg>
#include <aknexlist.mbg>
#include "AknExList.hrh"
#include "AknExListConst.h" // for bitmap file name
#include "AknExListSettingView.h"
#include "AknExListSettingContainer.h"


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

// ----------------------------------------------------------------------------
// CAknExListSettingContainer::CAknExListSettingContainer()
// Copy constructor.
// ----------------------------------------------------------------------------
//
CAknExListSettingContainer::CAknExListSettingContainer( 
                                                CAknExListSettingView* aView )
: iListBox( NULL ), iView( aView ), iOutlineId( KAknExListInitOutlineId )
    {
    }

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

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

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

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

    TInt resourceId( KAknExListInitListResourceId ); // For listbox.
    TInt emptyResourceId( KAknExListInitEmptyResourceId ); // For empty text.
    TInt messageId( KAknExListMessageInitId ); // For displaying message.
    TBool flagsOfNumber( EFalse ); // Flag for auto numbering.
    TBool flagsOfGraphic( EFalse ); // Flag for graphic.

    // Creates ListBox control object and sets resource ID.
    switch ( iOutlineId ) // Outlind ID is...
        {
        case EAknExListCmdOutline22: // OUTLINE22 screen.
            resourceId = R_AKNEXLIST_SETTING;
            flagsOfGraphic = ETrue;
            iListBox = new ( ELeave ) CAknSettingStyleListBox();
            break;
        case EAknExListCmdOutline23: // OUTLINE23 screen.
            resourceId = R_AKNEXLIST_SETTING_NUMBER;
            flagsOfGraphic = ETrue;
            messageId = R_AKNEXLIST_USER_DEFINED_NUMBERING_MSG;
            iListBox = new ( ELeave ) CAknSettingNumberStyleListBox();
            break;
        case EAknExListCmdOutline59: // OUTLINE59 screen.
            resourceId = R_AKNEXLIST_SETTING_NUMBER;
            flagsOfNumber = ETrue;
            flagsOfGraphic = ETrue;
            iListBox = new ( ELeave ) CAknSettingNumberStyleListBox();
            break;
        case EAknExListCmdOutline74: // OUTLINE74 screen.
            resourceId = R_AKNEXLIST_SETTING;
            flagsOfGraphic = ETrue;
            iListBox = new ( ELeave ) CAknSettingStyleListBox();
            break;
        case EAknExListCmdOutline75: // OUTLINE75 screen.
            flagsOfGraphic = ETrue;
            iListBox = new ( ELeave ) CAknSettingStyleListBox();
            break;
        case EAknExListCmdOutline76: // OUTLINE76 screen.
            emptyResourceId = R_AKNEXLIST_TWO_LINES_EMPTY_LABEL;
            flagsOfGraphic = ETrue;
            iListBox = new ( ELeave ) CAknSettingStyleListBox();
            break;
        case EAknExListCmdOutline79: // OUTLINE79 screen.
            resourceId = R_AKNEXLIST_SETTING;
            flagsOfGraphic = ETrue;
            iListBox = new ( ELeave ) CAknSettingStyleListBox();
            break;
        default:
            break;
        }

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

        SizeChanged();

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

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

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

        iListBox->ActivateL();
        // Update scrollbar in order to draw correct scroll bar.
        UpdateScrollBar( iListBox );

        // erase the bitmap in cell
        switch ( iOutlineId ) // Outlind ID is...
            {
            case EAknExListCmdOutline22: // OUTLINE22 screen.
            case EAknExListCmdOutline74: // OUTLINE74 screen.
            case EAknExListCmdOutline75: // OUTLINE75 screen.
            case EAknExListCmdOutline76: // OUTLINE76 screen.
            case EAknExListCmdOutline79: // OUTLINE79 screen.
            case EAknExListCmdOutline23: // OUTLINE23 screen.
            case EAknExListCmdOutline59: // OUTLINE59 screen.
               
                iListBox->ItemDrawer()->FormattedCellData()->SetGraphicsSubCellL( 2,EFalse );
                break;
            }
        }

    DrawNow();

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

// ----------------------------------------------------------------------------
// CAknExListSettingContainer::OfferKeyEventL()
// Handles the key events.
// ----------------------------------------------------------------------------
//
TKeyResponse CAknExListSettingContainer::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( 
                                    tabGroup->TabIdFromIndex( 
                                        tabGroup->ActiveTabIndex() ) );
                    return EKeyWasConsumed;
                    }
                }
            break;
        default:
            {
            break;
            }

        }

    switch ( iOutlineId )
        {
        case EAknExListCmdOutline74:
            {
            if ( charCode == AKNEXLIST_ADDINGTYPE1_KEY || 
                charCode == AKNEXLIST_ADDINGTYPE2_KEY ||

⌨️ 快捷键说明

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