Ejemplo n.º 1
0
void Annotation::Init(GP<GMapArea> pArea, const CSize& szPage, int nRotate)
{
	sourceArea = pArea;

	if (pArea->border_type == GMapArea::NO_BORDER)
		nBorderType = BorderNone;
	else if (pArea->border_type == GMapArea::XOR_BORDER)
		nBorderType = BorderXOR;
	else if (pArea->border_type == GMapArea::SHADOW_IN_BORDER)
		nBorderType = BorderShadowIn;
	else if (pArea->border_type == GMapArea::SHADOW_OUT_BORDER)
		nBorderType = BorderShadowOut;
	else if (pArea->border_type == GMapArea::SHADOW_EIN_BORDER)
		nBorderType = BorderEtchedIn;
	else if (pArea->border_type == GMapArea::SHADOW_EOUT_BORDER)
		nBorderType = BorderEtchedOut;
	else
		nBorderType = BorderSolid;

	if (nBorderType == BorderSolid)
	{
		DWORD dwColor = pArea->border_color;
		crBorder = RGB(GetBValue(dwColor), GetGValue(dwColor), GetRValue(dwColor));
	}

	if (pArea->get_shape_type() != GMapArea::RECT && nBorderType > BorderXOR)
		nBorderType = BorderXOR;

	nBorderWidth = max(2, min(32, pArea->border_width));

	bHideInactiveBorder = !pArea->border_always_visible;

	if (pArea->hilite_color == 0xffffffff)
		nFillType = FillNone;
	else if (pArea->hilite_color == 0xff000000)
		nFillType = FillXOR;
	else
		nFillType = FillSolid;

	if (nFillType == FillSolid)
	{
		DWORD dwColor = pArea->hilite_color;
		crFill = RGB(GetBValue(dwColor), GetGValue(dwColor), GetRValue(dwColor));
	}

	fTransparency = 1.0 - max(0, min(100, pArea->opacity)) / 100.0;

	if (pArea->is_text)
	{
		bAlwaysShowComment = true;
		DWORD dwColor = pArea->foreground_color;
		crForeground = RGB(GetBValue(dwColor), GetGValue(dwColor), GetRValue(dwColor));
	}

	strComment = pArea->comment;
	strURL = pArea->url;

	if (pArea->get_shape_type() == GMapArea::LINE || pArea->get_shape_type() == GMapArea::POLY)
	{
		GMapPoly* pPoly = (GMapPoly*)(GMapArea*) pArea;
		for (int i = 0; i < pPoly->get_points_num(); ++i)
		{
			GRect rect(pPoly->get_x(i), pPoly->get_y(i), 1, 1);
			if (nRotate != 0)
				Rotate(szPage, nRotate, rect);
			points.push_back(make_pair(rect.xmin, rect.ymin));
		}

		if (pArea->is_line)
		{
			bIsLine = true;
			bHasArrow = pArea->has_arrow;
			nLineWidth = max(1, min(32, pArea->line_width));

			DWORD dwColor = pArea->foreground_color;
			crForeground = RGB(GetBValue(dwColor), GetGValue(dwColor), GetRValue(dwColor));
		}
	}
	else
	{
		if (pArea->get_shape_type() == GMapArea::OVAL)
			bOvalShape = true;

		rects.push_back(pArea->get_bound_rect());
		if (nRotate != 0)
			Rotate(szPage, nRotate, rects.back());
	}

	UpdateBounds();
}