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


C++ BView::GetMouse方法代码示例

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


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

示例1: color_tear_drag

int32 color_tear_drag (void *data)
{
	colorTearInfo *tearInfo = (colorTearInfo *) data;
	uint32 buttons = 1;
	BPoint point;
	ColorMenu *menu = tearInfo->parent;
	BRect place = tearInfo->dragRect;
	BView *view = tearInfo->someView;
	// It might seem a good idea to use `menu' as the view, but
	// this gave errors: `Method requires owner but doesn't have one'.
	delete tearInfo;	// The caller doesn't do this (race condition otherwise)

	// printf ("Entering loop; view = %p\n", view);
	while (buttons)
	{
		view->Window()->Lock();
		view->GetMouse (&point, &buttons);
		view->Window()->Unlock();
		snooze (50000);
	}
	// printf ("Exited loop\n");
	view->Window()->Lock();
	point = view->ConvertToScreen (point);
	view->Window()->Unlock();

	// printf ("Released at (%.0f, %.0f)\n", point.x, point.y);
	place.OffsetTo (point);
	
	menu->getParent()->lock->Lock();
	menu->TearDone (place, !menu->getParent()->MenuWinOnScreen);
	menu->getParent()->lock->Unlock();

	return B_NO_ERROR;
}
开发者ID:gedrin,项目名称:Becasso,代码行数:34,代码来源:ColorMenu.cpp

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

示例3: app

// ---------------------------------------------------------------
// main
//
// Creates a BWindow for displaying info about the BMPTranslator
//
// Preconditions:
//
// Parameters:
//
// Postconditions:
//
// Returns:
// ---------------------------------------------------------------
int
main()
{
	BApplication app("application/x-vnd.obos-bmp-translator");
	BMPTranslator *ptranslator = new BMPTranslator;
	BView *view = NULL;
	BRect rect(0, 0, 225, 175);
	if (ptranslator->MakeConfigurationView(NULL, &view, &rect)) {
		BAlert *err = new BAlert("Error",
			"Unable to create the BMPTranslator view.", "OK");
		err->Go();
		return 1;
	}
	// release the translator even though I never really used it anyway
	ptranslator->Release();
	ptranslator = NULL;

	BMPWindow *wnd = new BMPWindow(rect);
	view->ResizeTo(rect.Width(), rect.Height());
	wnd->AddChild(view);
	BPoint wndpt = B_ORIGIN;
	{
		BScreen scrn;
		BRect frame = scrn.Frame();
		frame.InsetBy(10, 23);
		// if the point is outside of the screen frame,
		// use the mouse location to find a better point
		if (!frame.Contains(wndpt)) {
			uint32 dummy;
			view->GetMouse(&wndpt, &dummy, false);
			wndpt.x -= rect.Width() / 2;
			wndpt.y -= rect.Height() / 2;
			// clamp location to screen
			if (wndpt.x < frame.left)
				wndpt.x = frame.left;
			if (wndpt.y < frame.top)
				wndpt.y = frame.top;
			if (wndpt.x > frame.right)
				wndpt.x = frame.right;
			if (wndpt.y > frame.bottom)
				wndpt.y = frame.bottom;
		}
	}
	wnd->MoveTo(wndpt);
	wnd->Show();
	app.Run();

	return 0;
}
开发者ID:Ithamar,项目名称:cosmoe,代码行数:62,代码来源:BMPMain.cpp

示例4: BAlert

status_t
LaunchTranslatorWindow(BTranslator *translator, const char *title, BRect rect)
{
	BView *view = NULL;
	if (translator->MakeConfigurationView(NULL, &view, &rect)) {
		BAlert *err = new BAlert(B_TRANSLATE("Error"),
			B_TRANSLATE("Unable to create the view."), B_TRANSLATE("OK"));
		err->SetFlags(err->Flags() | B_CLOSE_ON_ESCAPE);
		err->Go();
		return B_ERROR;
	}
	// release the translator even though I never really used it anyway
	translator->Release();
	translator = NULL;

	TranslatorWindow *wnd = new TranslatorWindow(rect, title);
	wnd->AddChild(view);
	BPoint wndpt = B_ORIGIN;
	{
		BScreen scrn;
		BRect frame = scrn.Frame();
		frame.InsetBy(10, 23);
		// if the point is outside of the screen frame,
		// use the mouse location to find a better point
		if (!frame.Contains(wndpt)) {
			uint32 dummy;
			view->GetMouse(&wndpt, &dummy, false);
			wndpt.x -= rect.Width() / 2;
			wndpt.y -= rect.Height() / 2;
			// clamp location to screen
			if (wndpt.x < frame.left)
				wndpt.x = frame.left;
			if (wndpt.y < frame.top)
				wndpt.y = frame.top;
			if (wndpt.x > frame.right)
				wndpt.x = frame.right;
			if (wndpt.y > frame.bottom)
				wndpt.y = frame.bottom;
		}
	}
	wnd->MoveTo(wndpt);
	wnd->Show();
	
	return B_OK;
}
开发者ID:AmirAbrams,项目名称:haiku,代码行数:45,代码来源:TranslatorWindow.cpp

示例5: BWindow

/*!	Returns the current mouse position in screen coordinates.
	Since there is no method to retrieve this in the Be API without a view,
	this looks a bit more complicated.
*/
static BPoint
mouse_position()
{
	BWindow* window = new BWindow(BRect(-1000, -1000, -900, -900), "mouse",
		B_NO_BORDER_WINDOW_LOOK, B_NORMAL_WINDOW_FEEL,
		B_AVOID_FRONT | B_AVOID_FOCUS);
	BView* view = new BView(window->Bounds(), "mouse", B_FOLLOW_ALL, 0);
	window->AddChild(view);
	window->Run();

	window->Lock();

	BPoint position;
	uint32 buttons;
	view->GetMouse(&position, &buttons);
	view->ConvertToScreen(&position);

	window->Quit();

	return position;
}
开发者ID:mmanley,项目名称:Antares,代码行数:25,代码来源:MarkAs.cpp

示例6: app

int
main()
{
	BApplication app("application/x-vnd.Haiku-PPMTranslator");
	BView * v = NULL;
	BRect r(0, 0, 1, 1);
	if (MakeConfig(NULL, &v, &r)) {
		BAlert * err = new BAlert("Error", 
			B_TRANSLATE("Something is wrong with the PPMTranslator!"), 
			B_TRANSLATE("OK"));
		err->Go();
		return 1;
	}
	PPMWindow *w = new PPMWindow(r);
	v->ResizeTo(r.Width(), r.Height());
	w->AddChild(v);
	BPoint o = get_window_origin();
	{
		BScreen scrn;
		BRect f = scrn.Frame();
		f.InsetBy(10,23);
		/* if not in a good place, start where the cursor is */
		if (!f.Contains(o)) {
			uint32 i;
			v->GetMouse(&o, &i, false);
			o.x -= r.Width()/2;
			o.y -= r.Height()/2;
			/* clamp location to screen */
			if (o.x < f.left) o.x = f.left;
			if (o.y < f.top) o.y = f.top;
			if (o.x > f.right) o.x = f.right;
			if (o.y > f.bottom) o.y = f.bottom;
		}
	}
	w->MoveTo(o);
	w->Show();
	app.Run();
	return 0;
}
开发者ID:mmadia,项目名称:Haiku-services-branch,代码行数:39,代码来源:PPMMain.cpp

示例7: r


//.........这里部分代码省略.........
					bMsg->FindRect("dest", &destRect);
					if(srcRect.IsValid() == false || destRect.IsValid() == false) break;
					bMsg->FindPointer("clipping", (void**)&clipping); 

					BRegion beRegion;
					__etk_convert_region(clipping, &beRegion, fTopView->Bounds());
					fTopView->ConstrainClippingRegion(&beRegion);
					fTopView->DrawBitmap(bitmap, srcRect, destRect);
				}
				break;

			case ETK_BEOS_GRAB_MOUSE:
			case ETK_BEOS_UNGRAB_MOUSE:
				{
					uint32 options = (what == ETK_BEOS_GRAB_MOUSE ? B_LOCK_WINDOW_FOCUS : 0);
					if(fTopView->SetEventMask(B_POINTER_EVENTS, options) != B_OK) break;
					bMsg->AddBool("state", what == ETK_BEOS_GRAB_MOUSE);
				}
				break;

			case ETK_BEOS_GRAB_KEYBOARD:
			case ETK_BEOS_UNGRAB_KEYBOARD:
				{
					uint32 options = (what == ETK_BEOS_GRAB_KEYBOARD ? B_LOCK_WINDOW_FOCUS : 0);
					if(fTopView->SetEventMask(B_KEYBOARD_EVENTS, options) != B_OK) break;
					bMsg->AddBool("state", what == ETK_BEOS_GRAB_KEYBOARD);
				}
				break;

			case ETK_BEOS_QUERY_MOUSE:
				{
					BPoint pt;
					uint32 btns = 0;
					fTopView->GetMouse(&pt, &btns, false);
					bMsg->AddInt32("x", (int32)pt.x);
					bMsg->AddInt32("y", (int32)pt.y);
					bMsg->AddInt32("buttons", (int32)btns);
				}
				break;

			case ETK_BEOS_SET_SIZE_LIMITS:
				{
					BRect r;
					if(bMsg->FindRect("limits", &r) != B_OK) break;
					SetSizeLimits(r.left, r.right, r.top, r.bottom);
					bMsg->AddBool("done", true);
				}
				break;

			case ETK_BEOS_GET_SIZE_LIMITS:
				{
					BRect r(-1, -1, -1, -1);
					GetSizeLimits(&(r.left), &(r.right), &(r.top), &(r.bottom));
					bMsg->AddRect("limits", r);
				}
				break;

			default:
				handled = false;
				break;
		}

		if(handled)
		{
			BMessage aMsg(*bMsg);
			bMsg->SendReply(&aMsg);
开发者ID:D-os,项目名称:EasyToolkitAndExtension,代码行数:67,代码来源:etk-window.cpp

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


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