singlelistbox.cpp

来自「0S9.平台任务管理.内存监控示例.还sign后才可以安装」· C++ 代码 · 共 99 行

CPP
99
字号
#include "ListBoxProxy.h"

#include <eiktxlbm.h>   // CTextListBoxModel
#include <eikclbd.h>    // CColumnListBoxData

void CSingleListBox::ConstructL(CCoeControl* aParent, TInt /*aFlags*/)
{
    CEikColumnListBox::ConstructL(aParent);
}

TInt CSingleListBox::CurrentItemIndex() const
{
    return CEikColumnListBox::CurrentItemIndex();
}

TKeyResponse CSingleListBox::OfferKeyEventL(const TKeyEvent& aKeyEvent, TEventCode aType)
{
    return CEikColumnListBox::OfferKeyEventL(aKeyEvent, aType);
}

void CSingleListBox::RefreshL()
{
    CEikColumnListBox::HandleItemRemovalL();
    CEikColumnListBox::HandleItemAdditionL();
    CEikColumnListBox::SetCurrentItemIndex(0);
    CEikColumnListBox::SetFocus(ETrue);
}

void CSingleListBox::SetContainerWindowL(const CCoeControl& aContainer)
{
    CEikColumnListBox::SetContainerWindowL(aContainer);
}

void CSingleListBox::SetItemList(MDesCArray* aTextArray, CArrayPtr<CGulIcon>* aIconArray)
{
    Model()->SetItemTextArray(aTextArray);
    Model()->SetOwnershipType(ELbmDoesNotOwnItemArray);

    CColumnListBoxData* cd = ItemDrawer()->ColumnData();
    cd->SetIconArray(aIconArray);

    cd->SetGraphicsColumnL(0, ETrue);
    cd->SetColumnWidthPixelL(0, 20);
    cd->SetColumnAlignmentL(0, CGraphicsContext::ECenter);

    cd->SetColumnWidthPixelL(1, 120);
    cd->SetColumnAlignmentL(1, CGraphicsContext::ELeft);

    cd->SetColumnWidthPixelL(2, 50);
    cd->SetColumnAlignmentL(2, CGraphicsContext::ELeft);
}

void CSingleListBox::SetListBoxObserver(MEikListBoxObserver* aObserver)
{
    CEikColumnListBox::SetListBoxObserver(aObserver);
}

void CSingleListBox::SetMopParent(MObjectProvider* /*aParent*/)
{}

void CSingleListBox::SetRect(const TRect& aRect)
{
    TInt rectHeight = aRect.Height();
#if   defined(__S80__)
    const TInt height(rectHeight / 6);      // 6 items per screen
#elif defined(__S90__)
    const TInt height(rectHeight / 8);
#elif defined(__UIQ__)
    const TInt height(rectHeight / 10);
#endif

    CEikTextListBox::SetItemHeightL(height);
    CEikColumnListBox::SetRect(aRect);
}

void CSingleListBox::SetScrollBarL()
{
    CEikColumnListBox::CreateScrollBarFrameL();
}

void CSingleListBox::ShowScrollBarL(TBool aShow)
{
    if (CEikTextListBox::ScrollBarFrame())
    {
        if (aShow)
            CEikTextListBox::ScrollBarFrame()->SetScrollBarVisibilityL(CEikScrollBarFrame::EOff, CEikScrollBarFrame::EAuto);
        else
            CEikTextListBox::ScrollBarFrame()->SetScrollBarVisibilityL(CEikScrollBarFrame::EOff, CEikScrollBarFrame::EOff);

        CEikTextListBox::UpdateScrollBarsL();
    }
}

CEikListBox* CSingleListBox::This()
{
    return this;
}

⌨️ 快捷键说明

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