Ejemplo n.º 1
0
void AGScreen::LButtonDown (int x, int y)

//	LButtonDown
//
//	Handle left button down

	{
	int i;

	//	Convert to AGScreen coordinates

	POINT pt;
	pt.x = x - m_rcRect.left;
	pt.y = y - m_rcRect.top;

	//	Give it to the area under the pointer

	for (i = 0; i < GetAreaCount(); i++)
		{
		AGArea *pArea = GetArea(i);
		RECT rcArea = pArea->GetRect();

		if (pArea->IsVisible() 
				&& pArea->WantsMouseOver() 
				&& ::PtInRect(&rcArea, pt))
			{
			m_pMouseCapture = pArea;
			::SetCapture(m_hWnd);

			pArea->LButtonDown(pt.x, pt.y);
			break;
			}
		}
	}
Ejemplo n.º 2
0
void AGScreen::LButtonUp (int x, int y)

//	LButtonUp
//
//	Handle left button up

	{
	if (m_pMouseCapture)
		{
		//	Convert to screen coordinates

		POINT pt;
		pt.x = x - m_rcRect.left;
		pt.y = y - m_rcRect.top;

		//	Remember these values before we call LButtonUp because
		//	we may not have a valid screen after that.

		AGArea *pMouseCapture = m_pMouseCapture;
		::ReleaseCapture();
		m_pMouseCapture = NULL;

		pMouseCapture->LButtonUp(pt.x, pt.y);
		}
	}
Ejemplo n.º 3
0
bool CGFrameArea::LButtonDown (int x, int y)

//	LButtonDown
//
//	Handle left button down

	{
	int i;

	POINT pt = { x, y };

	//	Give it to the area under the pointer

	for (i = 0; i < GetAreaCount(); i++)
		{
		AGArea *pArea = GetArea(i);
		RECT rcArea = pArea->GetRect();

		if (pArea->IsVisible()
				&& pArea->WantsMouseOver() 
				&& ::PtInRect(&rcArea, pt))
			{
			m_pMouseCapture = pArea;

			pArea->LButtonDown(x, y);
			return true;
			}
		}

	return false;
	}
Ejemplo n.º 4
0
void CGFrameArea::Paint (CG32bitImage &Dest, const RECT &rcRect)

//	Paint
//
//	Paint the whole area.
//
//	rcRect is the rect to which this area should be painted.

	{
	for (int i = 0; i < GetAreaCount(); i++)
		{
		AGArea *pArea = GetArea(i);

		RECT rcAreaRelativeToFrame = pArea->GetRect();
		::OffsetRect(&rcAreaRelativeToFrame, -(GetRect().left), -(GetRect().top));

		RECT rcAreaRelativeToDest = rcAreaRelativeToFrame;
		::OffsetRect(&rcAreaRelativeToDest, rcRect.left, rcRect.top);

		RECT rcIntersect;
		if (pArea->IsVisible()
				&& ::IntersectRect(&rcIntersect, &rcRect, &rcAreaRelativeToDest))
			{
			pArea->Paint(Dest, rcAreaRelativeToDest);
			}
		}
	}
Ejemplo n.º 5
0
void AGScreen::LButtonDoubleClick (int x, int y)

//	LButtonDoubleClick
//
//	Handle left button double click

	{
	int i;

	//	Convert to AGScreen coordinates

	POINT pt;
	pt.x = x - m_rcRect.left;
	pt.y = y - m_rcRect.top;

	//	Give it to the area under the pointer

	for (i = 0; i < GetAreaCount(); i++)
		{
		AGArea *pArea = GetArea(i);
		RECT rcArea = pArea->GetRect();

		if (pArea->IsVisible() 
				&& pArea->WantsMouseOver() 
				&& ::PtInRect(&rcArea, pt))
			{
			m_pMouseCapture = pArea;
			SDL_WM_GrabInput(SDL_GRAB_ON);

			pArea->LButtonDoubleClick(pt.x, pt.y);
			break;
			}
		}
	}
Ejemplo n.º 6
0
void CGFrameArea::Update (void)

//	Update
//
//	Update the area

	{
	for (int i = 0; i < GetAreaCount(); i++)
		{
		AGArea *pArea = GetArea(i);
		pArea->Update();
		}
	}
Ejemplo n.º 7
0
void AGScreen::Update (void)

//	Update
//
//	Update the screen

	{
	int i;

	for (i = 0; i < GetAreaCount(); i++)
		{
		AGArea *pArea = GetArea(i);
		pArea->Update();
		}
	}
Ejemplo n.º 8
0
AGArea *AGScreen::FindArea (DWORD dwTag)

//	FindArea
//
//	Finds area by tag. Returns NULL if do not find the area

	{
	for (int i = 0; i < GetAreaCount(); i++)
		{
		AGArea *pArea = GetArea(i);
		if (pArea->GetTag() == dwTag)
			return pArea;
		}

	return NULL;
	}
Ejemplo n.º 9
0
void CGFrameArea::LButtonUp (int x, int y)

//	LButtonUp
//
//	Handle left button up

	{
	if (m_pMouseCapture)
		{
		//	Remember these values before we call LButtonUp because
		//	we may not have a valid screen after that.

		AGArea *pMouseCapture = m_pMouseCapture;
		m_pMouseCapture = NULL;

		pMouseCapture->LButtonUp(x, y);
		}
	}
Ejemplo n.º 10
0
AGArea *AGScreen::HitTest (const POINT &pt)

//	HitTest
//
//	Returns the area at the given point (in local screen coords)

	{
	int i;

	for (i = 0; i < GetAreaCount(); i++)
		{
		AGArea *pArea = GetArea(i);
		RECT rcArea = pArea->GetRect();

		if (pArea->IsVisible() 
				&& pArea->WantsMouseOver() 
				&& ::PtInRect(&rcArea, pt))
			return pArea;
		}

	return NULL;
	}
Ejemplo n.º 11
0
void AGScreen::Paint (CG16bitImage &Dest)

//	Paint
//
//	Paint the whole screen.
//
//	Dest is the entire display area; its origin is 0,0.

	{
	if (!IsRectEmpty(&m_rcInvalid))
		{
		int i;

		//	Convert to Window coordinates

		RECT rcUpdate = m_rcInvalid;
		OffsetRect(&rcUpdate, m_rcRect.left, m_rcRect.top);

		//	Clip appropriately. Note that Dest is always in
		//	window coordinates.

		Dest.SetClipRect(rcUpdate);

		//	Blank the screen

		Dest.Fill(rcUpdate.left, rcUpdate.top, RectWidth(rcUpdate), RectHeight(rcUpdate), CG16bitImage::RGBValue(0,0,0));

		//	Let each area paint

		for (i = 0; i < GetAreaCount(); i++)
			{
			AGArea *pArea = GetArea(i);

			//	m_rcInvalid is in Screen coordinates, and so is the rect
			//	for each area. The intersection is the portion of the
			//	area's rect that is invalid.

			RECT rcIntersect;
			if (pArea->IsVisible()
					&& ::IntersectRect(&rcIntersect, &m_rcInvalid, &pArea->GetRect()))
				{
				//	Calculate the rect of the area relative to the Window

				RECT rcArea = pArea->GetRect();
				OffsetRect(&rcArea, m_rcRect.left, m_rcRect.top);

				//	Clip appropriately

				OffsetRect(&rcIntersect, m_rcRect.left, m_rcRect.top);
				Dest.SetClipRect(rcIntersect);

				//	Paint

				pArea->Paint(Dest, rcArea);
				}
			}

		//	Reset the invalid rect

		ZeroMemory(&m_rcInvalid, sizeof(m_rcInvalid));
		Dest.ResetClipRect();
		}
	}
Ejemplo n.º 12
0
void CGFrameArea::MouseMove (int x, int y)

//	MouseMove
//
//	Handle mouse move

	{
	int i;

	POINT pt = { x, y };

	if (m_pMouseCapture)
		{
		m_pMouseCapture->MouseMove(x, y);

		//	Check to see if we've entered the area

		if (m_pMouseOver == NULL)
			{
			if (::PtInRect(&m_pMouseCapture->GetRect(), pt))
				{
				m_pMouseCapture->MouseEnter();
				m_pMouseOver = m_pMouseCapture;
				}
			}
		else
			{
			ASSERT(m_pMouseOver == m_pMouseCapture);

			if (!::PtInRect(&m_pMouseCapture->GetRect(), pt))
				{
				m_pMouseCapture->MouseLeave();
				m_pMouseOver = NULL;
				}
			}
		}
	else
		{
		//	Are we still over the same area?

		if (m_pMouseOver && ::PtInRect(&m_pMouseOver->GetRect(), pt))
			{
			m_pMouseOver->MouseMove(x, y);
			}

		//	If not, find out what area we're over

		else
			{
			//	Tell the old area that we're done

			if (m_pMouseOver)
				m_pMouseOver->MouseLeave();

			//	Figure out which area has the mouse now

			AGArea *pNewMouseOver = NULL;
			for (i = 0; i < GetAreaCount(); i++)
				{
				AGArea *pArea = GetArea(i);
				RECT rcArea = pArea->GetRect();

				if (pArea->IsVisible()
						&& pArea->WantsMouseOver() 
						&& ::PtInRect(&rcArea, pt))
					{
					pNewMouseOver = pArea;
					break;
					}
				}

			//	Tell the new area that it has the mouse

			m_pMouseOver = pNewMouseOver;
			if (m_pMouseOver)
				{
				m_pMouseOver->MouseMove(pt.x, pt.y);
				m_pMouseOver->MouseEnter();
				}
			}
		}
	}