Exemplo n.º 1
0
bool CXMLDlg::AddImage(HGLOBAL hMemory, bool bIsDIB, CAGPage* pPage, RECT* pDestRect)
{
	if (!pPage || !pDestRect)
	{
		ASSERT(false);
		return false;
	}

	RECT MaxBounds = {0,0,0,0};
	SIZE PageSize = {0,0};
	pPage->GetPageSize(PageSize);
	::SetRect(&MaxBounds, 0, 0, PageSize.cx, PageSize.cy);

	CAGSym* pSym = NULL;
	if (bIsDIB)
	{
		char* pMemory = (char*)::GlobalLock(hMemory);
		if (!pMemory)
			return false;

		// do we have a bitmap file header preceding the DIB?
		BITMAPFILEHEADER* pBMPFile = (BITMAPFILEHEADER*)pMemory;
		#define BFT_BITMAP	0x4d42	/* 'BM' */
		if (pBMPFile->bfType == BFT_BITMAP)
			pMemory += sizeof(BITMAPFILEHEADER);

		BITMAPINFOHEADER* pDIB = (BITMAPINFOHEADER*)pMemory;
		if (pDIB->biCompression == BI_RGB)
		{
			CAGSymImage* pSymImage = new CAGSymImage(pDIB, MaxBounds);
			pSym = pSymImage;
		}

		::GlobalUnlock(hMemory);
	}
	else
	{
		CAGSymImage* pSymImage = new CAGSymImage(hMemory, MaxBounds);
		pSym = pSymImage;
	}

	if (!pSym)
	{
		ASSERT(false);
		return false;
	}
		
	pSym->SetDestRect(*pDestRect);

	CAGLayer* pActiveLayer = pPage->GetActiveLayer();
	if (pActiveLayer)
		pActiveLayer->AddSymbol(pSym);
	else
		ASSERT(false);

	return true;
}
Exemplo n.º 2
0
void CEnvelopeWizard::InitGraphics(CAGDoc* pPrevDoc)
{
	for (int nIndex = 0; nIndex < MAX_NUM_PICTURES; nIndex++)
		m_pGraphics[nIndex] = NULL;

	if (!pPrevDoc)
		return;

	int nGraphicItem = 0;
	for (int nIndex = 0; nIndex < MAX_PAGES_TO_CHECK; nIndex++)
	{
		CAGPage* pPage = pPrevDoc->GetPage(nIndex);
		if (!pPage)
			continue;

		int nLayers = pPage->GetNumLayers();
		for (int l = 0; l < nLayers; l++)
		{
			CAGLayer* pLayer = pPage->GetLayer(l);
			if (!pLayer)
				continue;

			int nSymbols = pLayer->GetNumSymbols();
			for (int i = 0; i < nSymbols; i++)
			{
				CAGSym* pSym = (CAGSym*)pLayer->GetSymbol(i);
				if (!pSym)
					continue;

				if (!pSym->IsImage())
					continue;

				CAGSymImage* pImage = (CAGSymImage*)pSym;
				if (pImage->IsLocked() || pImage->IsDeleted())
					continue;

				CAGSymImage* pNewImage = (CAGSymImage*)pImage->Duplicate();
				if (!pNewImage)
					return;

				// Add a copy of the image symbol to the list
				// Be sure to set its location to (0,0) to make it easier to add to the envelope
				CRect DestRect = pNewImage->GetDestRectTransformed();
				DestRect.MoveToXY(0,0);
				pNewImage->SetDestRect(DestRect);
				pNewImage->SetMatrix(CAGMatrix());
				pNewImage->SetHidden(false);
				m_pGraphics[nGraphicItem] = pNewImage;
				nGraphicItem++;
			}
		}
	}
}
Exemplo n.º 3
0
void CToolsCtlPanelText::UpdateControls()
{
	CAGSym* pSym = m_pCtp->GetDocWindow()->GetSelectedItem();
	if (!pSym)
		return;

	if (pSym->IsText() || (pSym->IsAddAPhoto() && m_pCtp->GetDocWindow()->SpecialsEnabled()))
	{
		CAGText* pText = (CAGText*)(CAGSymText*)pSym;
		UpdateTextControls(pText);
	}
	else if (pSym->IsCalendar())
	{
		CAGSymCalendar* pCalSym = (CAGSymCalendar*)pSym;
		UpdateCalendarTextControls(pCalSym);
	}
}
Exemplo n.º 4
0
void CToolsPanelImage2::UpdateControls()
{

	CDocWindow* pDocWindow = m_pCtp->GetDocWindow();
	CAGDoc* pAGDoc = (!pDocWindow ? NULL : pDocWindow->GetDoc());

	CAGSym* pSym = pDocWindow->GetSelectedItem();
	if (!pSym)
		return;

	m_ButtonColor.ShowWindow(SW_HIDE);
	m_ButtonRedeye.ShowWindow(SW_HIDE);
	if (pDocWindow->GetSelect().SymIsClipArt())
	{
		m_ButtonColor.EnableWindow(true);
		m_ButtonRedeye.EnableWindow(false);
	}
	else
	{
		m_ButtonColor.EnableWindow(false);
		m_ButtonRedeye.EnableWindow(true);
	}
	m_ButtonColor.ShowWindow(SW_SHOW);
	m_ButtonRedeye.ShowWindow(SW_SHOW);

	if (pSym->IsImage())
	{
		CAGSymImage* pImageSym = (CAGSymImage*)pSym;

		COLORREF Color = pImageSym->GetLastHitColor();
		if (Color == CLR_NONE)
			return;

		//Get the text panel and set the color
		CToolsPanelContainer* pCtlPanel = m_pCtp->GetCtlPanel(TEXT_PANEL);
		if (pCtlPanel)
		{
			CToolsPanelText2* pBotTxtToolsPanel = (CToolsPanelText2*)pCtlPanel->GetBotToolPanel();
			if (pBotTxtToolsPanel)
				pBotTxtToolsPanel->SetFillColor(Color);
		}
	}

	
}
Exemplo n.º 5
0
void CUndo::ClearList(CUndoList& List, bool fClearAllItems)
{
	CUndoItem* pItem = NULL;
	while (pItem = RemoveItem(List, fClearAllItems))
	{
		CAGSym* pUndoCopy = pItem->GetUndoCopy();
		if (pUndoCopy && pUndoCopy->IsDeleted())
			delete pUndoCopy;

		if (!fClearAllItems)
		{
			CAGSym* pSym = pItem->GetUndoItem();
			if (pSym && pSym->IsDeleted())
				m_pDocWindow->UndoPermDelete(pSym);
		}

		pItem->SetUndoItem(NULL);
		delete pItem;
	}
}
void CToolsCtlPanelGraphics::UpdateControls()
{
	CDocWindow* pDocWindow = m_pCtp->GetDocWindow();
	CAGDoc* pAGDoc = (!pDocWindow ? NULL : pDocWindow->GetDoc());

	CAGSym* pSym = m_pCtp->m_pDocWindow->GetSelectedItem();
	if (!pSym)
		return;

	if (pSym->IsGraphic())
	{
		CAGSymGraphic* pGraphicSym = (CAGSymGraphic*)pSym;

		if (pSym->IsRectangle())
			SetShapeName("Rectangle");
		else
		if (pSym->IsEllipse())
			SetShapeName("Circle/Ellipse");
		else
		if (pSym->IsLine())
			SetShapeName("Line");
		else
		if (pSym->IsShape())
		{
			SetShapeName(((CAGSymDrawing*)pSym)->GetShapeName());
		}

		// Update the Fill controls
		SetFillType(pGraphicSym->GetFillType());
		SetFillColor(pGraphicSym->GetFillColor());
		SetFillColor2(pGraphicSym->GetFillColor2());

		// Update the Line control
		SetLineWidth(pGraphicSym->GetLineWidth());
		SetLineColor(pGraphicSym->GetLineColor());

		//UpdateFillCtrls();
		//UpdateLineCtrls();
		ShowHideColors();
	}
}
Exemplo n.º 7
0
void CUndo::OnEditUndo()
{
	if (m_pSymTextEdit && m_pSymTextEdit->IsDirty()) // if editing text, and edits have been made...
		CheckPointText(NULL, m_pSymTextEdit);

	// Unselect the current symbol
	// This must be done before working with the undo list below
	m_pDocWindow->SymbolUnselect(true/*bClearPointer*/);

	CUndoItem* pItem = GetListItem(m_dqUndoItemList);
	if (!pItem)
		return;

	CAGSym* pSym = pItem->GetUndoItem();
	if (pSym || pItem->GetUndoCommand() == IDC_DOC_PAGENAV)
	{
		switch (pItem->GetUndoCommand())
		{
			case IDC_DOC_ADDIMAGE:
			case IDC_DOC_ADDAPHOTO:
			case IDC_DOC_ADDTEXTBOX:
			case IDC_DOC_ADDSHAPE:
			case IDC_DOC_ADDCALENDAR:
			case IDC_DOC_PASTE:
			{
				m_pDocWindow->UndoAdd(pSym);
				break;
			}
			case IDC_DOC_CUT:
			case IDC_DOC_DELETE:
			{
				m_pDocWindow->UndoDelete(pSym);
				break;
			}
			case IDC_CONVERT_TO_JPG:
			{
				CAGSym* pSymCopy = (CAGSym*)pItem->GetItemValue();
				m_pDocWindow->UndoAdd(pSymCopy);
				m_pDocWindow->UndoDelete(pSym);
				break;
			}
			case IDC_DOC_MIRROR:
			{
				m_pDocWindow->UndoMirrorFlip(pSym, true/*bFlipX*/, false/*bFlipy*/);
				break;
			}
			case IDC_DOC_FLIP:
			{
				m_pDocWindow->UndoMirrorFlip(pSym, false/*bFlipX*/, true/*bFlipy*/);
				break;
			}
			case IDC_DOC_ROTATECW:
			{
				m_pDocWindow->UndoRotate(pSym, false/*bCW*/);
				break;
			}
			case IDC_DOC_ROTATECCW:
			{
				m_pDocWindow->UndoRotate(pSym, true/*bCW*/);
				break;
			}
			case IDC_DOC_TRANSFORM:
			case IDC_DOC_POSCENTER:
			case IDC_DOC_POSCENTERH:
			case IDC_DOC_POSCENTERV:
			case IDC_DOC_POSLEFT:
			case IDC_DOC_POSRIGHT:
			case IDC_DOC_POSTOP:
			case IDC_DOC_POSTOPLEFT:
			case IDC_DOC_POSTOPRIGHT:
			case IDC_DOC_POSBOTTOM:
			case IDC_DOC_POSBOTTOMLEFT:
			case IDC_DOC_POSBOTTOMRIGHT:
			{
				CAGMatrix CurrentMatrix = pSym->GetMatrix();
				m_pDocWindow->UndoTransform(pSym, pItem->GetItemMatrix());
				pItem->SetItemMatrix(CurrentMatrix);
				break;
			}
			case IDC_DOC_FILLCOLORCHANGE:
			{
				CAGSymGraphic* pGraphicSym = (CAGSymGraphic*)pSym;
				COLORREF Color = pGraphicSym->GetFillColor();
				m_pDocWindow->UndoColor(pSym, pItem->GetItemValue(), false/*bLineColor*/);
				pItem->SetItemValue(Color);
				break;
			}
			case IDC_DOC_FILLCOLORCHANGE2:
			{
				CAGSymGraphic* pGraphicSym = (CAGSymGraphic*)pSym;
				COLORREF Color = pGraphicSym->GetFillColor2();
				m_pDocWindow->UndoColor(pSym, pItem->GetItemValue(), false/*bLineColor*/, true/*FillColor2*/);
				pItem->SetItemValue(Color);
				break;
			}
			case IDC_DOC_LINECOLORCHANGE:
			{
				CAGSymGraphic* pGraphicSym = (CAGSymGraphic*)pSym;
				COLORREF Color = pGraphicSym->GetLineColor();
				m_pDocWindow->UndoColor(pSym, pItem->GetItemValue(), true/*bLineColor*/);
				pItem->SetItemValue(Color);
				break;
			}
			case IDC_DOC_LINEWIDTHCHANGE:
			{
				CAGSymGraphic* pGraphicSym = (CAGSymGraphic*)pSym;
				int nWidth = pGraphicSym->GetLineWidth();
				m_pDocWindow->UndoLineWidth(pSym, pItem->GetItemValue(), pItem->GetItemValue2());
				pItem->SetItemValue(nWidth);
				break;
			}
			case IDC_DOC_FILLTYPECHANGE:
			{
				CAGSymGraphic* pGraphicSym = (CAGSymGraphic*)pSym;
				FillType Fill = pGraphicSym->GetFillType();
				m_pDocWindow->UndoFillType(pSym, pItem->GetItemValue());
				pItem->SetItemValue((int)Fill);
				break;
			}
			case IDC_DOC_DESTRECTCHANGE:
			{
				RECT CurrentDestRect = pSym->GetDestRect();
				m_pDocWindow->UndoDestRect(pSym, pItem->GetItemRect());
				pItem->SetItemRect(CurrentDestRect);
				break;
			}
			case IDC_DOC_CROP:
			{
				CAGSymImage* pImage = (CAGSymImage*)pSym;
				RECT CurrentCropRect = pImage->GetCropRect();
				m_pDocWindow->UndoCropRect(pSym, pItem->GetItemRect());
				pItem->SetItemRect(CurrentCropRect);
				break;
			}
			case IDC_DOC_BACKONE:
			case IDC_DOC_FORWARDONE:
			case IDC_DOC_BRINGTOFRONT:
			case IDC_DOC_PUSHTOBACK:
			{
				m_pDocWindow->UndoLayer(pSym, -pItem->GetItemValue());
				break;
			}
			case IDC_DOC_TEXT_EDIT_END:
			{
				m_pDocWindow->UndoTextEdit(pItem);
				break;
			}
			case IDC_DOC_LOCKED:
			{
				m_pDocWindow->UndoLocked(pSym);
				break;
			}
			case IDC_DOC_HIDDEN:
			{
				m_pDocWindow->UndoHidden(pSym);
				break;
			}
			case IDC_DOC_TRANSPARENT:
			{
				m_pDocWindow->UndoTransparent(pSym);
				break;
			}
			case IDC_DOC_PAGENAV:
			{
				int nLastPage = pItem->GetItemValue();
				int nPage = pItem->GetItemValue2();
				m_pDocWindow->UndoPageTurn(nLastPage);
				break;
			}
		}
	}

	// Select the modified symbol
	m_pDocWindow->SymbolSelect(pSym);

	TransferItem(m_dqUndoItemList, m_dqRedoItemList);
}
Exemplo n.º 8
0
bool CFYSPrintDoc::CreateXmlDoc(CString& strOrderId, CString& strCorrId, CString& strFYSInfo, bool bUnpackFiles)
{
	if (!m_pAGDoc)
		return false;

	CWaitCursor Wait;

	Initialize();
	if (!CreateDirAndSubDirs())
		return false;

	// Documents element
	CString strDocFileName;
	{
		// strip the last "\"
		int nLen = m_strFYSTempPath.GetLength();
		CString strTempPath = m_strFYSTempPath.Left(nLen-1);

		strDocFileName = TempFileName(strTempPath, "4YS", "txt");
		strDocFileName = m_strFYSTempPath + strDocFileName;
		FILE* docout = NULL;
		errno_t err = fopen_s(&docout, strDocFileName, "wb");
		if (!docout || err != 0)
		{
			SetError(String("Failed to open %s", strDocFileName));
			return false;
		}

		SIZE PageSize = {0,0};
		m_pAGDoc->GetPageSize(PageSize);
		double dx = DINCHES(PageSize.cx);
		double dy = DINCHES(PageSize.cy);

		fprintf(docout, "	<Documents Count='1'>\r\n");
		fprintf(docout, "		<Document CLT_CorrelationID='%s' FYS_CorrelationID='%s'>\r\n", strOrderId, strCorrId);
		fprintf(docout, "			<GreetingCard PageWidth='%0.5G' PageHeight='%0.5G' />\r\n", dx, dy);

		int nPages = m_pAGDoc->GetNumPages();
		for (int nPage = 0; nPage < nPages; nPage++)
		{
			CAGPage* pPage = m_pAGDoc->GetPage(nPage);
			if (!pPage)
				continue;

			if (!PageHasSymbols(pPage))
				continue;

			fprintf(docout, "\t\t\t<Page PageNumber='%d'>\r\n", nPage+1);

			int nLayers = pPage->GetNumLayers();
			for (int nLayer = 0; nLayer < nLayers; nLayer++)
			{
				CAGLayer* pLayer = pPage->GetLayer(nLayer);
				if (!pLayer)
					continue;

				int nSymbols = pLayer->GetNumSymbols();
				for (int nSymbol = nSymbols - 1; nSymbol >= 0; nSymbol--)
				{
					bool bRetVal = true;
					CAGSym* pSym = pLayer->GetSymbol(nSymbol);
					if (!pSym || pSym->IsHidden())
						continue;

					pSym->RegisterFileSpecsCallback(fnFileSpecs, (LPARAM)this);

					int idSym = pSym->GetID();
					bool bReposition = (idSym == IDR_AGLOGO || idSym == IDR_CARDBACK_COPYRIGHT);
					if (bReposition)
					{
						// Move these symbols up to make room for the FYS logo
						CAGMatrix Matrix = pSym->GetMatrix();
						Matrix.Translate(0, -(INCHES(0.5)));
						pSym->SetMatrix(Matrix);
					}

					pSym->WriteFYSXml(docout, 4);

					if (bReposition)
					{
						CAGMatrix Matrix = pSym->GetMatrix();
						Matrix.Translate(0, INCHES(0.5));
						pSym->SetMatrix(Matrix);
					}

					if (pSym->IsImage())
					{
						CAGSymImage* pSymImage = (CAGSymImage*)pSym;
						CString strSep("\\");
						CString strImagePath = m_strFYSTempPath + IMAGES_PATH + strSep;
						bRetVal = DumpImageFile(pSymImage, strImagePath);

						if (bRetVal)
						{
							SIZE PageSize;
							pPage->GetPageSize(PageSize);
							if (pSymImage->DoCoverDraw() && pSymImage->IsCoverAllowed())
								pSymImage->WriteXmlRects(docout, PageSize, 4);
						}
					}

					pSym->UnregisterFileSpecsCallback();
					if (!bRetVal)
						return false;
				}
			}

			fprintf(docout, "\t\t\t</Page>\r\n");
		}

		fprintf(docout, "		</Document>\r\n");
		fprintf(docout, "	</Documents>\r\n");
		fclose(docout);
	}

	CString strSep("\\");
	CString strFontsPath = m_strFYSTempPath + FONTS_PATH + strSep;
	DumpFontFiles(strFontsPath);

	// Get Configuration element
	if (!GetConfigurationElement(strFYSInfo))
	{
		CleanUpEx(strDocFileName);
		return false;
	}

	// Get Resources element
	if (!GetResourcesElement())
	{
		CleanUpEx(strDocFileName);
		return false;
	}

	// Write CreateAndPrint.xml file
	CString strXmlPath = m_strFYSTempPath + XML_PATH + strSep;
	if (!WriteCreatePrintXml(strDocFileName, strXmlPath))
	{
		CleanUpEx(strDocFileName);
		return false;
	}

	// Write StreamHdr.xml file
	if (!WriteXmlStreamHeader(strXmlPath))
	{
		CleanUp();
		return false;
	}

	// Write 4YourSoul.txt file
	if (!CreateSendFile())
	{
		CleanUp();
		return false;
	}

	if (bUnpackFiles)
		UnpackFiles();

	CleanUp();

	return true;
}