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


C++ BPose类代码示例

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


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

示例1: CountItems

BPose*
PoseList::DeepFindPose(const node_ref* node, int32* resultingIndex) const
{
	int32 count = CountItems();
	for (int32 index = 0; index < count; index++) {
		BPose* pose = ItemAt(index);
		Model* model = pose->TargetModel();
		if (*model->NodeRef() == *node) {
			if (resultingIndex != NULL)
				*resultingIndex = index;

			return pose;
		}
		// if model is a symlink, try matching node with the target
		// of the link
		if (model->IsSymLink()) {
			model = model->LinkTo();
			if (model != NULL && *model->NodeRef() == *node) {
				if (resultingIndex != NULL)
					*resultingIndex = index;

				return pose;
			}
		}
	}

	return NULL;
}
开发者ID:AmirAbrams,项目名称:haiku,代码行数:28,代码来源:PoseList.cpp

示例2: _SCRIPTING_ONLY

bool
BPoseView::ExecuteProperty(BMessage *_SCRIPTING_ONLY(specifier),
	int32 _SCRIPTING_ONLY(form), const char *_SCRIPTING_ONLY(property),
	BMessage *_SCRIPTING_ONLY(reply))
{
#if _SUPPORTS_FEATURE_SCRIPTING
	status_t error = B_OK;
	bool handled = false;
	if (strcmp(property, kPropertyEntry) == 0) {
		BMessage launchMessage(B_REFS_RECEIVED);
		
		if (form == (int32)B_ENTRY_SPECIFIER) {
			// move all poses specified by entry_ref to Trash
			entry_ref ref;
			for (int32 index = 0; specifier->FindRef("refs", index, &ref)
				== B_OK; index++)
				launchMessage.AddRef("refs", &ref);

		} else if (form == (int32)B_INDEX_SPECIFIER) {
			// move all poses specified by index to Trash
			int32 specifyingIndex;
			for (int32 index = 0; specifier->FindInt32("index", index,
				&specifyingIndex) == B_OK; index++) {
				BPose *pose = PoseAtIndex(specifyingIndex);

				if (!pose) {
					error = B_ENTRY_NOT_FOUND;
					break;
				}

				launchMessage.AddRef("refs", pose->TargetModel()->EntryRef());
			}
		} else
			return false;

		if (error == B_OK) {
			// add a messenger to the launch message that will be used to
			// dispatch scripting calls from apps to the PoseView
			launchMessage.AddMessenger("TrackerViewToken", BMessenger(this, 0, 0));
			if (fSelectionHandler)
				fSelectionHandler->PostMessage(&launchMessage);
		}
		handled = true;
	}

	if (error != B_OK)
		reply->AddInt32("error", error);

	return handled;
#else
	return false;
#endif
}
开发者ID:Ithamar,项目名称:cosmoe,代码行数:53,代码来源:PoseViewScripting.cpp

示例3: CountItems

BPose*
PoseList::FindPose(const node_ref* node, int32* resultingIndex) const
{
	int32 count = CountItems();
	for (int32 index = 0; index < count; index++) {
		BPose* pose = ItemAt(index);
		ASSERT(pose->TargetModel());
		if (*pose->TargetModel()->NodeRef() == *node) {
			if (resultingIndex)
				*resultingIndex = index;

			return pose;
		}
	}
	return NULL;
}
开发者ID:naveedasmat,项目名称:haiku,代码行数:16,代码来源:PoseList.cpp

示例4: ASSERT

void
BQueryPoseView::AddPosesCompleted()
{
	ASSERT(Window()->IsLocked());

	PoseList* oldPoseList = fQueryListContainer->OldPoseList();
	if (oldPoseList) {
		int32 count = oldPoseList->CountItems();
		for (int32 index = count - 1; index >= 0; index--) {
			BPose* pose = oldPoseList->ItemAt(index);
			DeletePose(pose->TargetModel()->NodeRef());
		}
		fQueryListContainer->ClearOldPoseList();
	}

	_inherited::AddPosesCompleted();
}
开发者ID:RTOSkit,项目名称:haiku,代码行数:17,代码来源:QueryPoseView.cpp

示例5: FSClipboardRemovePoses

uint32
FSClipboardRemovePoses(const node_ref *directory, PoseList *list)
{
	if (!be_clipboard->Lock())
		return 0;

	// update message to be send to all listeners
	BMessage updateMessage(kFSClipboardChanges);
	updateMessage.AddInt32("device", directory->device);
	updateMessage.AddInt64("directory", directory->node);
	updateMessage.AddBool("clearClipboard", false);

	TClipboardNodeRef clipNode;
	clipNode.moveMode = kDelete;

	uint32 refsRemoved = 0;

	BMessage *clip = be_clipboard->Data();
	if (clip != NULL) {
		int32 listCount = list->CountItems();

		for (int32 index = 0; index < listCount; index++) {
			char refName[64], modeName[64];
			BPose *pose = (BPose *)list->ItemAt(index);

			clipNode.node = *pose->TargetModel()->NodeRef();
			MakeRefName(refName, &clipNode.node);
			MakeModeName(modeName);

			if (clip->RemoveName(refName) == B_OK && clip->RemoveName(modeName)) {
				updateMessage.AddData("tcnode", T_CLIPBOARD_NODE, &clipNode,
					sizeof(TClipboardNodeRef), true, listCount);
				refsRemoved++;
			}
		}
		be_clipboard->Commit();
	}
	be_clipboard->Unlock();

	BMessenger(kTrackerSignature).SendMessage(&updateMessage);
		// Tracker will notify all listeners

	return refsRemoved;
}
开发者ID:HaikuArchives,项目名称:OpenTracker,代码行数:44,代码来源:FSClipboard.cpp

示例6: _DispatchEntryCreatedOrRemovedMessage

bool
VirtualDirectoryPoseView::_EntryRemoved(const BMessage* message)
{
	NotOwningEntryRef entryRef;
	node_ref nodeRef;

	if (message->FindInt32("device", &nodeRef.device) != B_OK
		|| message->FindInt64("node", &nodeRef.node) != B_OK
		|| message->FindInt64("directory", &entryRef.directory)
			!= B_OK
		|| message->FindString("name", (const char**)&entryRef.name) != B_OK) {
		return true;
	}
	entryRef.device = nodeRef.device;

	// It might be our definition file.
	if (nodeRef == *TargetModel()->NodeRef())
		return _inherited::FSNotification(message);

	// It might be one of our directories.
	BString path;
	if (message->FindString("path", &path) == B_OK
		&& fDirectoryPaths.HasString(path)) {
		// Find all poses that stem from that directory and generate an
		// entry-removed message for each.
		PoseList poses;
		for (int32 i = 0; BPose* pose = fPoseList->ItemAt(i); i++) {
			NotOwningEntryRef poseEntryRef = *pose->TargetModel()->EntryRef();
			if (poseEntryRef.DirectoryNodeRef() == nodeRef)
				poses.AddItem(pose);
		}

		for (int32 i = 0; BPose* pose = poses.ItemAt(i); i++) {
			_DispatchEntryCreatedOrRemovedMessage(B_ENTRY_REMOVED,
				*pose->TargetModel()->NodeRef(),
				*pose->TargetModel()->EntryRef(), NULL, false);
		}

		return true;
	}

	// If it is a directory, translate it.
	entry_ref* actualEntryRef = &entryRef;
	node_ref* actualNodeRef = &nodeRef;
	entry_ref definitionEntryRef;
	node_ref definitionNodeRef;

	VirtualDirectoryManager* manager = VirtualDirectoryManager::Instance();
	AutoLocker<VirtualDirectoryManager> managerLocker(manager);

	if (manager != NULL
		&& manager->GetSubDirectoryDefinitionFile(*TargetModel()->NodeRef(),
			entryRef.name, definitionEntryRef, definitionNodeRef)) {
		actualEntryRef = &definitionEntryRef;
		actualNodeRef = &definitionNodeRef;
	}

	// Check the pose. It might have been an entry that wasn't visible anyway.
	// In that case we can just ignore the notification.
	BPose* pose = fPoseList->FindPoseByFileName(actualEntryRef->name);
	if (pose == NULL || *actualNodeRef != *pose->TargetModel()->NodeRef())
		return true;

	// See, if another entry becomes visible, now.
	struct stat st;
	entry_ref visibleEntryRef;
	node_ref visibleNodeRef;
	if (_GetEntry(actualEntryRef->name, visibleEntryRef, &st)) {
		// If the new entry is a directory, translate it.
		visibleNodeRef = node_ref(st.st_dev, st.st_ino);
		if (S_ISDIR(st.st_mode)) {
			if (manager == NULL || manager->TranslateDirectoryEntry(
					*TargetModel()->NodeRef(), visibleEntryRef, visibleNodeRef)
					!= B_OK) {
				return true;
			}

			// Effectively nothing changes, when the removed entry was a
			// directory as well.
			if (visibleNodeRef == *actualNodeRef)
				return true;
		}
	}

	if (actualEntryRef == &entryRef) {
		managerLocker.Unlock();
		if (_inherited::FSNotification(message))
			pendingNodeMonitorCache.Add(message);
	} else {
		// tell the manager that the directory has been removed
		manager->DirectoryRemoved(*actualNodeRef);
		managerLocker.Unlock();

		_DispatchEntryCreatedOrRemovedMessage(B_ENTRY_REMOVED, *actualNodeRef,
			*actualEntryRef);
	}

	_DispatchEntryCreatedOrRemovedMessage(B_ENTRY_CREATED, visibleNodeRef,
		visibleEntryRef);

//.........这里部分代码省略.........
开发者ID:naveedasmat,项目名称:haiku,代码行数:101,代码来源:VirtualDirectoryPoseView.cpp

示例7: while

bool
VirtualDirectoryPoseView::_EntryCreated(const BMessage* message)
{
	NotOwningEntryRef entryRef;
	node_ref nodeRef;

	if (message->FindInt32("device", &nodeRef.device) != B_OK
		|| message->FindInt64("node", &nodeRef.node) != B_OK
		|| message->FindInt64("directory", &entryRef.directory) != B_OK
		|| message->FindString("name", (const char**)&entryRef.name) != B_OK) {
		return true;
	}
	entryRef.device = nodeRef.device;

	// It might be one of our directories.
	BString path;
	if (message->FindString("path", &path) == B_OK
		&& fDirectoryPaths.HasString(path)) {
		// Iterate through the directory and generate an entry-created message
		// for each entry.
		BDirectory directory;
		if (directory.SetTo(&nodeRef) != B_OK)
			return true;

		BPrivate::Storage::LongDirEntry entry;
		while (directory.GetNextDirents(&entry, sizeof(entry), 1) == 1) {
			if (strcmp(entry.d_name, ".") != 0
				&& strcmp(entry.d_name, "..") != 0) {
				_DispatchEntryCreatedOrRemovedMessage(B_ENTRY_CREATED,
					node_ref(entry.d_dev, entry.d_ino),
					NotOwningEntryRef(entry.d_pdev, entry.d_pino,
						entry.d_name),
					NULL, false);
			}
		}
		return true;
	}

	// See, if this entry actually becomes visible. If not, we can simply ignore
	// it.
	struct stat st;
	entry_ref visibleEntryRef;
	if (!_GetEntry(entryRef.name, visibleEntryRef, &st)
		|| visibleEntryRef != entryRef) {
		return true;
	}

	// If it is a directory, translate it.
	VirtualDirectoryManager* manager = VirtualDirectoryManager::Instance();
	AutoLocker<VirtualDirectoryManager> managerLocker(manager);

	bool entryTranslated = S_ISDIR(st.st_mode);
	if (entryTranslated) {
		if (manager == NULL)
			return true;

		if (manager->TranslateDirectoryEntry(*TargetModel()->NodeRef(),
				entryRef, nodeRef) != B_OK) {
			return true;
		}
	}

	// The entry might replace another entry. If it does, we'll fake a removed
	// message for the old one first.
	BPose* pose = fPoseList->FindPoseByFileName(entryRef.name);
	if (pose != NULL) {
		if (nodeRef == *pose->TargetModel()->NodeRef()) {
			// apparently not really a new entry -- can happen for
			// subdirectories
			return true;
		}

		// It may be a directory, so tell the manager.
		if (manager != NULL)
			manager->DirectoryRemoved(*pose->TargetModel()->NodeRef());

		managerLocker.Unlock();

		BMessage removedMessage(B_NODE_MONITOR);
		_DispatchEntryCreatedOrRemovedMessage(B_ENTRY_REMOVED,
			*pose->TargetModel()->NodeRef(), *pose->TargetModel()->EntryRef());
	} else
		managerLocker.Unlock();

	return entryTranslated
		? (_DispatchEntryCreatedOrRemovedMessage(B_ENTRY_CREATED, nodeRef,
			entryRef), true)
		: _inherited::FSNotification(message);
}
开发者ID:naveedasmat,项目名称:haiku,代码行数:89,代码来源:VirtualDirectoryPoseView.cpp

示例8: FSClipboardAddPoses

uint32
FSClipboardAddPoses(const node_ref *directory, PoseList *list, uint32 moveMode,
	bool clearClipboard)
{
	uint32 refsAdded = 0;
	int32 listCount = list->CountItems();

	if (listCount == 0 || !be_clipboard->Lock())
		return 0;

	// update message to be send to all listeners
	BMessage updateMessage(kFSClipboardChanges);
	updateMessage.AddInt32("device", directory->device);
	updateMessage.AddInt64("directory", directory->node);
	updateMessage.AddBool("clearClipboard", clearClipboard);

	TClipboardNodeRef clipNode;
	clipNode.moveMode = moveMode;

	if (clearClipboard)
		be_clipboard->Clear();

	BMessage *clip = be_clipboard->Data();
	if (clip != NULL) {
		for (int32 index = 0; index < listCount; index++) {
			char refName[64], modeName[64];
			BPose *pose = (BPose *)list->ItemAt(index);
			Model *model = pose->TargetModel();
			const node_ref *node = model->NodeRef();

			BEntry entry;
			model->GetEntry(&entry);
			if (model->IsVolume()
				|| model->IsRoot()
				|| FSIsTrashDir(&entry)
				|| FSIsDeskDir(&entry))
				continue;

			MakeRefName(refName, node);
			MakeModeNameFromRefName(modeName, refName);

			if (clearClipboard) {
				if (clip->AddInt32(modeName, (int32)moveMode) == B_OK)
					if (clip->AddRef(refName, model->EntryRef()) == B_OK) {
						pose->SetClipboardMode(moveMode);

						clipNode.node = *node;
						updateMessage.AddData("tcnode", T_CLIPBOARD_NODE, &clipNode,
							sizeof(TClipboardNodeRef), true, listCount);

						refsAdded++;
					} else
						clip->RemoveName(modeName);
			} else {
				if (clip->ReplaceInt32(modeName, (int32)moveMode) == B_OK) {
					// replace old mode if entry already exists in clipboard
					if (clip->ReplaceRef(refName, model->EntryRef()) == B_OK) {
						pose->SetClipboardMode(moveMode);

						clipNode.node = *node;
						updateMessage.AddData("tcnode", T_CLIPBOARD_NODE, &clipNode,
							sizeof(TClipboardNodeRef), true, listCount);

						refsAdded++;
					} else {
						clip->RemoveName(modeName);
						
						clipNode.node = *node;
						clipNode.moveMode = kDelete;	// note removing node
						updateMessage.AddData("tcnode", T_CLIPBOARD_NODE, &clipNode,
							sizeof(TClipboardNodeRef), true, listCount);
						clipNode.moveMode = moveMode; // set it back to current value
					}
				} else {
					// add it if it doesn't exist
					if (clip->AddRef(refName, model->EntryRef()) == B_OK
						&& clip->AddInt32(modeName, (int32)moveMode) == B_OK) {
						pose->SetClipboardMode(moveMode);
						
						clipNode.node = *node;
						updateMessage.AddData("tcnode", T_CLIPBOARD_NODE, &clipNode,
							sizeof(TClipboardNodeRef), true, listCount);

						refsAdded++;
					} else {
						clip->RemoveName(modeName);
						clip->RemoveName(refName);
						// here notifying delete isn't needed as node didn't
						// exist in clipboard
					}
				}
			}
		}
		be_clipboard->Commit();
	}	
	be_clipboard->Unlock();

	BMessenger(kTrackerSignature).SendMessage(&updateMessage);
		// Tracker will notify all listeners

//.........这里部分代码省略.........
开发者ID:HaikuArchives,项目名称:OpenTracker,代码行数:101,代码来源:FSClipboard.cpp

示例9: process_refs

/*!
	\brief Tracker add-on entry
*/
extern "C" void
process_refs(entry_ref dir, BMessage* refs, void* /*reserved*/)
{
	status_t status;
	BAlert *alert;
	BMessenger msgr;
	BPoseView *view = NULL;
	BMessage poseViewBackup;
	BMessage poseViewColumnBackup;
	uint32 poseViewModeBackup;
	BString windowTitleBackup;

	refs->PrintToStream();
	
	status = refs->FindMessenger("TrackerViewToken", &msgr);
	if (status < B_OK) {
		Error(view, status);
		return;
	}

	status = B_ERROR;
	if (!msgr.LockTarget()) {
		Error(view, status);
		return;
	}

	status = B_BAD_HANDLER;
	view = dynamic_cast<BPoseView *>(msgr.Target(NULL));
	if (!view) {
		Error(view, status);
		return;
	}
	if (dynamic_cast<BWindow *>(view->Looper()) == NULL) {
		Error(view, status, true);
		return;
	}

	windowTitleBackup = view->Window()->Title();

	view->SaveColumnState(poseViewColumnBackup);
	view->SaveState(poseViewBackup);
	view->SetDragEnabled(false);
	view->SetSelectionRectEnabled(false);
	view->SetPoseEditing(false);
	poseViewModeBackup = view->ViewMode();
	

	view->SetViewMode(kIconMode);

	view->ShowBarberPole();


	view->UnlockLooper();



	alert = new BAlert("Error", "IconVader:\nClick on the icons to get points."
		"\nAvoid symlinks!", "OK");
	alert->SetFlags(alert->Flags() | B_CLOSE_ON_ESCAPE);
	alert->Go();


	int32 score = 0;
	int32 count = 300;
	while (count--) {
		status = B_ERROR;
		if (!msgr.LockTarget()) {
			Error(view, status);
			return;
		}

		BPose *pose;
		for (int32 i = 0; (pose = view->PoseAtIndex(i)); i++) {
			if (pose->IsSelected()) {
				if (pose->TargetModel()->IsFile())
					score++;
				if (pose->TargetModel()->IsDirectory())
					score+=2;
				if (pose->TargetModel()->IsSymLink())
					score-=10;
				pose->Select(false);
			}
#ifdef __HAIKU__
			BPoint location = pose->Location(view);
#else
			BPoint location = pose->Location();
#endif
			location.x += ((rand() % 20) - 10);
			location.y += ((rand() % 20) - 10);
#ifdef __HAIKU__
			pose->SetLocation(location, view);
#else
			pose->SetLocation(location);
#endif
		}

		view->CheckPoseVisibility();
//.........这里部分代码省略.........
开发者ID:Barrett17,项目名称:haiku-contacts-kit-old,代码行数:101,代码来源:IconVader.cpp


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