当前位置: 首页>>代码示例>>C++>>正文


C++ BMenu::ItemAt方法代码示例

本文整理汇总了C++中BMenu::ItemAt方法的典型用法代码示例。如果您正苦于以下问题:C++ BMenu::ItemAt方法的具体用法?C++ BMenu::ItemAt怎么用?C++ BMenu::ItemAt使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在BMenu的用法示例。


在下文中一共展示了BMenu::ItemAt方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: UpdateDirectoryPopup

void CFtpDialog::UpdateDirectoryPopup()
{
	BMenu* menu = fDirectoryField->Menu();
	BMenuItem *item;

	while ((item = menu->ItemAt(menu->CountItems() - 1)) != NULL)
	{
		menu->RemoveItem(item);
		delete item;
	}

	char p[PATH_MAX], *l;
	strcpy(p, fPath);

	l = strtok(p, "/");

	menu->AddItem(new BMenuItem("/", new BMessage(msg_SelectedDirectory)));

	while (l)
	{
		menu->AddItem(new BMenuItem(l, new BMessage(msg_SelectedDirectory)));
		l = strtok(NULL, "/");
	}

	menu->ItemAt(menu->CountItems() - 1)->SetMarked(true);
} // CFtpDialog::UpdateDirectoryPopup
开发者ID:pgellert,项目名称:Pe,代码行数:26,代码来源:CFtpDialog.cpp

示例2:

/***********************************************************
 * SetValue
 ***********************************************************/
void
HCriteriaView::SetValue(int32 attr,
						int32 operation,
						const char* attr_value,
						int32 operation2)
{
	BMenu *menu = fAttrMenu->Menu();
	BMenuItem *item;
	if(menu)
	{
		item = menu->ItemAt(attr);
		if(item) item->SetMarked(true);
	}
	menu = fOpMenu->Menu();
	if(menu)
	{
		item = menu->ItemAt(operation);
		if(item) item->SetMarked(true);
	}
	menu = fOp2Menu->Menu();
	if(menu)
	{
		item = menu->ItemAt(operation2);
		if(item) item->SetMarked(true);
	}
	
	fValue->SetText(attr_value);
}
开发者ID:HaikuArchives,项目名称:Scooby,代码行数:31,代码来源:HCriteriaView.cpp

示例3: BMessage

void
FilterView::AdoptModel(const Model& model)
{
	BMenu* repositoryMenu = fRepositoryField->Menu();
		repositoryMenu->RemoveItems(0, repositoryMenu->CountItems(), true);

	repositoryMenu->AddItem(new BMenuItem(B_TRANSLATE("All depots"),
		new BMessage(MSG_DEPOT_SELECTED)));
	repositoryMenu->ItemAt(0)->SetMarked(true);

	repositoryMenu->AddItem(new BSeparatorItem());

	const DepotList& depots = model.Depots();
	for (int i = 0; i < depots.CountItems(); i++) {
		const DepotInfo& depot = depots.ItemAtFast(i);
		BMessage* message = new BMessage(MSG_DEPOT_SELECTED);
		message->AddString("name", depot.Name());
		BMenuItem* item = new BMenuItem(depot.Name(), message);
		repositoryMenu->AddItem(item);
	}

	BMenu* showMenu = fShowField->Menu();
	showMenu->RemoveItems(0, showMenu->CountItems(), true);

	showMenu->AddItem(new BMenuItem(B_TRANSLATE("All categories"),
		new BMessage(MSG_CATEGORY_SELECTED)));

	showMenu->AddItem(new BSeparatorItem());

	add_categories_to_menu(model.Categories(), showMenu);

	showMenu->ItemAt(0)->SetMarked(true);

	AdoptCheckmarks(model);
}
开发者ID:,项目名称:,代码行数:35,代码来源:

示例4:

void
AttributeWindow::_CheckDisplayAs()
{
	// check display as suported types

	type_code currentType = _CurrentType();

	BMenu* menu = fDisplayAsMenuField->Menu();
	for (int32 i = menu->CountItems(); i-- > 0;) {
		BMenuItem* item = menu->ItemAt(i);
		bool supported = item == _DefaultDisplayAs();
			// the default type is always supported
		type_code type;
		for (int32 j = 0; item->Message()->FindInt32("supports",
				j, (int32*)&type) == B_OK; j++) {
			if (type == currentType) {
				supported = true;
				break;
			}
		}

		item->SetEnabled(supported);
		if (item->IsMarked() && !supported)
			menu->ItemAt(0)->SetMarked(true);
	}

	fSpecialControl->SetEnabled(!_DefaultDisplayAs()->IsMarked());
}
开发者ID:mmanley,项目名称:Antares,代码行数:28,代码来源:AttributeWindow.cpp

示例5: BMenu

Window::Window()
	:
	BWindow(BRect(100, 100, 620, 200), "Alert-Test", B_TITLED_WINDOW,
		B_ASYNCHRONOUS_CONTROLS | B_AUTO_UPDATE_SIZE_LIMITS)
{
	BMenu* sizeMenu = new BMenu("Button size");
	sizeMenu->SetLabelFromMarked(true);
	sizeMenu->SetRadioMode(true);
	sizeMenu->AddItem(new BMenuItem("As usual", NULL));
	sizeMenu->AddItem(new BMenuItem("From widest", NULL));
	sizeMenu->AddItem(new BMenuItem("From label", NULL));
	sizeMenu->ItemAt(0)->SetMarked(true);
	fSizeField = new BMenuField("Button size", sizeMenu);

	BMenu* typeMenu = new BMenu("Alert type");
	typeMenu->SetLabelFromMarked(true);
	typeMenu->SetRadioMode(true);
	typeMenu->AddItem(new BMenuItem("Empty", NULL));
	typeMenu->AddItem(new BMenuItem("Info", NULL));
	typeMenu->AddItem(new BMenuItem("Idea", NULL));
	typeMenu->AddItem(new BMenuItem("Warning", NULL));
	typeMenu->AddItem(new BMenuItem("Stop", NULL));
	typeMenu->ItemAt(0)->SetMarked(true);
	fTypeField = new BMenuField("Alert type", typeMenu);

	BMenu* spacingMenu = new BMenu("Button spacing");
	spacingMenu->SetLabelFromMarked(true);
	spacingMenu->SetRadioMode(true);
	spacingMenu->AddItem(new BMenuItem("Even", NULL));
	spacingMenu->AddItem(new BMenuItem("Offset", NULL));
	spacingMenu->ItemAt(0)->SetMarked(true);
	fSpacingField = new BMenuField("Button spacing", spacingMenu);

	fCountSlider = new BSlider("count", "Button count", NULL, 1, 3,
		B_HORIZONTAL);
	fCountSlider->SetValue(3);
	fCountSlider->SetLimitLabels("1", "3");
	fCountSlider->SetHashMarkCount(3);
	fCountSlider->SetHashMarks(B_HASH_MARKS_BOTTOM);

	fLastStringView = new BStringView("last pressed", "");
	fLastStringView->SetAlignment(B_ALIGN_CENTER);

	BButton* button = new BButton("Show alert", new BMessage(kMsgShowAlert));

	BLayoutBuilder::Group<>(this, B_VERTICAL)
		.Add(fSizeField)
		.Add(fTypeField)
		.Add(fSpacingField)
		.Add(fCountSlider)
		.AddGlue()
		.Add(fLastStringView)
		.Add(button)
		.SetInsets(B_USE_DEFAULT_SPACING);

	CenterOnScreen();
	SetFlags(Flags() | B_CLOSE_ON_ESCAPE);
}
开发者ID:SummerSnail2014,项目名称:haiku,代码行数:58,代码来源:SimpleAlertTest.cpp

示例6: BMessage

void
FilterView::AdoptModel(const Model& model)
{
	// Adopt depots
	BMenu* repositoryMenu = fRepositoryField->Menu();
		repositoryMenu->RemoveItems(0, repositoryMenu->CountItems(), true);

	repositoryMenu->AddItem(new BMenuItem(B_TRANSLATE("All depots"),
		new BMessage(MSG_DEPOT_SELECTED)));

	repositoryMenu->AddItem(new BSeparatorItem());

	bool foundSelectedDepot = false;
	const DepotList& depots = model.Depots();
	for (int i = 0; i < depots.CountItems(); i++) {
		const DepotInfo& depot = depots.ItemAtFast(i);
		BMessage* message = new BMessage(MSG_DEPOT_SELECTED);
		message->AddString("name", depot.Name());
		BMenuItem* item = new BMenuItem(depot.Name(), message);
		repositoryMenu->AddItem(item);

		if (depot.Name() == model.Depot()) {
			item->SetMarked(true);
			foundSelectedDepot = true;
		}
	}

	if (!foundSelectedDepot)
		repositoryMenu->ItemAt(0)->SetMarked(true);

	// Adopt categories
	BMenu* showMenu = fShowField->Menu();
	showMenu->RemoveItems(0, showMenu->CountItems(), true);

	showMenu->AddItem(new BMenuItem(B_TRANSLATE("All categories"),
		new BMessage(MSG_CATEGORY_SELECTED)));

	showMenu->AddItem(new BSeparatorItem());

	add_categories_to_menu(model.Categories(), showMenu);

	bool foundSelectedCategory = false;
	for (int32 i = 0; i < showMenu->CountItems(); i++) {
		BMenuItem* item = showMenu->ItemAt(i);
		BMessage* message = item->Message();
		if (message == NULL)
			continue;
		BString category;
		if (message->FindString("name", &category) == B_OK
			&& model.Category() == category) {
			item->SetMarked(true);
			foundSelectedCategory = true;
			break;
		}
	}
	if (!foundSelectedCategory)
		showMenu->ItemAt(0)->SetMarked(true);
}
开发者ID:AmirAbrams,项目名称:haiku,代码行数:58,代码来源:FilterView.cpp

示例7: Bounds

/***********************************************************
 * InitGUI
 ***********************************************************/
void
HCriteriaView::InitGUI()
{
	BRect rect = Bounds();
	rect.left += 5;
	rect.top += 2;
	rect.right = rect.left + 80;
	BMenu *menu = new BMenu("menu");
	menu->AddItem(new BMenuItem(_("Subject"),NULL));
	menu->AddItem(new BMenuItem(_("To"),NULL));
	menu->AddItem(new BMenuItem(_("From"),NULL));
	menu->AddItem(new BMenuItem(_("Cc"),NULL));
	menu->AddItem(new BMenuItem(_("Reply-To"),NULL));
	menu->AddItem(new BMenuItem(_("Account"),NULL));
	menu->ItemAt(0)->SetMarked(true);
	menu->SetRadioMode(true);
	menu->SetLabelFromMarked(true);
	fAttrMenu = new BMenuField(rect,"attr","",menu);
	fAttrMenu->SetDivider(0);
	AddChild(fAttrMenu);
	
	rect.OffsetBy(80,0);
	menu = new BMenu("menu");
	menu->AddItem(new BMenuItem(_("contains"),NULL));
	menu->AddItem(new BMenuItem(_("is"),NULL));
	menu->AddItem(new BMenuItem(_("begin with"),NULL));
	menu->AddItem(new BMenuItem(_("end with"),NULL));
	menu->ItemAt(0)->SetMarked(true);
	menu->SetRadioMode(true);
	menu->SetLabelFromMarked(true);
	fOpMenu = new BMenuField(rect,"op","",menu);
	fOpMenu->SetDivider(0);
	AddChild(fOpMenu);
	
	rect.OffsetBy(80,2);
	rect.right= Bounds().right - 70;
	fValue = new BTextControl(rect,"value","","",NULL);
	fValue->SetDivider(0);
	AddChild(fValue);
	
	rect.right = Bounds().right - 5;
	rect.left = Bounds().right - 65;
	menu = new BMenu("operator");
	menu->AddItem(new BMenuItem(_("and"),NULL));
	menu->AddItem(new BMenuItem(_("or"),NULL));
	menu->ItemAt(0)->SetMarked(true);
	menu->SetRadioMode(true);
	menu->SetLabelFromMarked(true);
	fOp2Menu= new BMenuField(rect,"op2","",menu);
	fOp2Menu->SetDivider(0);
	AddChild(fOp2Menu);
}
开发者ID:HaikuArchives,项目名称:Scooby,代码行数:55,代码来源:HCriteriaView.cpp

示例8: FileFormatMenuItem

void
MediaConverterWindow::BuildFormatMenu()
{
	BMenu* menu = fFormatMenu->Menu();
	BMenuItem* item;

	// clear out old format menu items
	while ((item = menu->RemoveItem((int32)0)) != NULL)
		delete item;

	// add menu items for each file format
	media_file_format mfi;
	int32 cookie = 0;
	FileFormatMenuItem* ff_item;
	while (get_next_file_format(&cookie, &mfi) == B_OK) {
		if ((mfi.capabilities & media_file_format::B_WRITABLE) == 0)
			continue;
		ff_item = new FileFormatMenuItem(&mfi);
		menu->AddItem(ff_item);
	}

	// mark first item
	item = menu->ItemAt(0);
	if (item != NULL) {
		item->SetMarked(true);
		((BInvoker*)item)->Invoke();
	}
}
开发者ID:MaddTheSane,项目名称:haiku,代码行数:28,代码来源:MediaConverterWindow.cpp

示例9:

/*! \brief Set the control's value.
	\param value The new value of the control.
	Selects the option which has the given value.
*/
void
BOptionPopUp::SetValue(int32 value)
{
	BControl::SetValue(value);
	BMenu *menu = fMenuField->Menu();
	if (menu == NULL)
		return;

	int32 numItems = menu->CountItems();
	for (int32 i = 0; i < numItems; i++) {
		BMenuItem *item = menu->ItemAt(i);
		if (item && item->Message()) {
			int32 itemValue;
			item->Message()->FindInt32("be:value", &itemValue);
			if (itemValue == value) {
				item->SetMarked(true);

#if BEHAVE_LIKE_R5
				item->SetMarked(false);
#endif

				break;
			}
		}
	}
}
开发者ID:mmanley,项目名称:Antares,代码行数:30,代码来源:OptionPopUp.cpp

示例10: r

S9xRefreshWindow::S9xRefreshWindow(BRect rect, BWindow *parent, uint32 closemsg)
	: BWindow(rect, "FullScreen - Refresh Rate", B_FLOATING_WINDOW, B_NOT_ZOOMABLE | B_NOT_RESIZABLE),
	fWindow(parent),
	fS9xMsg(closemsg)
{
	display_mode *modes;
	uint32 mode_count;
	
	if(BScreen().GetModeList(&modes, &mode_count) == B_NO_ERROR) {
		BMenu *menu = new BMenu("menu");
		for(unsigned int i = 0; i < mode_count; i++) {
		//	if((modes[i].virtual_width == 640) && (modes[i].space == B_RGB16)) {
				BMessage *msg = new BMessage(ID_REFRESH);
				msg->AddPointer("refr_rate", (void *)&modes[i]);
				BString item_name;
				item_name << (modes[i].timing.pixel_clock * 1000)
					/ (modes[i].timing.h_total * modes[i].timing.v_total) << " Hz";
				menu->AddItem(new BMenuItem(item_name.String(), msg));
		//	}
		}
		BRect r(20, 20, 200, 60);
		BMenuField *field = new BMenuField(r, "field", "Refresh Rate:", menu);
		AddChild(field);
		menu->SetLabelFromMarked(true);
		menu->ItemAt(0)->SetMarked(true);
		menu->SetTargetForItems(fWindow);
	}
	Show();
}
开发者ID:ModeenF,项目名称:snes9x_haiku,代码行数:29,代码来源:S9xRefreshWindow.cpp

示例11: BWindow

Tearoff::Tearoff(BRect frame, const char *name, MainWindow *parent, MenuName menu_name, int idx)
	: BWindow(frame, name, B_FLOATING_WINDOW, B_NOT_RESIZABLE | B_NOT_ZOOMABLE, 0)
{
	int y = 0;
	BFont font;
	BMenu *menu;
	
	this->parent = parent;
	menu = parent->GetMenu(menu_name);
	menu->GetFont(&font);
	for(int i = 1; i < menu->CountItems(); i++) {
		BMenuItem *item = menu->ItemAt(i);
		if(item->Message()) {
			BButton *b = new BButton(BRect(0, y, frame.IntegerWidth(), y + TEAROFF_BUTTON_HEIGHT), "", item->Label(), new BMessage(item->Message()->what), B_FOLLOW_LEFT | B_FOLLOW_TOP, B_WILL_DRAW); 
			font.SetSize(TEAROFF_FONT_SIZE);
			b->SetFont(&font);
			AddChild(b);
			y = y + TEAROFF_BUTTON_HEIGHT;
		}
	}
	this->ResizeTo(frame.IntegerWidth(), y);
	this->SetTitle(menu->Name());
	this->index = idx;
	delete menu;
}
开发者ID:brennanos,项目名称:XFile-Haiku,代码行数:25,代码来源:Tearoff.cpp

示例12: english

BMenuItem*
BootPromptWindow::_KeymapItemForLanguage(BLanguage& language) const
{
	BLanguage english("en");
	BString name;
	if (language.GetName(name, &english) != B_OK)
		return fDefaultKeymapItem;

	// Check special mappings first
	for (size_t i = 0; i < kLanguageKeymapMappingsSize; i += 2) {
		if (!strcmp(name, kLanguageKeymapMappings[i])) {
			name = kLanguageKeymapMappings[i + 1];
			break;
		}
	}

	BMenu* menu = fKeymapsMenuField->Menu();
	for (int32 i = 0; i < menu->CountItems(); i++) {
		BMenuItem* item = menu->ItemAt(i);
		BMessage* message = item->Message();

		entry_ref ref;
		if (message->FindRef("ref", &ref) == B_OK
			&& name == ref.name)
			return item;
	}

	return fDefaultKeymapItem;
}
开发者ID:,项目名称:,代码行数:29,代码来源:

示例13: SetEvent

void AmProgramChangeView::SetEvent(AmPhraseEvent* container, AmProgramChange* pc)
{
	ArpASSERT(container && pc);
	mContainer = container;
	bool		updateAll = false;
	if (mProgramChange != pc) updateAll = true;
	mProgramChange = pc;
	if (updateAll || mCachedBankNumber != int32(BankNumber()) )
		SetTrackRef(mTrackRef);
	if (updateAll || mCachedProgramNumber != int32(mProgramChange->ProgramNumber()) ) {
		BMenu*		m = Menu();
		if (m) {
			int32		count = m->CountItems();
			for( int32 k = 0; k < count; k++ ) {
				BMenuItem*	item = m->ItemAt( k );
				if (item) {
					if( pc && k == pc->ProgramNumber() ) item->SetMarked( true );
					else item->SetMarked(false);
				}
			}
		}
	}
	mCachedProgramNumber = mProgramChange->ProgramNumber();
	mCachedBankNumber = BankNumber();
}
开发者ID:HaikuArchives,项目名称:Sequitur,代码行数:25,代码来源:AmEventControls.cpp

示例14: UpdatePopUpPriorityMenu

void TeamListView::UpdatePopUpPriorityMenu()
{
	BMenuField *Priority = (BMenuField *)slayer->mainWindow->FindView("MainPriorityField");
	BMenu *menu = Priority->Menu();
	BMenuItem *item;
	int32 i;
	for (i = 2; (item = menu->ItemAt(i)); i++) {
		priorityMenu->ItemAt(i-2)->SetMarked(item->IsMarked());
		priorityMenu->ItemAt(i-2)->SetEnabled(item->IsEnabled());
	}
}
开发者ID:diversys,项目名称:Slayer,代码行数:11,代码来源:TeamListView.cpp

示例15: MenuStringForControl

BString AmControlChangeInfoView::MenuStringForControl(uint32 control) const
{
	if (control > 127) return BString("?");
	BMenu*		menu = ControlMenu();
	if (!menu) return BString( am_control_name(control) );

	BMenuItem*	item;
	for (int32 index = 0; (item = menu->ItemAt( index )); index++) {
		if (index == (int32)control) return BString( item->Label() );
	}
	return BString( am_control_name(control) );
}
开发者ID:tgkokk,项目名称:Sequitur,代码行数:12,代码来源:AmControlChangeView.cpp


注:本文中的BMenu::ItemAt方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。