コード例 #1
0
ファイル: XMLDlg.cpp プロジェクト: jimmccurdy/ArchiveGit
void CXMLDlg::CreateTextItem(HTREEITEM pItem, CAGPage* pPage, POINT& ptOffset)
{
	HTREEITEM pChildItem = m_treeOutput.GetChildItem(pItem);
	if (!pChildItem)
	{
		ASSERT(false);
		return;
	}

	// Initialize the text properties: Color, Valign, HAlign, Angle, Font
	COLORREF Color = RGB(0,0,0);
	eTSJustTypes HAlignment = eRagCentered;
	eVertJust VAlignment = eVertTop;
	LOGFONT Font;
	memset(&Font, 0, sizeof(Font));
	Font.lfWeight = FW_NORMAL;
	Font.lfCharSet = ANSI_CHARSET; //j DEFAULT_CHARSET
	Font.lfItalic = false;
	Font.lfUnderline = false;
	Font.lfStrikeOut = false;
	lstrcpy(Font.lfFaceName, "Arial");
	Font.lfHeight = -POINTUNITS(14);

	#define MAX_SPECS 1000
	int pCharOffsets[MAX_SPECS];
	CAGSpec* pSpecs[MAX_SPECS];
	int nSpecs = 0;

	char* pTextBuffer = new char[10000];
	if (!pTextBuffer)
	{
		ASSERT(false);
		return;
	}
	*pTextBuffer = '\0';

	CRect DestRect;
	double fAngle = 0.0;
	while (pChildItem)
	{
		CString szItemType = m_treeOutput.GetItemText(pChildItem);
		if (!szItemType.CompareNoCase(_T("style")) )
		{
			int iOffset = lstrlen(pTextBuffer);
			CAGSpec* pSpec = HandleAddText(pChildItem, Font, Color, HAlignment, (BYTE*)pTextBuffer + iOffset);
			if (pSpec)
			{
				pSpecs[nSpecs] = pSpec;
				pCharOffsets[nSpecs] = iOffset;
				nSpecs++;
			}
		}
		else
		{
			CString szTitle;
			CString szValue;
			Separate(m_treeOutput.GetItemText(pChildItem), szTitle, szValue);

			if (!szTitle.CompareNoCase(_T("x")) )
			{
				DestRect.left = INCHES(atof(szValue));
			}
			else
			if (!szTitle.CompareNoCase(_T("y")) )
			{
				DestRect.top = INCHES(atof(szValue));
			}
			else
			if (!szTitle.CompareNoCase(_T("dx")) )
			{
				DestRect.right = DestRect.left + INCHES(atof(szValue));
			}
			else
			if (!szTitle.CompareNoCase(_T("dy")) )
			{
				DestRect.bottom = DestRect.top + INCHES(atof(szValue));
			}
			else
			if (!szTitle.CompareNoCase(_T("angle")) )
			{
				fAngle = atof(szValue);
			}
			else
			if (!szTitle.CompareNoCase(_T("valign")) )
			{
				if (!szValue.CompareNoCase(_T("Top")))
					VAlignment = eVertTop;
				else
				if (!szValue.CompareNoCase(_T("Middle")))
					VAlignment = eVertCentered;
				else
				if (!szValue.CompareNoCase(_T("Bottom")))
					VAlignment = eVertBottom;

			}
		}
		
		pChildItem = m_treeOutput.GetNextItem(pChildItem, TVGN_NEXT);
	}
	
	if (!nSpecs)
	{
		delete [] pTextBuffer;
		return;
	}

	DestRect.OffsetRect(-ptOffset.x, -ptOffset.y);

	CAGSymText* pText = new CAGSymText(ST_TEXT);
	if (pText)
	{
		pText->Create(DestRect);
		pText->SetVertJust(VAlignment);
		if (fAngle)
		{
			CAGMatrix Matrix;
			Matrix.Rotate(-fAngle, -fAngle, ((DestRect.left + DestRect.right) / 2), ((DestRect.top + DestRect.bottom) / 2));
			pText->SetMatrix(Matrix);
		}

		// Set the text and specs
		pText->SetText(pTextBuffer, nSpecs, pSpecs, pCharOffsets);

		// Add the text symbol to the page/layer
		CAGLayer* pActiveLayer = pPage->GetActiveLayer();
		if (pActiveLayer)
			pActiveLayer->AddSymbol(pText);	
	}
	else
		ASSERT(false);

	delete [] pTextBuffer;
}
コード例 #2
0
ファイル: XMLDlg.cpp プロジェクト: jimmccurdy/ArchiveGit
void CXMLDlg::CreateGraphicItem(HTREEITEM pItem, CAGPage* pPage, POINT& ptOffset, CString& szParentItemType)
{
	HTREEITEM pChildItem = m_treeOutput.GetChildItem(pItem);
	if (!pChildItem)
	{
		ASSERT(false);
		return;
	}

	COLORREF LineColor = RGB(0,0,0);
	int iLineWidth = LT_None;
	FillType tFillType = FT_None;
	COLORREF FillColor = RGB(0,0,0);
	COLORREF FillColor2 = RGB(0,0,0);
	LineStart tStart = LS_LeftTop;

	POINT* pPoints = new POINT[5000];
	int nPoints = 0;

	CRect DestRect;
	double fAngle = 0.0;
	while (pChildItem)
	{
		CString szItemType = m_treeOutput.GetItemText(pChildItem);
		if (!szItemType.CompareNoCase(_T("pt")) )
		{
			POINT Location = {0,0};
			GetCurrentObjectLocation(pChildItem, Location);
			pPoints[nPoints++] = Location;
		}
		else
		{
			CString szTitle;
			CString szValue;
			Separate(m_treeOutput.GetItemText(pChildItem), szTitle, szValue);

			if (!szTitle.CompareNoCase(_T("x")) )
			{
				DestRect.left = INCHES(atof(szValue));
			}
			else
			if (!szTitle.CompareNoCase(_T("y")) )
			{
				DestRect.top = INCHES(atof(szValue));
			}
			else
			if (!szTitle.CompareNoCase(_T("dx")) )
			{
				DestRect.right = DestRect.left + INCHES(atof(szValue));
			}
			else
			if (!szTitle.CompareNoCase(_T("dy")) )
			{
				DestRect.bottom = DestRect.top + INCHES(atof(szValue));
			}
			else
			if (!szTitle.CompareNoCase(_T("angle")) )
			{
				fAngle = atof(szValue);
			}
			else
			if (!szTitle.CompareNoCase(_T("filltype")) )
			{
				if (!szValue.CompareNoCase(_T("Solid")))
					tFillType = FT_Solid;
				else
				if (!szValue.CompareNoCase(_T("SweepRight")))
					tFillType = FT_SweepRight;
				else
				if (!szValue.CompareNoCase(_T("SweepDown")))
					tFillType = FT_SweepDown;
				else
				if (!szValue.CompareNoCase(_T("RadialCenter")))
					tFillType = FT_RadialCenter;
				else
				if (!szValue.CompareNoCase(_T("RadialCorner")))
					tFillType = FT_RadialCorner;
			}
			else
			if (!szTitle.CompareNoCase(_T("fillcolor")) )
			{
				FillColor = ParseColor(szValue);
			}
			else
			if (!szTitle.CompareNoCase(_T("fillblendcolor")) )
			{
				FillColor2 = ParseColor(szValue);
			}
			else
			if (!szTitle.CompareNoCase(_T("linetype")) )
			{
				if (!szValue.CompareNoCase(_T("Hairline")))
					iLineWidth = LT_Hairline;
				else
				if (!szValue.CompareNoCase(_T("Normal")))
					iLineWidth = POINTUNITS(1);
			}
			else
			if (!szTitle.CompareNoCase(_T("linecolor")) )
			{
				LineColor = ParseColor(szValue);
			}
			else
			if (!szTitle.CompareNoCase(_T("linewidth")) )
			{
				iLineWidth = POINTUNITS(atof(szValue));
			}
			else
			if (!szTitle.CompareNoCase(_T("start")) )
			{
				if (!szValue.CompareNoCase(_T("UpperLeft")))
					tStart = LS_LeftTop;
				else
				if (!szValue.CompareNoCase(_T("UpperRight")))
					tStart = LS_RightTop;
				else
				if (!szValue.CompareNoCase(_T("LowerRight")))
					tStart = LS_RightBottom;
				else
				if (!szValue.CompareNoCase(_T("LowerLeft")))
					tStart = LS_LeftBottom;
			}
		}

		pChildItem = m_treeOutput.GetNextItem(pChildItem, TVGN_NEXT);
	}	

	CAGSymGraphic* pSym = NULL;

	if (!szParentItemType.CompareNoCase(_T("rectangle")))
	{
		CAGSymRectangle* pSym1 = new CAGSymRectangle();
		pSym = pSym1;
	}
	else
	if (!szParentItemType.CompareNoCase(_T("ellipse")))
	{
		CAGSymEllipse* pSym1 = new CAGSymEllipse();
		pSym = pSym1;
	}
	else
	if (!szParentItemType.CompareNoCase(_T("drawing")))
	{
		CAGSymDrawing* pSym1 = new CAGSymDrawing();

		// Due to a conversion bug, flip the y value of each point within the drawing
		int iOffset = DestRect.bottom + DestRect.top;
		for (int i = 0; i < nPoints; i++)
			pPoints[i].y = iOffset - pPoints[i].y;

		pSym1->SetPoints(pPoints, nPoints);
		pSym = pSym1;
	}
	else
	if (!szParentItemType.CompareNoCase(_T("line")))
	{
		CAGSymLine* pSym1 = new CAGSymLine();

		pSym1->SetLineStart(tStart);
		pSym = pSym1;
	}
	else
	if (!szParentItemType.CompareNoCase(_T("border")))
	{
		CAGSymRectangle* pSym1 = new CAGSymRectangle();
		pSym = pSym1;
		// Ignore everything because the data is bad; make it a black, 5 point, unfilled rectangle
		LineColor = RGB(0,0,0);
		iLineWidth = POINTUNITS(5);
		tFillType = FT_None;
		FillColor = RGB(0,0,0);
		FillColor2 = RGB(0,0,0);
	}
	else
	if (!szParentItemType.CompareNoCase(_T("hyperlink")))
	{
	}

	delete [] pPoints;

	if (!pSym)
	{
		ASSERT(false);
		return;
	}

	DestRect.OffsetRect(-ptOffset.x, -ptOffset.y);

	pSym->SetLineColor(LineColor);
	pSym->SetLineWidth(iLineWidth);

	pSym->SetFillType(tFillType);
	pSym->SetFillColor(FillColor);
	pSym->SetFillColor2(FillColor2);

	pSym->SetDestRect(DestRect);
	if (fAngle)
	{
		CAGMatrix Matrix;
		Matrix.Rotate(-fAngle, -fAngle, ((DestRect.left + DestRect.right) / 2), ((DestRect.top + DestRect.bottom) / 2));
		pSym->SetMatrix(Matrix);
	}

	CAGLayer* pActiveLayer = pPage->GetActiveLayer();
	if (pActiveLayer)
		pActiveLayer->AddSymbol(pSym);
}
コード例 #3
0
ファイル: CalSupport.cpp プロジェクト: jimmccurdy/ArchiveGit
void CCalSupport::Draw()
{
	COLORREF LineColor = m_pCalSym->m_LineColor;
	bool bInvisible = (LineColor == CLR_NONE);
	int LineWidth = m_pCalSym->m_LineWidth;
	if (bInvisible)
		LineWidth = LT_None;

	CAGMatrix LineInverseMatrix = m_dc.GetSymbolMatrix();
	double fAngle = LineInverseMatrix.GetAngle();
	LineInverseMatrix.Rotate(-fAngle, -fAngle);
	LineInverseMatrix = LineInverseMatrix.Inverse();

	int nLineSize = (LineWidth == LT_Hairline ? 0 : LineWidth);
	int nLineWidth = dtoi(LineInverseMatrix.TransformWidth(nLineSize));
	int nLineHeight = dtoi(LineInverseMatrix.TransformHeight(nLineSize));

	RECT SymbolRect = m_pCalSym->m_DestRect;
	int iSymbolHeight = HEIGHT(SymbolRect);
	int iTitleHeight = (iSymbolHeight * m_pCalSym->m_uCalStyles.TitleSize) / 100;
	int iWeekHeight  = (iSymbolHeight * m_pCalSym->m_uCalStyles.DayOfWkSize) / 100;
	int iDatesHeight = (iSymbolHeight - iTitleHeight - iWeekHeight);
	int iDateHeight = ((iDatesHeight - nLineHeight) / 6);
	int iDateWidth = (WIDTH(SymbolRect) - nLineWidth) / 7;

	// Fill the 3 big background areas
	RECT TitleRect = SymbolRect;
	TitleRect.bottom = TitleRect.top + iTitleHeight;
	
	RECT WeekRect = SymbolRect;
	WeekRect.top = TitleRect.bottom;
	WeekRect.bottom = WeekRect.top + iWeekHeight;

	RECT DateRect = SymbolRect;
	DateRect.top = WeekRect.bottom;
	DateRect.bottom = DateRect.top + iDatesHeight;

	COLORREF TitleFillColor = (m_pCalSym->m_FillColor == CLR_DEFAULT ? CLR_NONE : m_pCalSym->m_FillColor);
	COLORREF WeekFillColor = (m_pCalSym->m_FillColor2 == CLR_DEFAULT ? CLR_NONE : m_pCalSym->m_FillColor2);
	COLORREF DateFillColor = (m_pCalSym->m_FillColor3 == CLR_DEFAULT ? CLR_NONE : m_pCalSym->m_FillColor3);

	CAGMatrix Matrix = m_dc.GetSymbolToDeviceMatrix();
	DrawBackgroundRectangle(TitleRect, Matrix, TitleFillColor);
	DrawBackgroundRectangle(WeekRect, Matrix, WeekFillColor);
	DrawBackgroundRectangle(DateRect, Matrix, DateFillColor);

	// Compute the Title rect
	TitleRect = SymbolRect;
	TitleRect.bottom = TitleRect.top + iTitleHeight + nLineHeight;

	// Draw the Title box and text
	m_pCalSym->m_SpecMonth.m_HorzJust = (eTSJust)m_pCalSym->m_uCalStyles1.TitleHorzJust;
	DrawRectangle(TitleRect, Matrix, LineColor, LineWidth, CLR_NONE, GetTitleStr(), m_pCalSym->m_SpecMonth, m_pCalSym->m_uCalStyles1.TitleVertJust, nLineWidth, nLineHeight);

	// Compute the Week rect
	WeekRect.left = SymbolRect.left;
	WeekRect.right = WeekRect.left + iDateWidth + nLineWidth;
	WeekRect.top = TitleRect.bottom - nLineHeight;
	WeekRect.bottom = WeekRect.top + iWeekHeight + nLineHeight;

	// Draw the Week boxes and text
	m_pCalSym->m_SpecWeek.m_HorzJust = (eTSJust)m_pCalSym->m_uCalStyles1.WeekHorzJust;

	bool bSunStart = (m_pCalSym->m_uCalStyles.WeekStart == CALSTYLES::SUNDAY_START);
	for (int i=0; i<7; i++)
	{
		int iDay = (bSunStart ? i : i+1);
		DrawRectangle(WeekRect, Matrix, LineColor, LineWidth, CLR_NONE, GetWeekStr(iDay), m_pCalSym->m_SpecWeek, m_pCalSym->m_uCalStyles1.WeekVertJust, nLineWidth, nLineHeight);

		// Update the Week rect
		WeekRect.left += iDateWidth;
		WeekRect.right = WeekRect.left + iDateWidth + nLineWidth;
		if (i == 5)
			WeekRect.right = SymbolRect.right;
	}

	// Compute the Date rect
	DateRect.left = 0;
	DateRect.right = 0;
	DateRect.top = WeekRect.bottom - nLineHeight;
	DateRect.bottom = DateRect.top + iDateHeight + nLineHeight;

	// Draw the Date boxes and text
	m_pCalSym->m_SpecDays.m_HorzJust = (eTSJust)m_pCalSym->m_uCalStyles1.DateHorzJust;

	int nDaysInMonth = GetDaysInMonth();
	int iDay = 2 - GetFirstDayOfMonth(); 
	for (int y=0; y<6; y++)
	{
		DateRect.left = SymbolRect.left;
		DateRect.right = DateRect.left + iDateWidth + nLineWidth;

		bool bRowEmpty = true;
		for (int x=0; x<7; x++)
		{
			bool bDraw = false;
			CString strText;
			if (iDay <= nDaysInMonth)
			{
				bDraw = true;
				if (iDay >= 1)
				{
					strText = String("%d", iDay);
					bRowEmpty = false;
				}
			}
			else
			{
				bool bHideUnusedBoxes = (m_pCalSym->m_uCalStyles.HideBoxes == 1); 
				bool bHideAllBoxes = (m_pCalSym->m_uCalStyles.HideAllBoxes == 1);
				bool bHideEmptyRows = (m_pCalSym->m_uCalStyles.HideAllBoxes == 0);
				bool bHide = bHideUnusedBoxes && (bHideAllBoxes || (bHideEmptyRows && bRowEmpty));
				bDraw = !bHide;
			}

			if (bDraw)
				DrawRectangle(DateRect, Matrix, LineColor, LineWidth, CLR_NONE, strText, m_pCalSym->m_SpecDays, m_pCalSym->m_uCalStyles1.DateVertJust, nLineWidth, nLineHeight);
			iDay++;

			// Update the Date rect
			DateRect.left += iDateWidth;
			DateRect.right = DateRect.left + iDateWidth + nLineWidth;
			if (x == 5)
				DateRect.right = SymbolRect.right;
		}

		// Update the Date rect
		DateRect.top += iDateHeight;
		DateRect.bottom = DateRect.top + iDateHeight + nLineHeight;
		if (y == 4)
			DateRect.bottom = SymbolRect.bottom;
	}
}