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

📄 listboxui.cpp

📁 这是一个学习Symbian的ListBox的好例子,我也是看学个学会的
💻 CPP
字号:
#include <eikmenup.h>
#include <avkon.hrh>
#include "ListBoxUi.h"
#include "ListBoxContainer.h" 
#include "ListBox.rsg"
#include "ListBox.hrh"

void ListBoxUi::ConstructL()
{
	BaseConstructL();
	_container = new (ELeave) ListBoxContainer;
	_container->SetMopParent(this);
	_container->ConstructL( ClientRect() );
	AddToStackL( _container );
}

ListBoxUi::~ListBoxUi()
{
	if (_container)
	{
		RemoveFromStack( _container );
		delete _container;
	}
}

void ListBoxUi::DynInitMenuPaneL(TInt resourceId, CEikMenuPane* menuPane)
{
    if (resourceId == R_MAIN_MENU)
		menuPane->SetItemDimmed(EListBoxCmdRemoveItem, _container == 0 || _container->isListBoxEmpty());
}

TKeyResponse ListBoxUi::HandleKeyEventL(const TKeyEvent& keyEvent, TEventCode type)
{
	if (type != EEventKeyDown)
		return EKeyWasNotConsumed;

	switch (keyEvent.iScanCode)
	{
        case EStdKeyLeftArrow:
			_container->cmdActivatePrevListBoxL();
			break;
        case EStdKeyRightArrow:
			_container->cmdActivateNextListBoxL();
			break;
		case EStdKeyBackspace:
			if (!_container->isListBoxEmpty())
				_container->cmdRemoveL();
			break;
		default:
			return EKeyWasNotConsumed;
	}
	return EKeyWasConsumed;
}

void ListBoxUi::HandleCommandL(TInt cmd)
{
	switch (cmd)
	{
		case EAknSoftkeyExit:
		case EEikCmdExit:
			Exit();
			break;
		case EListBoxCmdAddItem:
			_container->cmdAddL();
			break;
		case EListBoxCmdRemoveItem:
			_container->cmdRemoveL();
			break;
		case EAknCmdMark:
		{
			TInt currentItem = _container->getCurrentListBoxItem();
			if (currentItem != -1)
				_container->cmdMark(currentItem, true);
			break;
		}
		case EAknMarkAll:
			_container->cmdMark(-1, true);
			break;
		case EAknCmdUnmark: 
		{
			TInt currentItem = _container->getCurrentListBoxItem();
			if (currentItem != -1)
				_container->cmdMark(currentItem, false);
			break;
		}
		case EAknUnmarkAll:
			_container->cmdMark(-1, false);
			break;
        case EListBoxCmdToggleNotifications:
            _container->cmdToggleNotifications();
            break;
		default:
			break;      
	}
}

⌨️ 快捷键说明

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