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


C++ BPopUpMenu::CountItems方法代码示例

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


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

示例1: GeneratePopUp

void StatusItem::GeneratePopUp(BPoint point, BRect openrect)
{
	BString str(value);
	str.Append(" ");
	BString url;
	URLCrunch crunch(str.String(), str.Length());
	BPopUpMenu* menu = new BPopUpMenu("URLs");
	BMessage msg(M_LOAD_URL);
	BMessage* allocmsg(NULL);
	BMenuItem* item(NULL);

	while (crunch.Crunch(&url) != B_ERROR) {
		allocmsg = new BMessage(msg);
		allocmsg->AddString("url", url.String());
		item = new BMenuItem(url.String(), allocmsg);
		menu->AddItem(item);
		allocmsg = NULL;
	}

	if (menu->CountItems() > 0) {
		menu->SetTargetForItems(be_app);
		menu->SetAsyncAutoDestruct(true);
		menu->Go(point, true, true, openrect, true);
	} else {
		delete menu;
	}
}
开发者ID:carriercomm,项目名称:Vision,代码行数:27,代码来源:StatusView.cpp

示例2: BMessage


//.........这里部分代码省略.........
		}
		if (count > 0)
			menu->AddSeparatorItem();
	}

	// Hack for R5's buggy Query Notification
	#ifdef HAIKU_TARGET_PLATFORM_BEOS
		menu->AddItem(new BMenuItem(
			MDR_DIALECT_CHOICE("Refresh New Mail Count",
				"未読メールカウントを更新"),
			new BMessage(MD_REFRESH_QUERY)));
	#endif

	// The New E-mail query

	if (fNewMessages > 0) {
		BString string;
		MDR_DIALECT_CHOICE(
			string << fNewMessages << " new message"
				<< (fNewMessages != 1 ? "s" : B_EMPTY_STRING),
			string << fNewMessages << " 通の未読メッセージ");

		_GetNewQueryRef(ref);

		item = new BMenuItem(navMenu = new BNavMenu(string.String(),
			B_REFS_RECEIVED, BMessenger(kTrackerSignature)),
			msg = new BMessage(B_REFS_RECEIVED));
		msg->AddRef("refs", &ref);
		navMenu->SetNavDir(&ref);

		menu->AddItem(item);
	} else {
		menu->AddItem(item = new BMenuItem(
			MDR_DIALECT_CHOICE ("No new messages","未読メッセージなし"), NULL));
		item->SetEnabled(false);
	}

	BMailAccounts accounts;
	if (modifiers() & B_SHIFT_KEY) {
		BMenu *accountMenu = new BMenu(
			MDR_DIALECT_CHOICE ("Check for mails only","R) メール受信のみ"));
		BFont font;
		menu->GetFont(&font);
		accountMenu->SetFont(&font);

		for (int32 i = 0; i < accounts.CountAccounts(); i++) {
			BMailAccountSettings* account = accounts.AccountAt(i);

			BMessage* message = new BMessage(MD_CHECK_FOR_MAILS);
			message->AddInt32("account", account->AccountID());

			accountMenu->AddItem(new BMenuItem(account->Name(), message));
		}
		if (accounts.CountAccounts() == 0) {
			item = new BMenuItem("<no accounts>", NULL);
			item->SetEnabled(false);
			accountMenu->AddItem(item);
		}
		accountMenu->SetTargetForItems(this);
		menu->AddItem(new BMenuItem(accountMenu,
			new BMessage(MD_CHECK_FOR_MAILS)));

		// Not used:
		// menu->AddItem(new BMenuItem(MDR_DIALECT_CHOICE (
		// "Check For Mails Only","メール受信のみ"), new BMessage(MD_CHECK_FOR_MAILS)));
		menu->AddItem(new BMenuItem(
			MDR_DIALECT_CHOICE ("Send pending mails", "M) 保留メールを送信"),
		new BMessage(MD_SEND_MAILS)));
	} else {
		menu->AddItem(item = new BMenuItem(
			MDR_DIALECT_CHOICE ("Check for mail now", "C) メールチェック"),
			new BMessage(MD_CHECK_SEND_NOW)));
		if (accounts.CountAccounts() == 0)
			item->SetEnabled(false);
	}

	menu->AddSeparatorItem();
	menu->AddItem(new BMenuItem(
		MDR_DIALECT_CHOICE ("Preferences", "P) メール環境設定") B_UTF8_ELLIPSIS,
		new BMessage(MD_OPEN_PREFS)));

	if (modifiers() & B_SHIFT_KEY) {
		menu->AddItem(new BMenuItem(
			MDR_DIALECT_CHOICE ("Shutdown mail services", "Q) 終了"),
			new BMessage(B_QUIT_REQUESTED)));
	}

	// Reset Item Targets (only those which aren't already set)

	for (int32 i = menu->CountItems(); i-- > 0;) {
		item = menu->ItemAt(i);
		if (item && (msg = item->Message()) != NULL) {
			if (msg->what == B_REFS_RECEIVED)
				item->SetTarget(tracker);
			else
				item->SetTarget(this);
		}
	}
	return menu;
}
开发者ID:,项目名称:,代码行数:101,代码来源:

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

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

示例5:

/*!	\brief		Updates targets of all controls currently in the view.
 *	\details	BView::AttachToWindow(), among other things, modifies the targets
 *				of controls to point to main looper of the application. This is
 *				not desirable way. This function corrects it.
 */
void		CalendarModulePreferencesView::UpdateTargetting( void )
{
	BCheckBox* tempCheckBox = NULL;
	int i, limit;

	// Updating calendar chooser part
	BMenuItem* menuItem = NULL;
	if ( calendarModules ) {
		limit = calendarModules->CountItems();
		for ( i = 0; i < limit; ++i )
		{
			menuItem = dynamic_cast< BMenuItem* >( calendarModules->ItemAt( i ) );
			if ( menuItem )
				menuItem->SetTarget( this );
		}
	}

	// Update Weekends selector box
	BBox* tempBBox = ( BBox* )this->FindView( "Weekend selector" );
	if ( tempBBox ) {
		limit = tempBBox->CountChildren();
		for ( i = 0; i < limit; ++i )
		{
			tempCheckBox = dynamic_cast< BCheckBox* >( tempBBox->ChildAt( i ) );
			if ( tempCheckBox )
				tempCheckBox->SetTarget( this );
		}
	}
	
	// Update First day of week chooser
	BPopUpMenu* tempMenu = ( BPopUpMenu* )this->FindView( "First day of week" );
	if ( tempMenu )
	{
		limit = tempMenu->CountItems();
		for ( i = 0; i < limit; ++i )
		{
			menuItem = dynamic_cast< BMenuItem* >( tempMenu->ItemAt( i ) );
			if ( menuItem )
				menuItem->SetTarget( this );
		}
	}
	
	// Update day-month-year order chooser
	tempMenu = ( BPopUpMenu* )this->FindView( "DmyOrderChooser" );
	if ( tempMenu )
	{
		limit = tempMenu->CountItems();
		for ( i = 0; i < limit; ++i )
		{
			menuItem = dynamic_cast< BMenuItem* >( tempMenu->ItemAt( i ) );
			if ( menuItem )
				menuItem->SetTarget( this );
		}
	}
	
	// Update the target of Color selector
	CategoryListView* catListView = ( CategoryListView* )this->FindView("Colors list view");
	if ( catListView )
	{
		catListView->SetTarget( this );
	}
	
}	// <-- end of function CalendarModulePreferencesView::UpdateTargetting
开发者ID:BackupTheBerlios,项目名称:haiku-pim-svn,代码行数:68,代码来源:CalendarModulePreferencesView.cpp

示例6: BPopUpMenu

/*!	
 *	\brief			Create a menu to select the module user is setting up.
 *	\note			This is an internal function.
 */
BPopUpMenu*		CalendarModulePreferencesView::PopulateModulesMenu( void )
{
	BPopUpMenu* toReturn = NULL;
	BMenuItem* 	toAdd = NULL;
	BMessage*  	toSend = NULL;
	BString		moduleId;	// Note: this is not a pointer!
	CalendarModule* currentCalModule = NULL;
	
	toReturn = new BPopUpMenu("Calendar Modules");
	if ( ! toReturn )
	{ 
		/* Panic! */
		exit (1);
	}
	
	// Looping on all calendar modules available in the system.
	for ( uint i=0; i < NUMBER_OF_CALENDAR_MODULES; ++i )
	{
		// Obtain the next calendar module
		currentCalModule = (CalendarModule *)global_ListOfCalendarModules.ItemAt( i );
		if ( !currentCalModule )
		{
			continue;	// Skipping unavailable ones
		}
		
		// Create the message
		toSend = new BMessage( kCalendarModuleChosen );
		if ( !toSend )
		{
			/* Panic! */
			exit(1);
		}
		
		// Add the ID of the module to the message
		moduleId = currentCalModule->Identify();
		toSend->AddString( "Module ID", moduleId );
		
		// Create the menu item
		toAdd = new BMenuItem( moduleId.String(), toSend );
		if ( ! toAdd )
		{
			/* Panic! */
			exit(1);
		}
		toAdd->SetTarget( this );
		
		// Add the newly created item to the menu
		toReturn->AddItem( toAdd );
		
		// Gregorian calendar module is the default one
		if ( moduleId == "Gregorian" )
		{
			toAdd->SetMarked( true );
		}
		
	}	/* <-- end of "for ( every calendar module )" */
	
	// At least something should be marked.
	if ( ( ! toReturn->FindMarked() ) && ( toReturn->CountItems() > 0 ) )
	{
		toReturn->ItemAt( 0 )->SetMarked( true );	
	}
	
	return toReturn;
}	// <-- end of function "CalendarModulePreferencesView::PopulateModulesMenu"
开发者ID:BackupTheBerlios,项目名称:haiku-pim-svn,代码行数:69,代码来源:CalendarModulePreferencesView.cpp

示例7:

void
TestView::MessageReceived(BMessage *msg)
{
	switch (msg->what)
	{
		case M_TEST_CHOSEN:
		{
			SetTest(msg);
			break;
		}
		case M_MODE_CHOSEN:
		{
			BString mode;
			if (msg->FindString("mode",&mode) != B_OK)
				break;
			
			SetMode(mode.String());
			break;
		}
		case M_VALUE_CHANGED:
		{
			BString str;
			if (fTest->FindString("value",&str) == B_OK)
				fTest->ReplaceString("value",fValueBox->Text());
			else
				fTest->AddString("value",fValueBox->Text());
			break;
		}
		case M_SHOW_TEST_MENU:
		{
			BPopUpMenu *menu = (BPopUpMenu*)BPopUpMenu::Instantiate(&fArchivedTestMenu);
			menu->SetTargetForItems(this);
			
			for (int32 i = 0; i < menu->CountItems(); i++)
			{
				BMenuItem *item = menu->ItemAt(i);
				if (item->Submenu())
					item->Submenu()->SetTargetForItems(this);
			}
			
			BPoint pt;
			uint32 buttons;
			GetMouse(&pt,&buttons);
			ConvertToScreen(&pt);
			pt.x -= 10.0;
			if (pt.x < 0.0)
				pt.x = 0.0;
			
			pt.y -= 10.0;
			if (pt.y < 0.0)
				pt.y = 0.0;
			
			menu->SetAsyncAutoDestruct(true);
			menu->Go(pt,true,true,true);
			break;
		}
		case M_SHOW_TYPE_MENU:
		{
			BPopUpMenu *menu = (BPopUpMenu*)BPopUpMenu::Instantiate(&gArchivedTypeMenu);
			menu->SetTargetForItems(this);
			
			for (int32 i = 0; i < menu->CountItems(); i++)
			{
				BMenuItem *item = menu->ItemAt(i);
				if (item->Submenu())
					item->Submenu()->SetTargetForItems(this);
			}
			
			BPoint pt;
			uint32 buttons;
			GetMouse(&pt,&buttons);
			ConvertToScreen(&pt);
			pt.x -= 10.0;
			if (pt.x < 0.0)
				pt.x = 0.0;
			
			pt.y -= 10.0;
			if (pt.y < 0.0)
				pt.y = 0.0;
			
			menu->SetAsyncAutoDestruct(true);
			menu->Go(pt,true,true,true);
			break;
		}
		case M_SHOW_MODE_MENU:
		{
			ShowModeMenu();
			break;
		}
		default:
		{
			BView::MessageReceived(msg);
			break;
		}
	}

}
开发者ID:puckipedia,项目名称:Filer,代码行数:97,代码来源:TestView.cpp


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