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


C++ BMenuItem::SetMarked方法代码示例

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


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

示例1: BPopUpMenu

BPopUpMenu*
TPrefsWindow::_BuildBoolMenu(uint32 what, const char* boolItem, bool isTrue)
{
    BMenuItem* item;
    BMessage* msg;
    BPopUpMenu* menu;

    menu = new BPopUpMenu("");
    msg = new BMessage(what);
    msg->AddBool(boolItem, true);
    menu->AddItem(item = new BMenuItem("On", msg));
    if (isTrue)
        item->SetMarked(true);

    msg = new BMessage(what);
    msg->AddInt32(boolItem, false);
    menu->AddItem(item = new BMenuItem("Off", msg));
    if (!isTrue)
        item->SetMarked(true);

    return menu;
}
开发者ID:mmadia,项目名称:haiku-1,代码行数:22,代码来源:Prefs.cpp

示例2: msg

status_t
ConfigWindow::_SetToGeneralSettings(BMailSettings *settings)
{
	if (!settings)
		return B_BAD_VALUE;

	status_t status = settings->InitCheck();
	if (status != B_OK)
		return status;

	// retrieval frequency

	time_t interval = time_t(settings->AutoCheckInterval() / 1e6L);
	char text[25];
	text[0] = 0;
	int timeIndex = 0;
	if (interval >= 60) {
		timeIndex = 1;
		sprintf(text, "%" B_PRIdTIME, interval / (60));
	}
	if (interval >= (60*60)) {
		timeIndex = 2;
		sprintf(text, "%" B_PRIdTIME, interval / (60*60));
	}
	if (interval >= (60*60*24)) {
		timeIndex = 3;
		sprintf(text, "%" B_PRIdTIME, interval / (60*60*24));
	}
	fIntervalControl->SetText(text);

	if (BMenuItem *item = fIntervalUnitField->Menu()->ItemAt(timeIndex))
		item->SetMarked(true);
	fIntervalControl->SetEnabled(timeIndex != 0);

	fPPPActiveCheckBox->SetValue(settings->CheckOnlyIfPPPUp());
	fPPPActiveSendCheckBox->SetValue(settings->SendOnlyIfPPPUp());

	fAutoStartCheckBox->SetValue(settings->DaemonAutoStarts());

	int32 showStatusIndex = settings->ShowStatusWindow();
	BMenuItem *item = fStatusModeField->Menu()->ItemAt(showStatusIndex);
	if (item) {
		item->SetMarked(true);
		// send live update to the server by simulating a menu click
		BMessage msg(kMsgShowStatusWindowChanged);
		msg.AddInt32("ShowStatusWindow", showStatusIndex);
		PostMessage(&msg);
	}

	return B_OK;
}
开发者ID:mylegacy,项目名称:haiku,代码行数:51,代码来源:ConfigWindow.cpp

示例3: dir

BPopUpMenu*
AutoConfigView::_SetupProtocolMenu()
{
	BPopUpMenu* menu = new BPopUpMenu(B_TRANSLATE("Choose Protocol"));

	// TODO: use path finder!
	for (int i = 0; i < 2; i++) {
		BPath path;
		status_t status = find_directory((i == 0) ? B_USER_ADDONS_DIRECTORY :
			B_BEOS_ADDONS_DIRECTORY, &path);
		if (status != B_OK)
			return menu;

		path.Append("mail_daemon");
		path.Append("inbound_protocols");

		BDirectory dir(path.Path());
		entry_ref protocolRef;
		while (dir.GetNextRef(&protocolRef) == B_OK)
		{
			BEntry entry(&protocolRef);

			BMessage* msg = new BMessage(kProtokollChangedMsg);
			BMenuItem* item = new BMenuItem(entry.Name(), msg);
			menu->AddItem(item);
			msg->AddRef("protocol", &protocolRef);

			item->SetMarked(true);
		}
	}

	// make imap default protocol if existing
	BMenuItem* imapItem =  menu->FindItem("IMAP");
	if (imapItem)
		imapItem->SetMarked(true);

	return menu;
}
开发者ID:AmirAbrams,项目名称:haiku,代码行数:38,代码来源:AutoConfigView.cpp

示例4: log

void
SettingsView::UpdateFromSettings()
{
	int32 value = int32(fSettings.ClickSpeed() / 1000);
		// slow = 1000000, fast = 0
	fClickSpeedSlider->SetValue(value);

	value = int32((log(fSettings.MouseSpeed() / 8192.0) / log(2)) * 1000 / 6);
		// slow = 8192, fast = 524287
	fMouseSpeedSlider->SetValue(value);

	value = int32(sqrt(fSettings.AccelerationFactor() / 16384.0) * 1000 / 4);
		// slow = 0, fast = 262144
	fAccelerationSlider->SetValue(value);

	BMenuItem* item = fTypeMenu->ItemAt(fSettings.MouseType() - 1);
	if (item != NULL)
		item->SetMarked(true);

	fMouseView->SetMouseType(fSettings.MouseType());

	item = fFocusMenu->ItemAt(mouse_mode_to_index(fSettings.MouseMode()));
	if (item != NULL)
		item->SetMarked(true);

	item = fFocusFollowsMouseMenu->ItemAt(
		focus_follows_mouse_mode_to_index(fSettings.FocusFollowsMouseMode()));
	if (item != NULL)
		item->SetMarked(true);

	fFocusFollowsMouseMenu->SetEnabled(fSettings.MouseMode()
		== B_FOCUS_FOLLOWS_MOUSE);

	fAcceptFirstClickBox->SetValue(fSettings.AcceptFirstClick()
		? B_CONTROL_ON : B_CONTROL_OFF);
	fAcceptFirstClickBox->SetEnabled(fSettings.MouseMode()
		!= B_FOCUS_FOLLOWS_MOUSE);
}
开发者ID:veer77,项目名称:Haiku-services-branch,代码行数:38,代码来源:SettingsView.cpp

示例5: UpdateFields

void CInfoDialog::UpdateFields()
{
	BMessage *msg = Looper()->CurrentMessage();

	const char *ff, *fs;
	if (msg->FindString("family", &ff) == B_NO_ERROR &&
		msg->FindString("style", &fs) == B_NO_ERROR)
	{
		BMenuItem *item;

		item = fMenu->FindMarked();
		if (item)
		{
			item = item->Submenu()->FindMarked();
			if (item) item->SetMarked(false);
			fMenu->FindMarked()->SetMarked(false);
		}

		item = fMenu->FindItem(ff);
		if (item)
		{
			item->SetMarked(true);
			item = item->Submenu()->FindItem(fs);
			if (item) item->SetMarked(true);
		}
	}

	if (strcmp(fTypes->FindMarked()->Label(), "undefined") == 0)
	{
		MWarningAlert a("Please choose a real mime type");
		a.Go();
	}

	SetEnabled("wrapfixedto", IsOn("wrapfixed"));

	SetEnabled("ok", true);
	SetEnabled("cancel", true);
} /* CInfoDialog::UpdateFields */
开发者ID:jscipione,项目名称:Paladin,代码行数:38,代码来源:CInfoDialog.cpp

示例6: BPopUpMenu

BPopUpMenu *TPrefsWindow::BuildSignatureMenu(char *sig)
{
	char			name[B_FILE_NAME_LENGTH];
	int32			index = 0;
	BEntry			entry;
	BFile			file;
	BMenuItem		*item;
	BMessage		*msg;
	BPopUpMenu		*menu;
	BQuery			query;
	BVolume			vol;
	BVolumeRoster	volume;

	menu = new BPopUpMenu("");
	msg = new BMessage(P_SIG);
	menu->AddItem(item = new BMenuItem(SIG_NONE, msg));
	if (!strcmp(sig, SIG_NONE))
		item->SetMarked(true);
	menu->AddSeparatorItem();

	volume.GetBootVolume(&vol);
	query.SetVolume(&vol);
	query.SetPredicate("_signature = *");
	query.Fetch();

	while (query.GetNextEntry(&entry) == B_NO_ERROR) {
		file.SetTo(&entry, O_RDONLY);
		if (file.InitCheck() == B_NO_ERROR) {
			msg = new BMessage(P_SIG);
			file.ReadAttr("_signature", B_STRING_TYPE, 0, name, sizeof(name));
			msg->AddString("signature", name);
			menu->AddItem(item = new BMenuItem(name, msg));
			if (!strcmp(sig, name))
				item->SetMarked(true);
		}
	}
	return menu;
}
开发者ID:ErisBlastar,项目名称:wordservices,代码行数:38,代码来源:Prefs.cpp

示例7:

void
AppWindowPrefsView::SetEncodingItem(int32 encoding)
{
	BMenuItem *item (NULL);
	for (int32 i = 0; i < fEncodings->Menu()->CountItems(); i++)
	{
		item = fEncodings->Menu()->ItemAt(i);
		if (item->Message()->FindInt32("encoding") == encoding)
		{
			item->SetMarked(true);
			break;
		}
	}
}
开发者ID:jessicah,项目名称:Vision,代码行数:14,代码来源:PrefApp.cpp

示例8: file

status_t
DisplayView::Load()
{
	BPath path;

	if (find_directory(B_USER_SETTINGS_DIRECTORY, &path) != B_OK)
		return B_ERROR;

	path.Append(kSettingsDirectory);

	if (create_directory(path.Path(), 0755) != B_OK) {
		BAlert* alert = new BAlert("",
			B_TRANSLATE("There was a problem saving the preferences.\n"
				"It's possible you don't have write access to the "
				"settings directory."), B_TRANSLATE("OK"), NULL, NULL,
			B_WIDTH_AS_USUAL, B_STOP_ALERT);
		alert->SetFlags(alert->Flags() | B_CLOSE_ON_ESCAPE);
		(void)alert->Go();
	}

	path.Append(kDisplaySettings);

	BFile file(path.Path(), B_READ_ONLY);
	BMessage settings;
	settings.Unflatten(&file);

	char buffer[255];
	int32 setting;
	BMenuItem* item = NULL;

	float width;
	if (settings.FindFloat(kWidthName, &width) != B_OK)
		width = kDefaultWidth;
	(void)sprintf(buffer, "%.2f", width);
	fWindowWidth->SetText(buffer);

	icon_size iconSize;
	if (settings.FindInt32(kIconSizeName, &setting) != B_OK)
		iconSize = kDefaultIconSize;
	else
		iconSize = (icon_size)setting;
	if (iconSize == B_MINI_ICON)
		item = fIconSize->ItemAt(0);
	else
		item = fIconSize->ItemAt(1);
	if (item)
		item->SetMarked(true);

	return B_OK;
}
开发者ID:Barrett17,项目名称:haiku-contacts-kit-old,代码行数:50,代码来源:DisplayView.cpp

示例9: SetFont

void ArpFontControl::SetFont(const ArpFont& font)
{
	if (!mFontCtrl || !mSizeCtrl) return;
	mSizeCtrl->SetValue(int32(font.Size()));
	BMenu*		m = mFontCtrl->Menu();
	if (!m) return;
	BString16	family = font.Family();
	BMenuItem*	item;
	for (int32 k = 0; (item = m->ItemAt(k)) != 0; k++) {
		if (family == item->Label()) {
			item->SetMarked(true);
		}
	}
}
开发者ID:HaikuArchives,项目名称:Sequitur,代码行数:14,代码来源:ArpFontControl.cpp

示例10: sizeof

void
AppearancePrefView::_MarkSelectedFont(const char* family, const char* style,
	const char* size)
{
	char fontMenuLabel[134];
	snprintf(fontMenuLabel, sizeof(fontMenuLabel), "%s - %s", family, style);

	// mark the selected font
	BMenuItem* selectedFont = fFontField->Menu()->FindItem(fontMenuLabel);
	if (selectedFont != NULL)
		selectedFont->SetMarked(true);

	// mark the selected font size on all font menus
	for (int32 i = 0; i < fFontField->Menu()->CountItems(); i++) {
		BMenu* fontSizeMenu = fFontField->Menu()->SubmenuAt(i);
		if (fontSizeMenu == NULL)
			continue;

		BMenuItem* item = fontSizeMenu->FindItem(size);
		if (item != NULL)
			item->SetMarked(true);
	}
}
开发者ID:sahil9912,项目名称:haiku,代码行数:23,代码来源:AppearPrefView.cpp

示例11: add_device_menu_items

static void add_device_menu_items(BMenu* menu)
{
	if (!menu) return;
	BString		markedLabel;
	BMenuItem*	item = menu->FindMarked();
	if (item) markedLabel = item->Label();
	menu->RemoveItems(0, menu->CountItems(), true);
	
	AmDeviceRoster*				roster = AmDeviceRoster::Default();
	if (roster) {
		vector<BMenuItem*>		items;
		BString					mfg, name, key;
		bool					isValid;
		for (uint32 k = 0; roster->GetDeviceInfo(k, mfg, name, key, NULL, &isValid) == B_OK; k++) {
			if (isValid) {
				BString			label = AmDeviceI::MakeLabel(mfg, name);
				BMessage*		msg = new BMessage(DEVICE_MSG);
				if (msg) {
					if (mfg.Length() > 0) msg->AddString(DEV_MFG_STR, mfg);
					if (name.Length() > 0) msg->AddString(DEV_NAME_STR, name);

					item = new BMenuItem(label.String(), msg);
					if (item) items.push_back(item);
				}
			}
		}
		sort(items.begin(), items.end(), sort_items);
		for (uint32 k = 0; k < items.size(); k++) menu->AddItem(items[k]);
		items.resize(0);
	}
	/* Set the marked to whatever it previously was.  It's important to try
	 * to find the marked BEFORE adding the separator item -- otherwise, if
	 * there is no marked label, it will find the separator item.
	 */
	BMenuItem*	marked = menu->FindItem(markedLabel.String() );

	if (menu->CountItems() > 0) menu->AddSeparatorItem();
	BMenuItem*	noneItem = new BMenuItem(NONE_STR, new BMessage(DEVICE_MSG));
	if (noneItem) menu->AddItem(noneItem);
	item = new BMenuItem(VARIOUS_STR, NULL);
	if (item) {
		menu->AddItem(item);
		item->SetEnabled(false);
	}
	/* Now set the actual marked item.
	 */
	if (!marked) marked = noneItem;
	if (!marked) marked = menu->ItemAt(0);
	if (marked) marked->SetMarked(true);
}
开发者ID:dtbinh,项目名称:Sequitur,代码行数:50,代码来源:SeqStudioWindow.cpp

示例12: showContextMenu

void MediaRoutingView::showContextMenu(
	BPoint point)
{
	D_METHOD(("MediaRoutingView::showContextMenu()\n"));

	BPopUpMenu *menu = new BPopUpMenu("MediaRoutingView PopUp", false, false, B_ITEMS_IN_COLUMN);
	menu->SetFont(be_plain_font);

	// add layout options
	BMenuItem *item;
	BMessage *message = new BMessage(M_LAYOUT_CHANGED);
	message->AddInt32("layout", M_ICON_VIEW);
	menu->AddItem(item = new BMenuItem("Icon View", message));
	if (m_layout == M_ICON_VIEW)
	{
		item->SetMarked(true);
	}
	message = new BMessage(M_LAYOUT_CHANGED);
	message->AddInt32("layout", M_MINI_ICON_VIEW);
	menu->AddItem(item = new BMenuItem("Mini Icon View", message));
	if (m_layout == M_MINI_ICON_VIEW)
	{
		item->SetMarked(true);
	}
	menu->AddSeparatorItem();

	// add 'CleanUp' command
	menu->AddItem(new BMenuItem("Clean Up", new BMessage(M_CLEANUP_REQUESTED), 'K'));

	// add 'Select All' command
	menu->AddItem(new BMenuItem("Select All", new BMessage(M_SELECT_ALL), 'A'));

	menu->SetTargetForItems(this);
	ConvertToScreen(&point);
	point -= BPoint(1.0, 1.0);
	menu->Go(point, true, true, true);
}
开发者ID:HaikuArchives,项目名称:Cortex,代码行数:37,代码来源:MediaRoutingView.cpp

示例13: MenusBeginning

void SeqStudioWindow::MenusBeginning()
{
	inherited::MenusBeginning();
	BMenuBar*			bar = KeyMenuBar();
	if (!bar) return;
	BColumnListView*	table = dynamic_cast<BColumnListView*>( FindView(ENDPOINT_LIST_STR) );
	if (!table) return;

	if (mDeviceCtrl && mDeviceCtrl->Menu() ) add_device_menu_items(mDeviceCtrl->Menu() );

	// MIDI Port menu
	if (mPortMenu) {
		bool				deleteEnabled = false;
		_EndpointRow*	r = dynamic_cast<_EndpointRow*>(table->CurrentSelection() );
		if (r && !r->mIsValid && r->mEndpoint.channel < 0) deleteEnabled = true;

		BMenuItem*			deleteItem = mPortMenu->FindItem(DELETE_STR);
		if (deleteItem && deleteItem->IsEnabled() != deleteEnabled) deleteItem->SetEnabled(deleteEnabled);
	}

	// Attributes menu
	BMenu*					menu;
	BMenuItem*				item;
	if ( (menu = bar->SubmenuAt(ATTRIBUTES_MENU_INDEX)) != NULL) {
		for (int32 k = 0; (item = menu->ItemAt(k)) != NULL; k++) {
			const char*		n;
			if (item->Message() && item->Message()->FindString(COLUMN_NAME_STR, &n) == B_OK) {
				BColumn*	col = column_named(n, table);
				if (col && col->IsVisible() ) {
					if (!item->IsMarked() ) item->SetMarked(true);
				} else {
					if (item->IsMarked() ) item->SetMarked(false);
				}
			}
		}
	}
}
开发者ID:dtbinh,项目名称:Sequitur,代码行数:37,代码来源:SeqStudioWindow.cpp

示例14: BPopUpMenu

void
GLObject::MenuInvoked(BPoint point)
{
	BPopUpMenu* m = new BPopUpMenu("Object",false,false);
	BMenuItem* i;

	int c = 1;
	m->AddItem(i = new BMenuItem("White",NULL));
	if (color == c++)
		i->SetMarked(true);
	m->AddItem(i = new BMenuItem("Yellow",NULL));
	if (color == c++)
		i->SetMarked(true);
	m->AddItem(i = new BMenuItem("Blue",NULL));
	if (color == c++)
		i->SetMarked(true);
	m->AddItem(i = new BMenuItem("Red",NULL));
	if (color == c++)
		i->SetMarked(true);
	m->AddItem(i = new BMenuItem("Green",NULL));
	if (color == c++)
		i->SetMarked(true);
	m->AddSeparatorItem();

	c = 0;
	m->AddItem(i = new BMenuItem("Solid",NULL));
	if (solidity == c++)
		i->SetMarked(true);
	m->AddItem(i = new BMenuItem("Translucent",NULL));
	if (solidity == c++)
		i->SetMarked(true);
	m->AddItem(i = new BMenuItem("Transparent",NULL));
	if (solidity == c++)
		i->SetMarked(true);

	i = m->Go(point);
	int32 index = m->IndexOf(i);
	delete m;
	
	if (index < 5) {
		color = index+1;
	} else if (index > 5) {
		solidity = index-6;
	}
	changed = true;
	setEvent(fObjView->drawEvent);
}
开发者ID:AmirAbrams,项目名称:haiku,代码行数:47,代码来源:GLObject.cpp

示例15: if

void
PPPoEView::ReloadInterfaces()
{
	// delete all items and request a new bunch from the pppoe kernel module
	BMenu *menu = fInterface->Menu();
	while(menu->CountItems() > 2)
		delete menu->RemoveItem((int32) 0);
	fOtherInterface->SetLabel(kLabelOtherInterface);
	
	PPPManager manager;
	char *interfaces = new char[8192];
		// reserve enough space for approximately 512 entries
	int32 count = manager.ControlModule("pppoe", PPPoE_GET_INTERFACES, interfaces,
		8192);
	
	BMenuItem *item;
	char *name = interfaces;
	int32 insertAt;
	for(int32 index = 0; index < count; index++) {
		item = new BMenuItem(name, new BMessage(kMsgSelectInterface));
		insertAt = FindNextMenuInsertionIndex(menu, name);
		if(insertAt > menu->CountItems() - 2)
			insertAt = menu->CountItems() - 2;
		
		item->SetTarget(this);
		menu->AddItem(item, insertAt);
		name += strlen(name) + 1;
	}
	
	// set interface or some default value if nothing was found
	if(Addon()->InterfaceName() && strlen(Addon()->InterfaceName()) > 0)
		fInterfaceName = Addon()->InterfaceName();
	else if(count > 0)
		fInterfaceName = interfaces;
	else
		fInterfaceName = "";
	
	delete interfaces;
	
	item = menu->FindItem(fInterfaceName.String());
	if(item && menu->IndexOf(item) <= menu->CountItems() - 2)
		item->SetMarked(true);
	else if(Addon()->InterfaceName()) {
		BString label(kLabelOtherInterface);
		label << " " << fInterfaceName;
		fOtherInterface->SetLabel(label.String());
		fOtherInterface->SetMarked(true);
	}
}
开发者ID:AmirAbrams,项目名称:haiku,代码行数:49,代码来源:PPPoEAddon.cpp


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