本文整理汇总了C++中Menu::CountItems方法的典型用法代码示例。如果您正苦于以下问题:C++ Menu::CountItems方法的具体用法?C++ Menu::CountItems怎么用?C++ Menu::CountItems使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Menu
的用法示例。
在下文中一共展示了Menu::CountItems方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: new
static void
add_boot_volume_item(Menu* menu, Directory* volume, const char* name)
{
BReference<PackageVolumeInfo> volumeInfo;
PackageVolumeState* selectedState = NULL;
if (volume == sBootVolume->RootDirectory()) {
volumeInfo.SetTo(sBootVolume->GetPackageVolumeInfo());
selectedState = sBootVolume->GetPackageVolumeState();
} else {
volumeInfo.SetTo(new(std::nothrow) PackageVolumeInfo);
if (volumeInfo->SetTo(volume, "system/packages") == B_OK)
selectedState = volumeInfo->States().Head();
else
volumeInfo.Unset();
}
BootVolumeMenuItem* item = new(nothrow) BootVolumeMenuItem(name);
menu->AddItem(item);
Menu* subMenu = NULL;
if (volumeInfo != NULL) {
subMenu = new(std::nothrow) Menu(CHOICE_MENU, "Select Haiku version");
for (PackageVolumeStateList::ConstIterator it
= volumeInfo->States().GetIterator();
PackageVolumeState* state = it.Next();) {
PackageVolumeStateMenuItem* stateItem
= new(nothrow) PackageVolumeStateMenuItem(state->DisplayName(),
volumeInfo, state);
subMenu->AddItem(stateItem);
stateItem->SetTarget(user_menu_boot_volume_state);
stateItem->SetData(volume);
if (state == selectedState) {
stateItem->SetMarked(true);
stateItem->Select(true);
item->UpdateStateName(stateItem->VolumeState());
}
}
}
if (subMenu != NULL && subMenu->CountItems() > 1) {
item->SetSubmenu(subMenu);
} else {
delete subMenu;
item->SetTarget(user_menu_boot_volume);
item->SetData(volume);
}
if (volume == sBootVolume->RootDirectory()) {
item->SetMarked(true);
item->Select(true);
}
}
示例2:
static bool
user_menu_boot_volume(Menu *menu, MenuItem *item)
{
Menu *super = menu->Supermenu();
if (super == NULL) {
// huh?
return true;
}
MenuItem *bootItem = super->ItemAt(super->CountItems() - 1);
bootItem->SetEnabled(true);
bootItem->Select(true);
bootItem->SetData(item->Data());
gKernelArgs.boot_volume.SetBool(BOOT_VOLUME_USER_SELECTED, true);
return true;
}