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

📄 listboxcontainer.cpp

📁 这是一个学习Symbian的ListBox的好例子,我也是看学个学会的
💻 CPP
📖 第 1 页 / 共 2 页
字号:
			TBuf<16> itemName;
			itemName.Format(KListBoxItemTextFormat, itemCount + 1);
			item.Format(f, 0, &itemName, 1);
		}
		break;
		case eDouble:  // CAknDoubleStyleListBox, "\t<label1>\t<label2>\t"
		{
			TBuf<16> labelA;
			labelA.Format(KListBoxLabelFormat, itemCount + 1, TChar('a'));
			TBuf<16> labelB;
			labelB.Format(KListBoxLabelFormat, itemCount + 1, TChar('b'));
			item.Format(f, &labelA, &labelB);
		}
		break;
		case eDouble2:	// CAknDoubleStyle2ListBox, "\t<long label1>\t\t<icon idx>"
		{
			TBuf<16> label;
			label.Format(KListBoxLabelFormat, itemCount + 1, TChar(' '));
			item.Format(f, &label, 0);
		}
		break;
		case eDoubleNumber:	// CAknDoubleNumberStyleListBox, "<number>\t<label1>\t<label2>\t<icon idx>"
		{
			TBuf<16> labelA;
			labelA.Format(KListBoxLabelFormat, itemCount + 1, TChar('a'));
			TBuf<16> labelB;
			labelB.Format(KListBoxLabelFormat, itemCount + 1, TChar('b'));
			item.Format(f, itemCount+1, &labelA, &labelB, 0);
		}
		break;
		case eDoubleTime:	// CAknDoubleTimeStyleListBox, undocumented, "\t\t%S\t"
		{
			TUint counter1 = 1000;
			TUint counter2 = 10;
			TBuf<16> labelA;
			labelA.Format(KListBoxLabelFormat, itemCount + 1, TChar('a'));
			TBuf<16> labelB;
			labelB.Format(KListBoxLabelFormat, itemCount + 1, TChar('b'));
			item.Format(f, counter1 + itemCount + 1, counter2 + itemCount + 1, &labelA, &labelB);
		}
		break;
		case eDoubleLarge:	// CAknDoubleLargeStyleListBox, "<thumbnail icon idx>\t<label1>\t<label2>\t<small icon idx>"
		{
			TBuf<16> labelA;
			labelA.Format(KListBoxLabelFormat, itemCount + 1, TChar('a'));
			TBuf<16> labelB;
			labelB.Format(KListBoxLabelFormat, itemCount + 1, TChar('b'));
			item.Format(f, 4, &labelA, &labelB, 0);
		}
		break;
		case eDoubleGraphic:	// CAknDoubleGraphicStyleListBox, "<icon idx>\t<label1>\t<label2>\t<icon idx>"
		{
			TBuf<16> labelA;
			labelA.Format(KListBoxLabelFormat, itemCount + 1, TChar('a'));
			TBuf<16> labelB;
			labelB.Format(KListBoxLabelFormat, itemCount + 1, TChar('b'));
			item.Format(f, 0, &labelA, &labelB, 1);
		}
		break;
		case eFormDoubleGraphic:	// CAknFormDoubleGraphicStyleListBox, "\t<label1>\t<label2>\t<icon idx>"
		{
			TBuf<16> labelA;
			labelA.Format(KListBoxLabelFormat, itemCount + 1, TChar('a'));
			TBuf<16> labelB;
			labelB.Format(KListBoxLabelFormat, itemCount + 1, TChar('b'));
			item.Format(f, 0, &labelA, &labelB, 1);
		}
		break;
		case eFormDouble:	// CAknFormDoubleStyleListBox, "\t<label1>\t<label2>\t<icon idx>"
		{
			TBuf<16> labelA;
			labelA.Format(KListBoxLabelFormat, itemCount + 1, TChar('a'));
			TBuf<16> labelB;
			labelB.Format(KListBoxLabelFormat, itemCount + 1, TChar('b'));
			item.Format(f, &labelA, &labelB, 0);
		}
		break;
		case eSetting1: // CAknSettingStyleListBox, "\t<label>\t\t<value>"
		{
			TBuf<16> label;
			label.Format(KListBoxLabelFormat, itemCount + 1, TChar(' '));
			TBuf<16> value;
			value.Format(KListBoxValueFormat, itemCount + 1);
			item.Format(f, &label, &value);
		}
		break;
		case eSetting2: // CAknSettingStyleListBox, "\t<label>\t<icon idx>\t"
		{
			TBuf<16> label;
			label.Format(KListBoxLabelFormat, itemCount + 1, TChar(' '));
			item.Format(f, &label, 0);
		}
		break;
		case eSetting3: // CAknSettingStyleListBox, "\t<label1>\t\t<value>\t*"
		{
			TBuf<16> label;
			label.Format(KListBoxLabelFormat, itemCount + 1, TChar(' '));
			TBuf<16> value;
			value.Format(KListBoxValueFormat, itemCount + 1);
			item.Format(f, &label, &value, itemCount+1);
		}
		break;
		case eSetting4: // CAknSettingStyleListBox, "\t<label1>\t\t\t\t<label2>"
		{
			TBuf<16> labelA;
			labelA.Format(KListBoxLabelFormat, itemCount + 1, TChar('a'));
			TBuf<16> labelB;
			labelB.Format(KListBoxLabelFormat, itemCount + 1, TChar('b'));
			item.Format(f, &labelA, 0, &labelB);
		}
		break;
		case eSettingNumber: // CAknSettingNumberStyleListBox, "<number>\t<label1>\t\t<value>", supports 4 formats (like eSetting)
		{
			TBuf<16> label;
			label.Format(KListBoxLabelFormat, itemCount + 1, TChar(' '));
			TBuf<16> value;
			value.Format(KListBoxValueFormat, itemCount + 1);
			item.Format(f, itemCount+1, &label, &value);
		}
		break;
		case eSinglePopupMenu: // CAknSinglePopupMenuStyleListBox, "<item text>\t<icon idx>"
		{
			TBuf<16> label;
			label.Format(KListBoxLabelFormat, itemCount + 1, TChar(' '));
			item.Format(f, &label, 0);
		}
		break;
		case eSingleGraphicPopupMenu: // CAknSingleGraphicPopupMenuStyleListBox, "<icon idx\t<item text>"
		{
			TBuf<16> label;
			label.Format(KListBoxLabelFormat, itemCount + 1, TChar(' '));
			item.Format(f, 0, &label);
		}
		break;
		case eSingleGraphicBtPopupMenu: // CAknSingleGraphicBtPopupMenuStyleListBox, "<icon idx>\t<item text>"
		{
			TBuf<16> label;
			label.Format(KListBoxLabelFormat, itemCount + 1, TChar(' '));
			item.Format(f, 0, &label);
		}
		break;
		case eSingleHeadingPopupMenu: // CAknSingleHeadingPopupMenuStyleListBox, "<heading>\t<label>"
		{
			TBuf<16> heading;
			heading.Format(KListBoxHeadingFormat, itemCount + 1);
			TBuf<16> itemName;
			itemName.Format(KListBoxItemTextFormat, itemCount + 1);
			item.Format(f, &heading, &itemName);
		}
		break;
		case eSingleGraphicHeadingPopupMenu: // CAknSingleGraphicHeadingPopupMenuStyleListBox, "<icon idx>\t<heading>\t<label>"
		{
			TBuf<16> heading;
			heading.Format(KListBoxHeadingFormat, itemCount + 1);
			TBuf<16> itemName;
			itemName.Format(KListBoxItemTextFormat, itemCount + 1);
			item.Format(f, 0, &heading, &itemName);
		}
		break;
		case eDoublePopupMenu: // CAknDoublePopupMenuStyleListBox, "<label1>\t<label2>"
		{
			TBuf<16> labelA;
			labelA.Format(KListBoxLabelFormat, itemCount + 1, TChar('a'));
			TBuf<16> labelB;
			labelB.Format(KListBoxLabelFormat, itemCount + 1, TChar('b'));
			item.Format(f, &labelA, &labelB);
		}
		break;
		case eDoubleLargeGraphicPopupMenu: // CAknDoubleLargeGraphicPopupMenuStyleListBox, "<icon idx>\t<label1>\t<label2>"
		{
			TBuf<16> labelA;
			labelA.Format(KListBoxLabelFormat, itemCount + 1, TChar('a'));
			TBuf<16> labelB;
			labelB.Format(KListBoxLabelFormat, itemCount + 1, TChar('b'));
			item.Format(f, 0, &labelA, &labelB);
		}
		break;
		case eSet1: // CAknSetStyleListBox, "<icond idx>\t<short label>"
		{
			TBuf<16> label;
			label.Format(KListBoxLabelFormat, itemCount + 1, TChar(' '));
			item.Format(f, 0, &label);
		}
		break;
		case eSet2: // CAknSetStyleListBox, "\t\t<long label>"
		{
			TBuf<16> label;
			label.Format(KListBoxLabelFormat, itemCount + 1, TChar(' '));
			item.Format(f, &label);
		}
		break;
		case eFormGraphic1: // CAknFormGraphicStyleListBox, "<icon idx>\t"<short label>"
		{
			TBuf<16> label;
			label.Format(KListBoxLabelFormat, itemCount + 1, TChar(' '));
			item.Format(f, 0, &label);
		}
		break;
		case eFormGraphic2: // CAknFormGraphicStyleListBox, "\t\t<long label>"
		{
			TBuf<16> label;
			label.Format(KListBoxLabelFormat, itemCount + 1, TChar(' '));
			item.Format(f, &label);
		}
		break;
		case eFormGraphicWide1: // CAknFormGraphicWideStyleListBox, "<icon idx>\t"<short label>"
		{
			TBuf<16> label;
			label.Format(KListBoxLabelFormat, itemCount + 1, TChar(' '));
			item.Format(f, 0, &label);
		}
		break;
		case eFormGraphicWide2: // CAknFormGraphicWideStyleListBox, "\t\t<long label>"
		{
			TBuf<16> label;
			label.Format(KListBoxLabelFormat, itemCount + 1, TChar(' '));
			item.Format(f, &label);
		}
		break;
		default:
			__ASSERT_DEBUG(false, iEikonEnv->InfoMsg(_L("False")));
			return;
	}
	listBoxItems->AppendL(item);
}

void ListBoxContainer::getListBoxItemFormat(EAvkonListBoxType listBoxType, TDes& itemFormat) const
{
	switch (listBoxType)
	{
		case eSingle:	itemFormat = _L("\t%S\t\t"); return; // CAknSingleStyleListBox, "\t<item text>\t\t"
		case eSingleNumber:	itemFormat = _L("%d\t%S\t\t"); return; // CAknSingleNumberStyleListBox, "<number>\t<item text>\t\t"
		case eSingleHeading: itemFormat = _L("%S\t%S\t\t"); return; // CAknSingleHeadingStyleListBox, "<item heading>\t<item text>\t\t"
		case eSingleGraphic: itemFormat = _L("%d\t%S\t%d\t%d"); return; // CAknSingleGraphicStyleListBox, "<icon idx>\t<item text>\t<icon idx>\t<icon idx>"
		case eSingleGraphicHeading:	itemFormat = _L("%d\t%S\t%S\t%d\t%d"); return; // CAknSingleGraphicHeadingStyleListBox, "<icon idx>\t<item heading>\t<item text>\t<icon idx>\t<icon idx>"
		case eSingleNumberHeading:	itemFormat = _L("%d\t%S\t%S\t\t"); return; // CAknSingleNumberHeadingStyleListBox, "<number>\t<item heading>\t<item text>\t\t"; check if it supports icons!
		case eSingleLarge:	itemFormat = _L("%d\t%S\t%d"); return; // CAknSingleLargeStyleListBox, "<icon idx>\t<item text>\t<icon idx>";
		case eDouble: itemFormat = _L("\t%S\t%S\t"); return; // CAknDoubleStyleListBox, "\t<label1>\t<label2>\t"
		case eDouble2: itemFormat = _L("\t%S\t\t%d"); return; // CAknDoubleStyle2ListBox, "\t<long label1>\t\t<icon idx>"
		case eDoubleNumber:	itemFormat = _L("%d\t%S\t%S\t%d"); return; // CAknDoubleNumberStyleListBox, "<number>\t<label1>\t<label2>\t<icon idx>"
		case eDoubleTime: itemFormat = _L("%d\t%d\t%S\t%S"); return; // CAknDoubleTimeStyleListBox (undocumented)
		case eDoubleLarge: itemFormat = _L("%d\t%S\t%S\t%d"); return; // CAknDoubleLargeStyleListBox, "<thumbnail icon idx>\t<label1>\t<label2>\t<small icon idx>"
		case eDoubleGraphic: itemFormat = _L("%d\t%S\t%S\t%d"); return; // CAknDoubleGraphicStyleListBox, "<icon idx>\t<label1>\t<label2>\t<icon idx>"
		case eFormDoubleGraphic: itemFormat = _L("%d\t%S\t%S\t%d"); return; // CAknFormDoubleGraphicStyleListBox, "<icon idx>\t<label1>\t<label2>\t<icon idx>"
		case eFormDouble: itemFormat = _L("\t%S\t%S\t%d"); return; // CAknFormDoubleStyleListBox, "\t<label1>\t<label2>\t<icon idx>"
		case eSetting1: itemFormat = _L("\t%S\t\t%S"); return; // CAknSettingStyleListBox, "\t<label1>\t\t<value>",  
		case eSetting2: itemFormat = _L("\t%S\t%d\t"); return; // "\t<label1>\t<icon idx>\t",
		case eSetting3: itemFormat = _L("\t%S\t\t%S\t%d"); return; // "\t<label1>\t\t<value>\t<icon idx>", 
		case eSetting4: itemFormat = _L("\t%S\t%d\t\t\t%S"); return; // "\t<label1>\t<icon idx>\t\t\t<label2>"
		case eSettingNumber:	itemFormat = _L("%d\t%S\t\t%S"); return; // CAknSettingNumberStyleListBox, "<number>\t<label1>\t\t<value>", "<number>\t<label1>\t<icon idx>\t", // "<number>\t<label1>\t\t<value>\t*", "<number>\t<label1>\t\t\t\t<label2>" 
		case eSinglePopupMenu: itemFormat = _L("%S\t%d"); return; // CAknSinglePopupMenuStyleListBox, "<item text>\t<icon idx>"
		case eSingleGraphicPopupMenu: itemFormat = _L("%d\t%S"); return; // CAknSingleGraphicPopupMenuStyleListBox, "<icon idx\t<item text>"
		case eSingleGraphicBtPopupMenu:	itemFormat = _L("%d\t%S"); return; // CAknSingleGraphicBtPopupMenuStyleListBox, "<icon idx>\t<item text>"
		case eSingleHeadingPopupMenu: itemFormat = _L("%S\t%S"); return; // CAknSingleHeadingPopupMenuStyleListBox, "<heading>\t<label>"
		case eSingleGraphicHeadingPopupMenu: itemFormat = _L("%d\t%S\t%S"); return; // CAknSingleGraphicHeadingPopupMenuStyleListBox, "<icon idx>\t<heading>\t<label>"
		case eDoublePopupMenu: itemFormat = _L("%S\t%S"); return; // CAknDoublePopupMenuStyleListBox, "<label1>\t<label2>"
		case eDoubleLargeGraphicPopupMenu: itemFormat = _L("%d\t%S\t%S"); return; // CAknDoubleLargeGraphicPopupMenuStyleListBox, "<icon idx>\t<label1>\t<label2>"
		case eSet1: itemFormat = _L("%d\t%S"); return; // CAknSetStyleListBox, "<icond idx>\t<short label>"
		case eSet2: itemFormat = _L("\t\t%S"); return; // CAknSetStyleListBox, "\t\t<long label>"
		case eFormGraphic1: itemFormat = _L("%d\t%S"); return;	// CAknFormGraphicStyleListBox, "<icon idx>\t"<short label>"
		case eFormGraphic2: itemFormat = _L("\t\t%S"); return;	// CAknFormGraphicStyleListBox, "\t\t<long label>"
		case eFormGraphicWide1: itemFormat = _L("%d\t%S"); return; // CAknFormGraphicWideStyleListBox, "<icon idx>\t"<short label>"
		case eFormGraphicWide2: itemFormat = _L("\t\t%S"); return; // CAknFormGraphicWideStyleListBox, "\t\t<long label>"
		default:
			__ASSERT_DEBUG(false, iEikonEnv->InfoMsg(_L("False")));
			itemFormat = _L("ERROR");

	}
}

ListBoxContainer::EAvkonListBoxBaseType ListBoxContainer::getListBoxBaseType(EAvkonListBoxType type) const
{
	switch (type)
	{
		case eSingle:					
		case eSingleNumber:				
		case eSingleHeading:			
		case eSingleGraphic:			
		case eSingleGraphicHeading:		
		case eSingleNumberHeading:		
		case eSingleLarge:				
		case eDouble:					
			return eColumn;
		case eDouble2:
		case eDoubleNumber:
		case eDoubleTime:
		case eDoubleLarge:
		case eDoubleGraphic:
		case eFormDoubleGraphic:
		case eFormDouble:
		case eSetting1:
		case eSetting2:					
		case eSetting3:					
		case eSetting4:					
		case eSettingNumber:
		// popup styles
		case eSinglePopupMenu:
		case eSingleGraphicPopupMenu:
		case eSingleGraphicBtPopupMenu:
		case eSingleHeadingPopupMenu:
		case eSingleGraphicHeadingPopupMenu:
		case eDoublePopupMenu:
		case eDoubleLargeGraphicPopupMenu:
		case eSet1:
		case eSet2:
		case eFormGraphic1:
		case eFormGraphic2:
		case eFormGraphicWide1:
		case eFormGraphicWide2:
			return eFormattedCell;
		default:
			__ASSERT_DEBUG(false, iEikonEnv->InfoMsg(_L("False")));
			return eColumn;
	}
}

void ListBoxContainer::getListBoxTitle(EAvkonListBoxType listBoxType, TDes& title) const
{
	switch (listBoxType)
	{
		case eSingle:					title = _L("Single"); break;
		case eSingleNumber:				title = _L("SingleNumber"); break;
		case eSingleHeading:			title = _L("SingleHeading"); break;
		case eSingleGraphic:			title = _L("SingleGraphic"); break;
		case eSingleGraphicHeading:		title = _L("SingleGraphicHeading"); break;
		case eSingleNumberHeading:		title = _L("SingleNumberHeading"); break;
		case eSingleLarge:				title = _L("SingleLarge"); break;
		case eDouble:					title = _L("Double"); break;
		case eDouble2:					title = _L("Double2"); break;
		case eDoubleNumber:				title = _L("DoubleNumber"); break;
		case eDoubleTime:				title = _L("DoubleTime"); break;
		case eDoubleLarge:				title = _L("DoubleLarge"); break;
		case eDoubleGraphic:			title = _L("DoubleGraphic"); break;
		case eFormDoubleGraphic:		title = _L("FormDoubleGraphic"); break;
		case eFormDouble:				title = _L("FormDouble"); break;
		case eSetting1:					title = _L("Setting (1)"); break;
		case eSetting2:					title = _L("Setting (2)"); break;
		case eSetting3:					title = _L("Setting (3)"); break;
		case eSetting4:					title = _L("Setting (4)"); break;
		case eSettingNumber:			title = _L("SettingNumber"); break;
		// popup
		case eSinglePopupMenu:			title = _L("SinglePopupMenu"); break;
		case eSingleGraphicPopupMenu:	title = _L("SingleGraphicPopupMenu"); break;
		case eSingleGraphicBtPopupMenu:	title = _L("SingleGraphicBtPopupMenu"); break;
		case eSingleHeadingPopupMenu:	title = _L("SingleHeadingPopupMenu"); break;
		case eSingleGraphicHeadingPopupMenu:	title = _L("SingleGraphicHeadingPopupMenu"); break;
		case eDoublePopupMenu:			title = _L("DoublePopupMenu"); break;
		case eDoubleLargeGraphicPopupMenu:	title = _L("DoubleLargeGraphicPopupMenu"); break;
		case eSet1:						title = _L("Set (1)"); break;
		case eSet2:						title = _L("Set (2)"); break;
		case eFormGraphic1:				title = _L("FormGraphic (1)"); break;
		case eFormGraphic2:				title = _L("FormGraphic (2)"); break;
		case eFormGraphicWide1:			title = _L("FormGraphicWide (1)"); break;
		case eFormGraphicWide2:			title = _L("FormGraphicWide (2)"); break;
		default:
			__ASSERT_DEBUG(false, iEikonEnv->InfoMsg(_L("False")));
			title = _L("<no title>");
	}
}

⌨️ 快捷键说明

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