Exemplo n.º 1
0
void CText::Layout(SInt2 sPosition, SInt2 sAreaSize)
{
	CRectangle	cRect;
	BOOL		bValid;

	mcTextData.Layout();
	CDrawable::Layout(sPosition, sAreaSize);

	bValid = mcTextData.GetBounds(msCaretPos.x, msCaretPos.y, &cRect);

	if (bValid)
	{
		mpcCaret->SetPosition(cRect.miLeft + sPosition.x, cRect.miTop + sPosition.y);
		mpcCaret->SetActualSize(1, cRect.GetHeight());
	}
	else
	{
		mbCaretVisible = FALSE;
	}
}
Exemplo n.º 2
0
void CBorder::CalculateUVCoords(SUVCornersFull* apsUVs)
{
	SFloat2		sTopLeft;
	SFloat2		sBottomRight;
	CRectangle	sSubImage;
	int			iTextureWidth;
	int			iTextureHeight;

	if (mpcBorderParameters->GetGraphicsMaterial()->GetNumTextures() > 0)
	{
		//You're not actually done yet, until you handle the tiled version.

		iTextureWidth = GetTexture(0)->GetWidth();
		iTextureHeight = GetTexture(0)->GetHeight();

		//Top
		sSubImage.miTop = 0;
		sSubImage.miLeft = 0;
		sSubImage.SetWidth(iTextureWidth);
		sSubImage.SetHeight(mpcBorderParameters->maiEdgeWidths[0]);
		sTopLeft	 = sSubImage.GetUVCoordinatesTopLeft(iTextureWidth, iTextureHeight);
		sBottomRight = sSubImage.GetUVCoordinatesBottomRight(iTextureWidth, iTextureHeight);
		apsUVs[1].Set(sTopLeft.x, sTopLeft.y, sBottomRight.x, sBottomRight.y);

		//Right
		sSubImage.miTop += sSubImage.GetHeight() - 1;  //Don't even ask...
		sSubImage.SetHeight(mpcBorderParameters->maiEdgeWidths[1]);
		sTopLeft	 = sSubImage.GetUVCoordinatesTopLeft(iTextureWidth, iTextureHeight);
		sBottomRight = sSubImage.GetUVCoordinatesBottomRight(iTextureWidth, iTextureHeight);
		apsUVs[3].Set(sTopLeft.x, sTopLeft.y, sBottomRight.x, sBottomRight.y);
		apsUVs[3].Rotate(1);

		//Bottom
		sSubImage.miTop += sSubImage.GetHeight();
		sSubImage.SetHeight(mpcBorderParameters->maiEdgeWidths[2]);
		sTopLeft	 = sSubImage.GetUVCoordinatesTopLeft(iTextureWidth, iTextureHeight);
		sBottomRight = sSubImage.GetUVCoordinatesBottomRight(iTextureWidth, iTextureHeight);
		apsUVs[5].Set(sTopLeft.x, sTopLeft.y, sBottomRight.x, sBottomRight.y);
		apsUVs[5].Rotate(2);

		//Left
		sSubImage.miTop += sSubImage.GetHeight() + 1;
		sSubImage.SetHeight(mpcBorderParameters->maiEdgeWidths[3]);
		sTopLeft	 = sSubImage.GetUVCoordinatesTopLeft(iTextureWidth, iTextureHeight);
		sBottomRight = sSubImage.GetUVCoordinatesBottomRight(iTextureWidth, iTextureHeight);
		apsUVs[7].Set(sTopLeft.x, sTopLeft.y, sBottomRight.x, sBottomRight.y);
		apsUVs[7].Rotate(3);

		//Top Left
		sSubImage.miTop += sSubImage.GetHeight();
		sSubImage.SetHeight(mpcBorderParameters->masCornerSizes[0].y);
		sSubImage.SetWidth(mpcBorderParameters->masCornerSizes[0].x);
		sTopLeft	 = sSubImage.GetUVCoordinatesTopLeft(iTextureWidth, iTextureHeight);
		sBottomRight = sSubImage.GetUVCoordinatesBottomRight(iTextureWidth, iTextureHeight);
		apsUVs[0].Set(sTopLeft.x, sTopLeft.y, sBottomRight.x, sBottomRight.y);

		//Top Right
		sSubImage.miTop += sSubImage.GetHeight();
		sSubImage.SetHeight(mpcBorderParameters->masCornerSizes[1].y);
		sSubImage.SetWidth(mpcBorderParameters->masCornerSizes[1].x);
		sTopLeft	 = sSubImage.GetUVCoordinatesTopLeft(iTextureWidth, iTextureHeight);
		sBottomRight = sSubImage.GetUVCoordinatesBottomRight(iTextureWidth, iTextureHeight);
		apsUVs[2].Set(sTopLeft.x, sTopLeft.y, sBottomRight.x, sBottomRight.y);

		//Bottom Right
		sSubImage.miTop += sSubImage.GetHeight();
		sSubImage.SetHeight(mpcBorderParameters->masCornerSizes[2].y);
		sSubImage.SetWidth(mpcBorderParameters->masCornerSizes[2].x);
		sTopLeft	 = sSubImage.GetUVCoordinatesTopLeft(iTextureWidth, iTextureHeight);
		sBottomRight = sSubImage.GetUVCoordinatesBottomRight(iTextureWidth, iTextureHeight);
		apsUVs[4].Set(sTopLeft.x, sTopLeft.y, sBottomRight.x, sBottomRight.y);

		//Bottom Left
		sSubImage.miTop += sSubImage.GetHeight();
		sSubImage.SetHeight(mpcBorderParameters->masCornerSizes[3].y);
		sSubImage.SetWidth(mpcBorderParameters->masCornerSizes[3].x);
		sTopLeft	 = sSubImage.GetUVCoordinatesTopLeft(iTextureWidth, iTextureHeight);
		sBottomRight = sSubImage.GetUVCoordinatesBottomRight(iTextureWidth, iTextureHeight);
		apsUVs[6].Set(sTopLeft.x, sTopLeft.y, sBottomRight.x, sBottomRight.y);
	}
}