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


C++ BMessenger::Target方法代码示例

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


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

示例1: _handleAddObserver

void ObservableHandler::_handleAddObserver(
	BMessage*								message) {

#if DEBUG
	BLooper* l = Looper();
	ASSERT(l);
	ASSERT(l->IsLocked());
#endif
	BMessage reply;

	BMessenger observer;
	status_t err = message->FindMessenger(
		"observer", &observer);
	if(err < B_OK) {
		PRINT((
			"* ObservableHandler::_handleAddObserver(): no observer specified!\n"));
		// send reply? +++++
		return;
	}

	if(m_released) {
		// already quitting
		reply.what = M_BAD_TARGET;
		reply.AddMessenger("target", BMessenger(this));
		reply.AddMessenger("observer", observer);
		message->SendReply(&reply);
		
		return;
	}
	else if(IndexOfTarget(observer.Target(0)) != -1) {
		// observer already added
		reply.what = M_BAD_OBSERVER;
		reply.AddMessenger("target", BMessenger(this));
		reply.AddMessenger("observer", observer);
		message->SendReply(&reply);
		
		return;
	}	

	// valid observer given

	// add it
	err = AddTarget(observer.Target(0));
	ASSERT(err == B_OK);

	// call hook
	observerAdded(observer);
}
开发者ID:AmirAbrams,项目名称:haiku,代码行数:48,代码来源:ObservableHandler.cpp

示例2: SetTargetForItems

// Include the following version of SetTargetForItems() to eliminate
// hidden polymorphism warning. Should be correct, but is unused and untested.
status_t QueryMenu::SetTargetForItems(BMessenger messenger)
{
	if (messenger.IsTargetLocal()) {
		BLooper* ignore; // don't care what value this gets
		fTargetHandler = messenger.Target(&ignore);
		return BMenu::SetTargetForItems(messenger);
	} else {
		return B_ERROR;
	}
}
开发者ID:HaikuArchives,项目名称:OpenTracker,代码行数:12,代码来源:QueryMenu.cpp

示例3:

/*!	\brief Subscribes a target to node and/or mount watching, or unsubscribes
		   it from node watching.

	Depending of \a flags the action performed by this function varies:
	- \a flags is \c 0: The target is unsubscribed from watching the node.
	  \a node must not be \c NULL in this case.
	- \a flags contains \c B_WATCH_MOUNT: The target is subscribed to mount
	  watching.
	- \a flags contains at least one of \c B_WATCH_NAME, \c B_WATCH_STAT,
	  \c B_WATCH_ATTR, or \c B_WATCH_DIRECTORY: The target is subscribed to
	  watching the specified aspects of the node. \a node must not be \c NULL
	  in this case.

	Note, that the latter two cases are not mutual exlusive, i.e. mount and
	node watching can be requested with a single call.

	\param node node_ref referring to the node to be watched. May be \c NULL,
		   if only mount watching is requested.
	\param flags Flags indicating the actions to be performed.
	\param target Messenger referring to the target. Must be valid.
	\return \c B_OK, if everything went fine, another error code otherwise.
*/
status_t
watch_node(const node_ref *node, uint32 flags, BMessenger target)
{
	status_t error = (target.IsValid() ? B_OK : B_BAD_VALUE);
	if (error == B_OK) {
		BLooper *looper = NULL;
		BHandler *handler = target.Target(&looper);
		error = watch_node(node, flags, handler, looper);
	}
	return error;
}
开发者ID:Ithamar,项目名称:cosmoe,代码行数:33,代码来源:NodeMonitor.cpp

示例4: MouseWatcher

int32 MouseWatcher(void* data)
{
	BMessenger* TheMessenger = (BMessenger*)data;
	BPoint PreviousPos;
	uint32 PreviousButtons;
	bool FirstCheck = true;
	BMessage MessageToSend;
	MessageToSend.AddPoint("where",BPoint(0,0));
	MessageToSend.AddInt32("buttons",0);
	MessageToSend.AddInt32("modifiers",0);
	while(true)
	{
		if (!TheMessenger->LockTarget())
		{
			delete TheMessenger;
			return 0;			// window is dead so exit
		}
		BLooper *TheLooper;
		BView* TheView = (BView*)TheMessenger->Target(&TheLooper);
		BPoint Where;
		uint32 Buttons;
		TheView->GetMouse(&Where,&Buttons,false);
		if(FirstCheck)
		{
			PreviousPos = Where;
			PreviousButtons = Buttons;
			FirstCheck = false;
		}
		bool Send = false;
		if(Buttons != PreviousButtons || Buttons == 0 || Where != PreviousPos)
		{
			if(Buttons == 0)
				MessageToSend.what = MW_MOUSE_UP;
			else if(Buttons != PreviousButtons)
				MessageToSend.what = MW_MOUSE_DOWN;
			else
				MessageToSend.what = MW_MOUSE_MOVED;
			MessageToSend.ReplacePoint("where",Where);
			MessageToSend.ReplaceInt32("buttons",Buttons);
			MessageToSend.ReplaceInt32("modifiers",modifiers());
			Send = true;
		}
		TheLooper->Unlock();
		if(Send)
			TheMessenger->SendMessage(&MessageToSend);
		if(Buttons == 0)
		{
			//Button was released
			delete TheMessenger;
			return 0;
		}
		snooze(50000);
	}
}
开发者ID:mariuz,项目名称:haiku,代码行数:54,代码来源:MouseWatcher.cpp

示例5: CallerFrame

static BRect CallerFrame(BMessenger& caller)
{
	BRect rect;
	if (caller.LockTarget())
	{
		BLooper* looper;
		caller.Target(&looper);
		BWindow* window = dynamic_cast<BWindow*>(looper);
		if (window)
			rect = window->Frame();
		looper->Unlock();
	}
	return rect;
}
开发者ID:HaikuArchives,项目名称:Pe,代码行数:14,代码来源:HDialog.cpp

示例6: UpdateBar

void DCCConnect::UpdateBar(const BMessenger& msgr, int readSize, int cps, uint32 size, bool update)
{
	BMessage msg(B_UPDATE_STATUS_BAR);

	if (update) {
		char text[128];

		sprintf(text, "%.1f", size / 1024.0);
		msg.AddString("trailing_text", text);

		sprintf(text, "%d", cps);
		msg.AddString("text", text);
	}

	msg.AddFloat("delta", readSize);
	BLooper* looper(NULL);
	DCCConnect* transferView((DCCConnect*)msgr.Target(&looper));
	if ((looper != NULL) && (transferView != NULL)) looper->PostMessage(&msg, transferView->fBar);
}
开发者ID:carriercomm,项目名称:Vision,代码行数:19,代码来源:DCCConnect.cpp

示例7: _handleRemoveObserver

void ObservableHandler::_handleRemoveObserver(
	BMessage*								message) {

#if DEBUG
	BLooper* l = Looper();
	ASSERT(l);
	ASSERT(l->IsLocked());
#endif
	BMessage reply;

	BMessenger observer;
	status_t err = message->FindMessenger(
		"observer", &observer);
	if(err < B_OK) {
		PRINT((
			"* ObservableHandler::_handleRemoveObserver(): no observer specified!\n"));
		// send reply? +++++
		return;
	}

	int32 index = IndexOfTarget(observer.Target(0));
	if(index == -1) {
		reply.what = M_BAD_OBSERVER;
		
		reply.AddMessenger("target", BMessenger(this));
		reply.AddMessenger("observer", observer);
		message->SendReply(&reply);
		return;
	}
	
	// valid observer given; remove it & call notification hook
	RemoveTarget(index);
	observerRemoved(observer);
	
	// time to shut down?
	if(m_released && !CountTargets()) {
		releaseComplete();
		delete this; // BOOM!
	}
}
开发者ID:AmirAbrams,项目名称:haiku,代码行数:40,代码来源:ObservableHandler.cpp

示例8: OpenAddWindow

void _OwqList::OpenAddWindow(BMessage* row)
{
	if( !mAddWin.IsValid() ) {
		_OwqWindow*	win = new _OwqWindow( BMessenger(this), row );
		if( win ) {
			mAddWin = BMessenger(win);
			win->Show();
		}
	} else {
		BHandler*		target;
		BLooper*		looper;
		if( (target = mAddWin.Target(&looper)) != 0 ) {
			_OwqWindow*	win = dynamic_cast<_OwqWindow*>( target );
			if( win ) {
				if( row && win->Lock() ) {
					win->MessageReceived( row );
					win->Unlock();
				}
				win->Activate( true );
			}
		}
	}
}
开发者ID:dtbinh,项目名称:Sequitur,代码行数:23,代码来源:SeqPrefWin.cpp

示例9: MouseDragOrPopupWatcher

int32 MouseDragOrPopupWatcher(void* data)
{
	BMessenger* TheMessenger = (BMessenger*)data;
	BPoint StartPos;
	uint32 StartButtons = 0;
	bigtime_t StartTime = 0;
	bool FirstCheck = true;
	BMessage MessageToSend;
	MessageToSend.AddPoint("where",BPoint(0,0));
	MessageToSend.AddInt32("buttons",0);
	MessageToSend.AddInt32("modifiers",0);
	bigtime_t PopupTime;
	if(get_click_speed(&PopupTime) != B_OK)
		return 0;
	PopupTime *= 2;
	while(true)
	{
		if (!TheMessenger->LockTarget())
		{
			delete TheMessenger;
			return 0;			// window is dead so exit
		}
		BLooper *TheLooper;
		BView* TheView = (BView*)TheMessenger->Target(&TheLooper);
		BPoint Where;
		uint32 Buttons;
		bigtime_t Time = system_time();
		TheView->GetMouse(&Where,&Buttons,false);
		if(FirstCheck)
		{
			StartPos = Where;
			StartButtons = Buttons;
			StartTime = Time;
			FirstCheck = false;
		}
		bool Send = false;
		if(Buttons == 0 || Buttons != StartButtons)
		{
			//Changed or released
			MessageToSend.what = MW_MOUSE_CLICK;
			Send = true;
		}
		else if(Where.x < StartPos.x-1.0 || Where.x > StartPos.x+1.0 ||
			Where.y < StartPos.y-1.0 || Where.y > StartPos.y+1.0)
		{
			MessageToSend.what = MW_MOUSE_DRAG;
			Send = true;
		}
		else if(Time >= StartTime + PopupTime)
		{
			MessageToSend.what = MW_MOUSE_POPUP;
			Send = true;
		}
		TheLooper->Unlock();
		if(Send)
		{
			MessageToSend.ReplacePoint("where",StartPos);
			MessageToSend.ReplaceInt32("buttons",Buttons);
			MessageToSend.ReplaceInt32("modifiers",modifiers());
			TheMessenger->SendMessage(&MessageToSend);
			delete TheMessenger;
			return 0;
		}
		snooze(50000);
	}
}
开发者ID:HaikuArchives,项目名称:BePhoneBook,代码行数:66,代码来源:MouseDragOrPopupWatcher.cpp

示例10:

/*
	BHandler *Target(BLooper **looper) const
	@case 1			this is uninitialized, looper is NULL
	@results		should return NULL.
 */
void TargetTester::TargetTest1()
{
	BMessenger messenger;
	CHK(messenger.Target(NULL) == NULL);
}
开发者ID:SummerSnail2014,项目名称:haiku,代码行数:10,代码来源:TargetTester.cpp

示例11: str

/*!
	\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


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