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


C++ BNavMenu::SetNavDir方法代码示例

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


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

示例1: model

void
BDirMenu::AddItemToDirMenu(const BEntry* entry, BWindow* originatingWindow,
	bool atEnd, bool addShortcuts, bool navMenuEntries)
{
	Model model(entry);
	if (model.InitCheck() != B_OK)
		return;

	BMessage* message = new BMessage(fCommand);
	message->AddRef(fEntryName.String(), model.EntryRef());

	// add reference to the container windows model so that we can
	// close the window if
	BContainerWindow* window = originatingWindow ?
		dynamic_cast<BContainerWindow*>(originatingWindow) : 0;
	if (window)
		message->AddData("nodeRefsToClose", B_RAW_TYPE,
			window->TargetModel()->NodeRef(), sizeof (node_ref));
	ModelMenuItem* item;
	if (navMenuEntries) {
		BNavMenu* subMenu = new BNavMenu(model.Name(), B_REFS_RECEIVED,
			fTarget, window);
		entry_ref ref;
		entry->GetRef(&ref);
		subMenu->SetNavDir(&ref);
		item = new ModelMenuItem(&model, subMenu);
		item->SetLabel(model.Name());
		item->SetMessage(message);
	} else {
		item = new ModelMenuItem(&model, model.Name(), message);
	}

	if (addShortcuts) {
		if (model.IsDesktop())
			item->SetShortcut('D', B_COMMAND_KEY);
		else if (FSIsHomeDir(entry))
			item->SetShortcut('H', B_COMMAND_KEY);
	}

	if (atEnd)
		AddItem(item);
	else
		AddItem(item, 0);

	item->SetTarget(fTarget);

	if (fMenuBar) {
		ModelMenuItem* menu
			= dynamic_cast<ModelMenuItem*>(fMenuBar->ItemAt(0));
		if (menu) {
			ThrowOnError(menu->SetEntry(entry));
			item->SetMarked(true);
		}
	}
}
开发者ID:RTOSkit,项目名称:haiku,代码行数:55,代码来源:DirMenu.cpp

示例2: BNavMenu

void
BNavMenu::AddNavParentDir(const char *name,const Model *model,uint32 what,BHandler *target)
{
	BNavMenu *menu = new BNavMenu(name,what,target);
	menu->SetNavDir(model->EntryRef());
	menu->SetShowParent(true);
	menu->InitTrackingHook(fTrackingHook.fTrackingHook, &(fTrackingHook.fTarget),
			fTrackingHook.fDragMessage);

	BMenuItem *item = new SpecialModelMenuItem(model,menu);

	BMessage *message = new BMessage(what);
	message->AddRef("refs",model->EntryRef());
	item->SetMessage(message);

	AddItem(item);
}
开发者ID:Ithamar,项目名称:cosmoe,代码行数:17,代码来源:NavMenu.cpp

示例3: Model

void
BSlowContextMenu::BuildVolumeMenu()
{
	BVolumeRoster roster;
	BVolume	volume;

	roster.Rewind();
	while (roster.GetNextVolume(&volume) == B_OK) {
		
		if (!volume.IsPersistent())
			continue;
		
		BDirectory startDir;
		if (volume.GetRootDirectory(&startDir) == B_OK) {
			BEntry entry;
			startDir.GetEntry(&entry);

			Model *model = new Model(&entry);
			if (model->InitCheck() != B_OK) {
				delete model;
				continue;
			}
			
			BNavMenu *menu = new BNavMenu(model->Name(), fMessage.what,
				fMessenger, fParentWindow, fTypesList);

			menu->SetNavDir(model->EntryRef());
			menu->InitTrackingHook(fTrackingHook.fTrackingHook, &(fTrackingHook.fTarget),
				fTrackingHook.fDragMessage);

			ASSERT(menu->Name());

			ModelMenuItem *item = new ModelMenuItem(model, menu);
			BMessage *message = new BMessage(fMessage);

			message->AddRef("refs", model->EntryRef());
			item->SetMessage(message);
			fItemList->AddItem(item);
			ASSERT(item->Label());
		}
	}
}
开发者ID:mmanley,项目名称:Antares,代码行数:42,代码来源:SlowContextPopup.cpp

示例4: BMessage

void 
BNavMenu::AddNavDir(const Model *model, uint32 what, BHandler *target,
	bool populateSubmenu)
{
	BMessage *message = new BMessage((uint32)what);
	message->AddRef("refs", model->EntryRef());
	ModelMenuItem *item = NULL;

	if (populateSubmenu) {
		BNavMenu *navMenu = new BNavMenu(model->Name(), what, target);
		navMenu->SetNavDir(model->EntryRef());
		navMenu->InitTrackingHook(fTrackingHook.fTrackingHook, &(fTrackingHook.fTarget),
				fTrackingHook.fDragMessage);
		item = new ModelMenuItem(model, navMenu);
		item->SetMessage(message);
	} else 
		item = new ModelMenuItem(model, model->Name(), message);

	AddItem(item);
}
开发者ID:Ithamar,项目名称:cosmoe,代码行数:20,代码来源:NavMenu.cpp

示例5: opener

ModelMenuItem * 
BSlowContextMenu::NewModelItem(Model *model, const BMessage *invokeMessage,
	const BMessenger &target, bool suppressFolderHierarchy,
	BContainerWindow *parentWindow, const BObjectList<BString> *typeslist,
	TrackingHookData *hook)
{
	if (model->InitCheck() != B_OK)
		return NULL;

	entry_ref ref;
	bool container = false;
	if (model->IsSymLink()) {
	
		Model *newResolvedModel = NULL;
		Model *result = model->LinkTo();

		if (!result) {
			newResolvedModel = new Model(model->EntryRef(), true, true);

			if (newResolvedModel->InitCheck() != B_OK) {
				// broken link, still can show though, bail
				delete newResolvedModel;
				newResolvedModel = NULL;
			}
			
			result = newResolvedModel;
		}

		if (result) {
			BModelOpener opener(result);
				// open the model, if it ain't open already
					
			PoseInfo poseInfo;
			ssize_t size = -1;
			
			if (result->Node()) 
				size = result->Node()->ReadAttr(kAttrPoseInfo, B_RAW_TYPE, 0,
					&poseInfo, sizeof(poseInfo));
	
			result->CloseNode();

			ref = *result->EntryRef();
			container = result->IsContainer();
		}
		model->SetLinkTo(result);
	} else {
		ref = *model->EntryRef();
		container = model->IsContainer();
	}

	BMessage *message = new BMessage(*invokeMessage);
	message->AddRef("refs", model->EntryRef());

	// Truncate the name if necessary
	BString truncatedString(model->Name());
	be_plain_font->TruncateString(&truncatedString, B_TRUNCATE_END,
		BNavMenu::GetMaxMenuWidth());

	ModelMenuItem *item = NULL;
	if (!container || suppressFolderHierarchy) {
		item = new ModelMenuItem(model, truncatedString.String(), message);
		if (invokeMessage->what != B_REFS_RECEIVED)
			item->SetEnabled(false);
	} else {
		BNavMenu *menu = new BNavMenu(truncatedString.String(),
			invokeMessage->what, target, parentWindow, typeslist);
		
		menu->SetNavDir(&ref);
		if (hook)
			menu->InitTrackingHook(hook->fTrackingHook, &(hook->fTarget),
				hook->fDragMessage);

		item = new ModelMenuItem(model, menu);
		item->SetMessage(message);
	}

	return item;
}
开发者ID:mmanley,项目名称:Antares,代码行数:78,代码来源:SlowContextPopup.cpp

示例6: model

BMenuItem*
BRecentItemsList::GetNextMenuItem(const BMessage* fileOpenInvokeMessage,
	const BMessage* containerOpenInvokeMessage, BHandler* target,
	entry_ref* currentItemRef)
{
	entry_ref ref;
	if (GetNextRef(&ref) != B_OK)
		return NULL;

	Model model(&ref, true);
	if (model.InitCheck() != B_OK)
		return NULL;

	bool container = false;
	if (model.IsSymLink()) {

		Model* newResolvedModel = NULL;
		Model* result = model.LinkTo();

		if (result == NULL) {
			newResolvedModel = new Model(model.EntryRef(), true, true);

			if (newResolvedModel->InitCheck() != B_OK) {
				// broken link, still can show though, bail
				delete newResolvedModel;
				result = NULL;
			} else
				result = newResolvedModel;
		} else {
			BModelOpener opener(result);
				// open the model, if it ain't open already

			PoseInfo poseInfo;
			BNode* resultNode = result->Node();
			if (resultNode != NULL) {
				resultNode->ReadAttr(kAttrPoseInfo, B_RAW_TYPE, 0,
					&poseInfo, sizeof(poseInfo));
			}

			result->CloseNode();

			ref = *result->EntryRef();
			container = result->IsContainer();
		}
		model.SetLinkTo(result);
	} else {
		ref = *model.EntryRef();
		container = model.IsContainer();
	}

	// if user asked for it, return the current item ref
	if (currentItemRef != NULL)
		*currentItemRef = ref;

	BMessage* message;
	if (container && containerOpenInvokeMessage)
		message = new BMessage(*containerOpenInvokeMessage);
	else if (!container && fileOpenInvokeMessage)
		message = new BMessage(*fileOpenInvokeMessage);
	else
		message = new BMessage(B_REFS_RECEIVED);

	message->AddRef("refs", model.EntryRef());

	// Truncate the name if necessary
	BString truncatedString(model.Name());
	be_plain_font->TruncateString(&truncatedString, B_TRUNCATE_END,
		BNavMenu::GetMaxMenuWidth());

	ModelMenuItem* item = NULL;
	if (!container || !fNavMenuFolders)
		item = new ModelMenuItem(&model, truncatedString.String(), message);
	else {
		// add another nav menu item if it's a directory
		BNavMenu* menu = new BNavMenu(truncatedString.String(), message->what,
			target, 0);

		menu->SetNavDir(&ref);
		item = new ModelMenuItem(&model, menu);
		item->SetMessage(message);
	}

	if (item != NULL && target != NULL)
		item->SetTarget(target);

	return item;
}
开发者ID:mylegacy,项目名称:haiku,代码行数:87,代码来源:RecentItems.cpp

示例7: opener

ModelMenuItem * 
BNavMenu::NewModelItem(Model *model, const BMessage *invokeMessage,
	const BMessenger &target, bool suppressFolderHierarchy,
	BContainerWindow *parentWindow, const BObjectList<BString> *typeslist,
	TrackingHookData *hook)
{
	if (model->InitCheck() != B_OK)
		return 0;
	entry_ref ref;
	bool container = false;
	if (model->IsSymLink()) {
	
		Model *newResolvedModel = 0;
		Model *result = model->LinkTo();

		if (!result) {
			newResolvedModel = new Model(model->EntryRef(), true, true);

			if (newResolvedModel->InitCheck() != B_OK) {
				// broken link, still can show though, bail
				delete newResolvedModel;
				result = 0;
			} else
				result = newResolvedModel;
		}

		if (result) {
			BModelOpener opener(result);
				// open the model, if it ain't open already
					
			PoseInfo poseInfo;
			ssize_t size = -1;
			
			if (result->Node()) 
				size = result->Node()->ReadAttr(kAttrPoseInfo, B_RAW_TYPE, 0,
					&poseInfo, sizeof(poseInfo));
	
			result->CloseNode();

			if (size == sizeof(poseInfo) && !BPoseView::PoseVisible(result,
				&poseInfo, false)) {
				// link target sez it doesn't want to be visible,
				// don't show the link
				PRINT(("not showing hidden item %s\n", model->Name()));
				delete newResolvedModel;
				return 0;
			}
			ref = *result->EntryRef();
			container = result->IsContainer();
		}
		model->SetLinkTo(result);
	} else {
		ref = *model->EntryRef();
		container = model->IsContainer();
	}

	BMessage *message = new BMessage(*invokeMessage);
	message->AddRef("refs", model->EntryRef());

	// Truncate the name if necessary
	BString truncatedString;
	TruncString(be_plain_font, model->Name(), truncatedString, GetMaxMenuWidth());

	ModelMenuItem *item = NULL;
	if (!container || suppressFolderHierarchy) {
		item = new ModelMenuItem(model, truncatedString.String(), message);
		if (invokeMessage->what != B_REFS_RECEIVED)
			item->SetEnabled(false);
			// the above is broken for FavoritesMenu::AddNextItem, which uses a
			// workaround - should fix this
	} else {
		BNavMenu *menu = new BNavMenu(truncatedString.String(),
			invokeMessage->what, target, parentWindow, typeslist);
		
		menu->SetNavDir(&ref);
		if (hook)
			menu->InitTrackingHook(hook->fTrackingHook, &(hook->fTarget),
				hook->fDragMessage);

		item = new ModelMenuItem(model, menu);
		item->SetMessage(message);
	}
	
	return item;
}
开发者ID:Ithamar,项目名称:cosmoe,代码行数:85,代码来源:NavMenu.cpp


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