Esempio n. 1
0
void ALW_GetWndPosition(int& nX, int& nY, int nWidth, int nHeight,
						bool bUseInputParamPos/* = false*/,
						bool bIgnoreCursorPos/* = false*/)
{
	int nSWidth, nSHeight;
	if (bUseInputParamPos == false)
		Wnd_GetCursorPos(&nX, &nY);
	Wnd_GetScreenSize(nSWidth, nSHeight);

	nX -= nWidth / 2;
	if (nX + nWidth > nSWidth)
		nX = nSWidth - nWidth;
	if (nX < 0)
		nX = 0;

	int nCentrePos;
	if (bIgnoreCursorPos == false)
		nCentrePos = (nSHeight - CURSOR_HEIGHT) / 2;
	else
		nCentrePos = nSHeight / 2;
	if (nY > nCentrePos)
		nY -= nHeight;
	else if (bIgnoreCursorPos == false)
		nY += CURSOR_HEIGHT;

	if (nY + nHeight > nSHeight)
		nY = nSHeight - nHeight;
	if (nY < 0)
		nY = 0;
}
Esempio n. 2
0
//--------------------------------------------------------------------------
//	功能:响应鼠标左键按下移动的操作
//--------------------------------------------------------------------------
void KWndWindow::OnMoveWnd()
{
	int x, y;
	Wnd_GetCursorPos(&x, &y);
	if (x != m_nLastMouseHoldPosX || y != m_nLastMouseHoldPosY)
	{
		x -= m_nLastMouseHoldPosX;
		y -= m_nLastMouseHoldPosY;
		SetPosition(x + m_Left, y + m_Top);
		m_nLastMouseHoldPosX += x;
		m_nLastMouseHoldPosY += y;

		x = ((x & 0xffff) | ((y & 0xffff) << 16));
		if (x && m_pParentWnd)
		{
			m_pParentWnd->WndProc(WND_N_CHILD_MOVE, (unsigned int)(KWndWindow*)this, x);
		}
	}
}
Esempio n. 3
0
//--------------------------------------------------------------------------
//	功能:设置容纳的对象
//--------------------------------------------------------------------------
void KWndObjectBox::HoldObject(unsigned int uGenre, unsigned int uId, int nDataW, int nDataH)
{
	m_Object.uGenre = uGenre;
	m_Object.uId = uId;
	m_Object.DataW = nDataW;
	m_Object.DataH = nDataH;

	if (g_MouseOver.IsMoseHoverWndObj(this, 0))
	{
		if (m_Object.uGenre != CGOG_NOTHING)
		{
			int x, y;
			Wnd_GetCursorPos(&x, &y);
			SetMouseHoverObjectDesc(this, 0, m_Object.uGenre,
				m_Object.uId, m_nContainerId, x, y);
		}
		else
		{
			g_MouseOver.CancelMouseHoverInfo();
		}
	}
}
Esempio n. 4
0
void KWndWindow::PaintDebugInfo()
{
	char	szInfo[128];
	szInfo[0] = 0;
	int nInfoLen = 0;

	int nOld = WND_SHOW_DEBUG_FRAME_TEXT;
	WND_SHOW_DEBUG_FRAME_TEXT = true;
	KWndWindow::PaintWindow();
	WND_SHOW_DEBUG_FRAME_TEXT = nOld;

#ifdef _DEBUG
	sprintf(szInfo, "Name:%s, Pos:%d,%d,Size:%d,%d", m_Caption,
		m_nAbsoluteLeft, m_nAbsoluteTop, m_Width, m_Height);
	nInfoLen = strlen(szInfo);
#else
	sprintf(szInfo, "Pos:%d,%d,Size:%d,%d", m_nAbsoluteLeft, m_nAbsoluteTop, m_Width, m_Height);
	nInfoLen = strlen(szInfo);
#endif
	if (m_Style & WND_S_SIZE_WITH_ALL_CHILD)
	{
		RECT	rc;
		GetAllChildLayoutRect(&rc);
		sprintf(&szInfo[nInfoLen], ",Rect:%d,%d-%d,%d", rc.left, rc.top,
			rc.right, rc.bottom);
		nInfoLen = strlen(szInfo);
	}
	int x, y, w, h;
	Wnd_GetCursorPos(&x, &y);
	Wnd_GetScreenSize(w, h);
	if (x + nInfoLen * 6  + 24 > w)
		x = w - nInfoLen * 6 - 24;
	if (y + 25 > h)
		y = h - 13;
	else
		y += 12;
	g_pRepresentShell->OutputText(12, szInfo, nInfoLen, x, y, 0xFFFF0000,
		0, TEXT_IN_SINGLE_PLANE_COORD, 0xffffffff);
}