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


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

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


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

示例1:

void
VideoWindow::ToggleMenuOnOff()
{
	BMenuItem* item = fMenu->FindItem(msg_video);
	item->SetEnabled(!item->IsEnabled());

	item = fMenu->FindItem(msg_start);
	item->SetEnabled(!item->IsEnabled());

	item = fMenu->FindItem(msg_stop);
	item->SetEnabled(!item->IsEnabled());
}
开发者ID:AmirAbrams,项目名称:haiku,代码行数:12,代码来源:CodyCam.cpp

示例2: str

status_t
PMenuItem::GetProperty(const char *name, PValue *value, const int32 &index) const
{
	if (!name || !value)
		return B_ERROR;
	
	BString str(name);
	PProperty *prop = FindProperty(name,index);
	if (!prop)
		return B_NAME_NOT_FOUND;
	
	BMenuItem *backend = (BMenuItem*)fBackend;
	if (str.ICompare("Message") == 0)
		((IntProperty*)prop)->SetValue(backend->Command());
	else if (str.ICompare("Trigger") == 0)
		((CharProperty*)prop)->SetValue(backend->Trigger());
	else if (str.ICompare("Label") == 0)
		((StringProperty*)prop)->SetValue(backend->Label());
	else if (str.ICompare("Frame") == 0)
		((RectProperty*)prop)->SetValue(backend->Frame());
	else if (str.ICompare("Marked") == 0)
		((BoolProperty*)prop)->SetValue(backend->IsMarked());
	else if (str.ICompare("Enabled") == 0)
		((BoolProperty*)prop)->SetValue(backend->IsEnabled());
	else
	{
		return PObject::GetProperty(name, value, index);
	}

	return prop->GetValue(value);
}
开发者ID:HaikuArchives,项目名称:PDesigner,代码行数:31,代码来源:PMenuItem.cpp

示例3:

void
ShowImageWindow::_EnableMenuItem(BMenu *menu, uint32 what, bool enable)
{
	BMenuItem* item = menu->FindItem(what);
	if (item && item->IsEnabled() != enable)
		item->SetEnabled(enable);
}
开发者ID:mmanley,项目名称:Antares,代码行数:7,代码来源:ShowImageWindow.cpp

示例4: 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

示例5: 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

示例6: templatePath


//.........这里部分代码省略.........
	fTargetBox->ResizeToPreferred();
	r.bottom = r.top + fTargetBox->Bounds().Height();
	fTargetBox->ResizeTo(bounds.Width() - 20.0,r.Height());
	fTargetBox->SetDivider(divider);
	SetToolTip(fTargetBox, "The name of the compiled application or library");
	
	if (!BEntry(PROJECT_PATH).Exists())
		create_directory(PROJECT_PATH,0777);
	
	r.OffsetBy(0,r.Height() + 10);
	fPathBox = new PathBox(r,"pathbox",gProjectPath.GetFullPath(),TR("Location:"),
							B_FOLLOW_LEFT_RIGHT | B_FOLLOW_TOP);
	top->AddChild(fPathBox);
	fPathBox->ResizeToPreferred();
	r.bottom = r.top + fPathBox->Bounds().Height();
	fPathBox->ResizeTo(bounds.Width() - 20.0,r.Height());
	fPathBox->SetDivider(divider);
	SetToolTip(fPathBox, "Set the location for your project.");
	
	menu = new BMenu("SCM Chooser");
	menu->AddItem(new BMenuItem("Mercurial", new BMessage()));
	menu->AddItem(new BMenuItem("Git", new BMessage()));
	menu->AddItem(new BMenuItem("Subversion", new BMessage()));
	menu->AddItem(new BMenuItem("None", new BMessage()));
	
	if (!gHgAvailable)
	{
		menu->ItemAt(0)->SetEnabled(false);
		menu->ItemAt(0)->SetLabel("Mercurial Unavailable");
	}
	
	if (!gGitAvailable)
	{
		menu->ItemAt(1)->SetEnabled(false);
		menu->ItemAt(1)->SetLabel("Git Unavailable");
	}
	
	if (!gSvnAvailable)
	{
		menu->ItemAt(2)->SetEnabled(false);
		menu->ItemAt(2)->SetLabel("Subversion Unavailable");
	}
	
	
	r.OffsetBy(0,r.Height() + 5.0);
	fSCMChooser = new BMenuField(r, "scmchooser", "Source Control: ", menu);
	top->AddChild(fSCMChooser);
	fSCMChooser->SetDivider(divider);
	SetToolTip(fSCMChooser, "Choose the source control manager for your project, if any.");
	
	menu->SetLabelFromMarked(true);
	menu->ItemAt(gDefaultSCM)->SetMarked(true);
	
	BMenuItem *item = menu->FindMarked();
	if (!item->IsEnabled())
	{
		item->SetMarked(false);
		for (int32 i = 0; i < menu->CountItems(); i++)
		{
			if (menu->ItemAt(i)->IsEnabled())
			{
				menu->ItemAt(i)->SetMarked(true);
				break;
			}
		}
	}
	menu->SetLabelFromMarked(true);
	
	r.OffsetBy(0,r.Height() + 5.0);
	fCreateFolder = new BCheckBox(r,"createfolder",TR("Create Project Folder"),NULL);
	fCreateFolder->MoveTo(divider + 10.0, r.top);
	fCreateFolder->SetValue(B_CONTROL_ON);
	top->AddChild(fCreateFolder);
	SetToolTip(fCreateFolder, "If checked, a folder for your project will be created "
							"in the folder in the Location box above.");
	
	r.OffsetBy(0,r.Height() + 5.0);
	fOK = new BButton(r,"ok",TR("Create Project…"), new BMessage(M_CREATE_PROJECT));
	fOK->ResizeToPreferred();
	top->AddChild(fOK);
	fOK->SetEnabled(false);
	fOK->MakeDefault(true);
	
	float offset = fPathBox->Divider();
	fOK->MoveBy(offset,0);
	
	float minwidth = Bounds().Width();
	float minheight = fOK->Frame().bottom + 10.0;
	SetSizeLimits(minwidth,30000,minheight,30000);
	
	gSettings.Lock();
	BRect savedframe;
	if (gSettings.FindRect("template_frame",&savedframe) == B_OK)
		ResizeTo(savedframe.Width(),savedframe.Height());
	else
		ResizeTo(minwidth,minheight);
	gSettings.Unlock();
		
	fNameBox->MakeFocus(true);
}
开发者ID:passick,项目名称:Paladin,代码行数:101,代码来源:TemplateWindow.cpp

示例7: if

void
SCMImportWindow::SetProvider(SCMProjectImporter *importer)
{
	if (importer && !fProvider)
	{
		fSCMField->SetEnabled(true);
		fProjectBox->SetEnabled(true);
		fAnonymousBox->SetEnabled(true);
		fUserNameBox->SetEnabled(true);
		fRepository->SetEnabled(true);
		fCommandView->MakeEditable(false);
		fOK->SetEnabled(false);
		fProjectBox->MakeFocus(true);
		fProvider = importer;
		
		UpdateCommand();
	}
	else if (!importer && fProvider)
	{
		fSCMField->SetEnabled(false);
		fProjectBox->SetEnabled(false);
		fAnonymousBox->SetEnabled(false);
		fUserNameBox->SetEnabled(false);
		fRepository->SetEnabled(false);
		fCommandView->MakeEditable(true);
		fCommandView->SetText("");
		fCommandView->MakeFocus(true);
		fOK->SetEnabled(true);
	}
	
	fProvider = importer;
	if (fProvider)
	{
		BMenu *menu = fSCMField->Menu();
		BMenuItem *item;
		
		item = menu->FindItem("Mercurial");
		if (item)
			item->SetEnabled(fProvider->SupportsSCM(SCM_HG));
			
		item = menu->FindItem("Git");
		if (item)
			item->SetEnabled(fProvider->SupportsSCM(SCM_GIT));
		
		item = menu->FindItem("Subversion");
		if (item)
			item->SetEnabled(fProvider->SupportsSCM(SCM_SVN));
		
		item = menu->FindMarked();
		if (!item->IsEnabled())
		{
			item->SetMarked(false);
			for (int32 i = 0; i < menu->CountItems(); i++)
				if (menu->ItemAt(i)->IsEnabled())
				{
					menu->ItemAt(i)->SetMarked(true);
					break;
			}
		}
	}
	UpdateCommand();
}
开发者ID:jscipione,项目名称:Paladin,代码行数:62,代码来源:SCMImportWindow.cpp

示例8: TR


//.........这里部分代码省略.........

	fTabs[0] = BLayoutBuilder::Grid<>(B_USE_DEFAULT_SPACING, B_USE_SMALL_SPACING)
		.Add(new BStringView("projects folder label", TR("Projects folder:")), 0, 0)
		.Add(fProjectFolder, 1, 0)

		.AddGroup(B_VERTICAL, 0.0f, 1, 1)
			.Add(fShowProjectFolder)
			.Add(fDontAddHeaders)
			.End()

		.Add(buildBox, 1, 2)

		.Add(fAutoSyncModules, 1, 3)

		.Add(new BStringView("backups folder label", TR("Backups folder:")), 0, 4)
		.Add(fBackupFolder, 1, 4)

		.SetInsets(B_USE_DEFAULT_SPACING)
		.View();
	fTabs[0]->SetName(TR("General"));
	fTabs[0]->SetViewColor(ui_color(B_PANEL_BACKGROUND_COLOR));

#ifndef BUILD_CODE_LIBRARY
	fAutoSyncModules->Hide();
#endif

	// source control

	BPopUpMenu* scmMenu = new BPopUpMenu("SCM Chooser");
	scmMenu->AddItem(new BMenuItem(TR("None"), NULL));
	scmMenu->AddSeparatorItem();
	scmMenu->AddItem(new BMenuItem(TR("Git"), NULL));
	scmMenu->AddItem(new BMenuItem(TR("Mercurial"), NULL));
	scmMenu->AddItem(new BMenuItem(TR("Subversion"), NULL));

	fSCMChooser = new BMenuField("scmchooser", TR("Preferred source control:"),
		scmMenu);

#ifdef DISABLE_GIT_SUPPORT
	scmMenu->ItemAt(2)->SetEnabled(false);
#endif

	BMenuItem* marked = scmMenu->ItemAt(gDefaultSCM);
	if (marked != NULL)
		marked->SetMarked(true);
	else
		scmMenu->ItemAt(0)->SetMarked(true);

	if (!marked->IsEnabled()) {
		// if the default SCM is disabled unmark it and mark the first one that
		// is enabled.
		marked->SetMarked(false);
		for (int32 i = 0; i < scmMenu->CountItems(); i++) {
			if (scmMenu->ItemAt(i)->IsEnabled()) {
				scmMenu->ItemAt(i)->SetMarked(true);
				break;
			}
		}
	}

	fSVNRepoFolder = new PathBox("svnrepofolder", gSVNRepoPath.GetFullPath(), "");
	fSVNRepoFolder->MakeValidating(true);
	SetToolTip(fSVNRepoFolder, TR("Sets the location for the 'server' side of "
		"local Subversion repositories."));

	fTabs[1] = BLayoutBuilder::Group<>(B_VERTICAL)
		.AddGrid(B_USE_DEFAULT_SPACING, B_USE_SMALL_SPACING)
			.Add(fSCMChooser->CreateLabelLayoutItem(), 0, 0)
			.AddGroup(B_HORIZONTAL, B_USE_DEFAULT_SPACING, 1, 0)
				.Add(fSCMChooser->CreateMenuBarLayoutItem())
				.AddGlue()
				.End()
	
			.Add(new BStringView("svn repo folder label",
				TR("Subversion repository folder:")), 0, 1)
			.Add(fSVNRepoFolder, 1, 1)
			.End()
		.AddGlue()
		.SetInsets(B_USE_DEFAULT_SPACING)
		.View();
	fTabs[1]->SetName(TR("Source control"));
	fTabs[1]->SetViewColor(ui_color(B_PANEL_BACKGROUND_COLOR));

	// tab view

	fTabView = new BTabView("tabview", B_WIDTH_FROM_LABEL);
	fTabView->SetBorder(B_NO_BORDER);
	fTabView->AddTab(fTabs[0]);
	fTabView->AddTab(fTabs[1]);
	fTabView->Select(0L);

	BLayoutBuilder::Group<>(this, B_VERTICAL, 0)
		.AddStrut(B_USE_SMALL_SPACING)
		.Add(fTabView)
		.End();

	fProjectFolder->MakeFocus(true);

	CenterOnScreen();
}
开发者ID:jscipione,项目名称:Paladin,代码行数:101,代码来源:PrefsWindow.cpp

示例9:

/*!	Update color and refresh options according to current mode
	(a color space is made active if there is any mode with
	given resolution and this colour space; same applies for
	refresh rate, though "Other…" is always possible)
*/
void
ScreenWindow::_CheckColorMenu()
{
	int32 supportsAnything = false;
	int32 index = 0;

	for (int32 i = 0; i < kColorSpaceCount; i++) {
		if ((fSupportedColorSpaces & (1 << i)) == 0)
			continue;

		bool supported = false;

		for (int32 j = 0; j < fScreenMode.CountModes(); j++) {
			screen_mode mode = fScreenMode.ModeAt(j);

			if (fSelected.width == mode.width
				&& fSelected.height == mode.height
				&& kColorSpaces[i].space == mode.space
				&& fSelected.combine == mode.combine) {
				supportsAnything = true;
				supported = true;
				break;
			}
		}

		BMenuItem* item = fColorsMenu->ItemAt(index++);
		if (item)
			item->SetEnabled(supported);
	}

	fColorsField->SetEnabled(supportsAnything);

	if (!supportsAnything)
		return;

	// Make sure a valid item is selected

	BMenuItem* item = fColorsMenu->FindMarked();
	bool changed = false;

	if (item != fUserSelectedColorSpace) {
		if (fUserSelectedColorSpace != NULL
			&& fUserSelectedColorSpace->IsEnabled()) {
			fUserSelectedColorSpace->SetMarked(true);
			item = fUserSelectedColorSpace;
			changed = true;
		}
	}
	if (item != NULL && !item->IsEnabled()) {
		// find the next best item
		int32 index = fColorsMenu->IndexOf(item);
		bool found = false;

		for (int32 i = index + 1; i < fColorsMenu->CountItems(); i++) {
			item = fColorsMenu->ItemAt(i);
			if (item->IsEnabled()) {
				found = true;
				break;
			}
		}
		if (!found) {
			// search backwards as well
			for (int32 i = index - 1; i >= 0; i--) {
				item = fColorsMenu->ItemAt(i);
				if (item->IsEnabled())
					break;
			}
		}

		item->SetMarked(true);
		changed = true;
	}

	if (changed) {
		// Update selected space

		BMessage* message = item->Message();
		int32 space;
		if (message->FindInt32("space", &space) == B_OK) {
			fSelected.space = (color_space)space;
			_UpdateColorLabel();
		}
	}
}
开发者ID:mmadia,项目名称:Haiku-services-branch,代码行数:89,代码来源:ScreenWindow.cpp

示例10: templatePath

TemplateWindow::TemplateWindow(const BRect& frame)
	:
	BWindow(frame, TR("Choose a project type"), B_TITLED_WINDOW,
		B_NOT_RESIZABLE | B_NOT_ZOOMABLE | B_AUTO_UPDATE_SIZE_LIMITS)
{
	RegisterWindow();

	CheckTemplates();

	DPath templatePath(gAppPath.GetFolder());
	templatePath << TR("Templates");
	fTempList.ScanFolder(templatePath.GetFullPath());

	// project type

	BPopUpMenu* projectTypeMenu = new BPopUpMenu("Project type");
	for (int32 i = 0; i < fTempList.CountTemplates(); i++) {
		ProjectTemplate* ptemp = fTempList.TemplateAt(i);
		entry_ref ref = ptemp->GetRef();
		projectTypeMenu->AddItem(new BMenuItem(ref.name,
			new BMessage(M_TEMPLATE_SELECTED)));
	}
	projectTypeMenu->ItemAt(0L)->SetMarked(true);

	fTemplateField = new BMenuField("templatefield", TR("Project type: "),
		projectTypeMenu);
	fTemplateField->SetViewColor(ui_color(B_PANEL_BACKGROUND_COLOR));

	// project name

	fNameBox = new AutoTextControl("namebox", TR("Project name:"), "",
		new BMessage(M_NAME_CHANGED));
	SetToolTip(fNameBox, TR("The name of your project. "
		"It can be the same as the Target name, but it does not have to be."));

	// target name

	fTargetBox = new AutoTextControl("targetbox", TR("Target name:"), "BeApp",
		new BMessage(M_TARGET_CHANGED));
	SetToolTip(fTargetBox, TR("The name of the compiled application or library"));

	// project path

	fPathBox = new PathBox("pathbox", gProjectPath.GetFullPath(), "");
	fPathBox->SetExplicitMinSize(BSize(be_plain_font->StringWidth("M") * 36,
		B_SIZE_UNSET)),
	SetToolTip(fPathBox, TR("Set the location for your project."));

	// source control

	BPopUpMenu* scmMenu = new BPopUpMenu("SCM Chooser");
	scmMenu->AddItem(new BMenuItem(TR("Mercurial"), new BMessage()));
	scmMenu->AddItem(new BMenuItem(TR("Git"), new BMessage()));
	scmMenu->AddItem(new BMenuItem(TR("Subversion"), new BMessage()));
	scmMenu->AddItem(new BMenuItem(TR("None"), new BMessage()));

	if (!gHgAvailable) {
		scmMenu->ItemAt(0)->SetEnabled(false);
		scmMenu->ItemAt(0)->SetLabel(TR("Mercurial unavailable"));
	}
	if (!gGitAvailable) {
		scmMenu->ItemAt(1)->SetEnabled(false);
		scmMenu->ItemAt(1)->SetLabel(TR("Git unavailable"));
	}
	if (!gSvnAvailable) {
		scmMenu->ItemAt(2)->SetEnabled(false);
		scmMenu->ItemAt(2)->SetLabel(TR("Subversion unavailable"));
	}

	fSCMChooser = new BMenuField("scmchooser", TR("Source control: "), scmMenu);
	fSCMChooser->SetViewColor(ui_color(B_PANEL_BACKGROUND_COLOR));
	SetToolTip(fSCMChooser,
		TR("Choose the source control manager for your project, if any."));

	scmMenu->ItemAt(gDefaultSCM)->SetMarked(true);

	BMenuItem* item = scmMenu->FindMarked();
	if (!item->IsEnabled()) {
		item->SetMarked(false);
		for (int32 i = 0; i < scmMenu->CountItems(); i++) {
			if (scmMenu->ItemAt(i)->IsEnabled()) {
				scmMenu->ItemAt(i)->SetMarked(true);
				break;
			}
		}
	}

	// create folder check box

	fCreateFolder = new BCheckBox(TR("Create project folder"));
	fCreateFolder->SetValue(B_CONTROL_ON);
	SetToolTip(fCreateFolder, TR("If checked, a folder for your project will be created "
		"in the folder in the Location box above."));

	// create project button

	fCreateProjectButton = new BButton("ok", TR("Create project") B_UTF8_ELLIPSIS,
		new BMessage(M_CREATE_PROJECT));
	fCreateProjectButton->SetEnabled(false);
	fCreateProjectButton->MakeDefault(true);
//.........这里部分代码省略.........
开发者ID:jscipione,项目名称:Paladin,代码行数:101,代码来源:TemplateWindow.cpp


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