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


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

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


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

示例1: BPopUpMenu

void
TestView::SetupTestMenu(void)
{
	// These ones will always exist. Type is the default because it's probably
	// going to be the one most used
	BMessage *msg;
	BPopUpMenu *menu = new BPopUpMenu("Test");
	
	
	// Read in the types in the MIME database which have extra attributes
	// associated with them
	
	BMimeType mime;
	BMessage types, info, attr;
	BString string;
	
	BMimeType::GetInstalledTypes(&types);
	
	int32 index = 0;
	while (types.FindString("types",index,&string) == B_OK)
	{
		index++;
		mime.SetTo(string.String());
		if (mime.GetAttrInfo(&info) != B_OK)
			continue;
		
		int32 infoindex = 0;
		BString attrName;
		BString attrPublicName;
		int32 attrType;
		
		char attrTypeName[B_MIME_TYPE_LENGTH];
		mime.GetShortDescription(attrTypeName);
		
		while (info.FindString("attr:name",infoindex,&attrName) == B_OK)
		{
			// This is where we create tests based on a particular type's "special" attributes
			
			// Just string attributes are supported for now
			if (info.FindInt32("attr:type",infoindex,&attrType) != B_OK ||
				attrType != B_STRING_TYPE ||
				info.FindString("attr:public_name",infoindex,&attrPublicName) != B_OK)
			{
				infoindex++;
				continue;
			}
			
			BMenu *submenu = GetMenu(menu,attrTypeName);
			if (!submenu)
				submenu = AddMenuSorted(menu,attrTypeName);
			
			msg = new BMessage(M_TEST_CHOSEN);
			msg->AddString("name","Attribute");
			msg->AddString("attrtype",attrName);
			msg->AddString("attrname",attrPublicName);
			msg->AddString("mimetype",string);
			msg->AddString("typename",attrTypeName);
			submenu->AddItem(new BMenuItem(attrPublicName.String(),msg));
			
			infoindex++;
		}
	}
	
	menu->AddItem(new BSeparatorItem(),0);
	
	
	// All this weirdness is to have the "standard"	tests at the top and
	// the attribute tests at the bottom with a separator in between
	BString testtype;
	int32 i = 0;
	while (fTestTypes.FindString("tests",i,&testtype) == B_OK)
		i++;
	
	i--;
	
	while (i >= 0)
	{
		fTestTypes.FindString("tests",i,&testtype);
		msg = new BMessage(M_TEST_CHOSEN);
		msg->AddString("name",testtype);
		menu->AddItem(new BMenuItem(testtype.String(),msg),0);
		i--;
	}
	
	
	menu->Archive(&fArchivedTestMenu);
	delete menu;
}
开发者ID:puckipedia,项目名称:Filer,代码行数:88,代码来源:TestView.cpp


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