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


C++ Dialog::GetViewport方法代码示例

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


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

示例1: MouseInput

bool Screen::MouseInput(int32_t iButton, int32_t iX, int32_t iY, DWORD dwKeyParam, Dialog *pForDlg, class C4Viewport *pForVP)
	{
	// help mode and button pressed: Abort help and discard button
	if (Game.MouseControl.IsHelp())
		{
		switch (iButton)
			{
			case C4MC_Button_None:
				// just movement
				break;
			case C4MC_Button_LeftDown:
			case C4MC_Button_RightDown:
				// special for left/right down: Just ignore them, but don't stop help yet
				// help should be stopped on button-up, so these won't be processed
				iButton = C4MC_Button_None;
				break;
			default:
				// buttons stop help
				Game.MouseControl.AbortHelp();
				iButton = C4MC_Button_None;
				break;
			}
		}
	// forward to mouse
	Mouse.Input(iButton, iX, iY, dwKeyParam);
	// dragging
	if (Mouse.pDragElement)
		{
		int32_t iX2=iX, iY2=iY;
		Mouse.pDragElement->ScreenPos2ClientPos(iX2, iY2);
		if (!Mouse.IsLDown())
			{
			// stop dragging
			Mouse.pDragElement->StopDragging(Mouse, iX2, iY2, dwKeyParam);
			Mouse.pDragElement = NULL;
			}
		else
			{
			// continue dragging
			Mouse.pDragElement->DoDragging(Mouse, iX2, iY2, dwKeyParam);
			}
		}
	// backup previous MouseOver-element
	Mouse.pPrevMouseOverElement = Mouse.pMouseOverElement;
	Mouse.pMouseOverElement = NULL;
	bool fProcessed = false;
	// active context menu?
	if (!pForVP && pContext && pContext->CtxMouseInput(Mouse, iButton, iX, iY, dwKeyParam))
		{
		// processed by context menu: OK!
		}
	// otherwise: active dlg and inside screen? (or direct forward to specific dlg/viewport dlg)
	else if (rcBounds.Contains(iX, iY) || pForDlg || pForVP)
		{
		// context menu open but mouse down command issued? close context then
		if (pContext && (iButton == C4MC_Button_LeftDown || iButton == C4MC_Button_RightDown))
			AbortContext(true);
		// get client pos
		if (!pForDlg && !pForVP)
			{
			C4Rect &rcClientArea = GetClientRect();
			iX -= rcClientArea.x; iY -= rcClientArea.y;
			}
		// exclusive mode: process active dialog only
		if (IsExclusive() && !pForDlg && !pForVP)
			{
			if (pActiveDlg && pActiveDlg->IsVisible() && !pActiveDlg->IsFading())
				{
				// bounds check to dlg: only if not dragging
				C4Rect &rcDlgBounds = pActiveDlg->GetBounds();
				if (Mouse.IsLDown() || rcDlgBounds.Contains(iX, iY))
					// forward to active dialog
					pActiveDlg->MouseInput(Mouse, iButton, iX - rcDlgBounds.x, iY - rcDlgBounds.y, dwKeyParam);
				else
					Mouse.pMouseOverElement = NULL;
				}
			else
				// outside dialog: own handling (for screen context menu)
				Window::MouseInput(Mouse, iButton, iX, iY, dwKeyParam);
			}
		else
			{
			// non-exclusive mode: process all dialogs; make them active on left-click
			Dialog *pDlg;
			for (Element *pEl = pLast; pEl; pEl = pEl->GetPrev())
				if (pDlg = pEl->GetDlg())
					if (pDlg->IsShown())
						{
						// if specified: process specified dlg only
						if (pForDlg && pDlg != pForDlg) continue;
						// if specified: process specified viewport only
						bool fIsExternalDrawDialog = pDlg->IsExternalDrawDialog();
						C4Viewport *pVP = fIsExternalDrawDialog ? pDlg->GetViewport() : NULL;
						if (pForVP && pForVP != pVP) continue;
						// calc offset
						C4Rect &rcDlgBounds = pDlg->GetBounds();
						int32_t iOffX=0, iOffY=0;
						// special handling for viewport dialogs
						if (fIsExternalDrawDialog)
							{
//.........这里部分代码省略.........
开发者ID:lluchs,项目名称:clonk-rage,代码行数:101,代码来源:C4Gui.cpp


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