VOID CCardView::set_card_panel_view(SHORT new_panel) { /* // If this is a demo card back, then we don't allow editing. */ if ((new_panel == CARD_PANEL_Back) && !GetConfiguration()->SupportsCardBack()) { return; } #if 1 BeforePageChange(); SetPanel(new_panel); #else /* // Get the document and build the undo/redo command for this. */ CPmwDoc* pDoc = GetDocument(); CCmdCardPanel* pCommand = new CCmdCardPanel(IDCmd_Panel[new_panel+1]); if (pCommand->Snapshot(this, pDoc->get_current_panel(), new_panel)) { pDoc->AddCommand(pCommand); } else { delete pCommand; /* Fall through. */ // SetPanel(new_panel); } #endif }
int CLabelView::OnPrintLabels(PrintContext &pc, int nCurrentPage, int nNumPages) { CPmwDoc* pDoc = GetDocument(); PPNT dims = pDoc->get_dimensions(); int nError = 0; int nPrintCopies = pc.m_copies; while (nError == 0 && nPrintCopies-- > 0) { // Source will always be all of the label. pc.m_source.x0 = 0; pc.m_source.y0 = 0; pc.m_source.x1 = dims.x; pc.m_source.y1 = dims.y; OnPrepareDC(&pc.m_dcPrint, pc.m_pInfo); // Set up drawing rect to entire page (in logical coordinates) pc.m_pInfo->m_rectDraw.SetRect(0, 0, pc.m_dcPrint.GetDeviceCaps(HORZRES), pc.m_dcPrint.GetDeviceCaps(VERTRES)); pc.m_dcPrint.DPtoLP(&pc.m_pInfo->m_rectDraw); CString strFmt; TRY LoadConfigurationString(IDS_PRINTPAGENUM, strFmt); END_TRY char szBuf[80]; wsprintf(szBuf, strFmt, (int32)nCurrentPage+1, (int32)nNumPages); pc.m_dlgstatus->SetDlgItemText(AFX_IDC_PRINT_PAGENUM, szBuf); if (!pc.m_fBanding) { VERIFY(pc.m_dcPrint.StartPage()); } nError = OnPrint(&pc, pc.m_pInfo) || UserAbort; if (!pc.m_fBanding) { if (pc.m_dcPrint.EndPage() < 0) nError = TRUE; } } return nError; }
static void CreateFrame(CPmwView* pView, LPCSTR pszText, const PBOX& Bound, ALIGN_TYPE nHAlign, VERT_ALIGN_TYPE nVAlign) { CPmwDoc* pDoc = pView->GetDocument(); PMGDatabase* pDatabase = pDoc->get_database(); FRAMEOBJ_CREATE_STRUCT fcs; fcs.bound = Bound; fcs.alignment = nHAlign; fcs.vert_alignment = nVAlign; fcs.flags = 0; fcs.pStyle = NULL; CFrameObject* pFrame = pDoc->create_frame_object(&fcs); if (pFrame != NULL) { pDoc->append_object(pFrame); CTextStyle Style(pDatabase); Style.SetDefault(); // Set the face to "Geneva". int nFace = typeface_server.find_face("Geneva", FALSE); if (nFace != -1) { PMGFontServer* pFontServer = (PMGFontServer*)pDoc->get_font_server(); DB_RECORD_NUMBER lFace = pFontServer->font_face_to_record(nFace); if (lFace != 0) { Style.Font(lFace); pDatabase->free_font_record(lFace, TRUE); } } Style.Size(MakeFixed(150)); Style.BaseSize(MakeFixed(150)); Style.UpdateFontMetrics(); CTxp Txp(pDatabase); Txp.Init(pFrame, 0); Txp.SetHorizontalAlignment(fcs.alignment); Txp.Style(Style); Txp.InsertString(pszText); } }
void CDoubleSidedPrintPrePrint1::OnClickedPrint() { CPmwApp* pApp = GET_PMWAPP(); // Create a newsletter project. pApp->last_new_info.type = PROJECT_TYPE_Newsletter; pApp->last_new_info.subtype = 0; pApp->last_new_info.orientation = PORTRAIT; // Paper info is printer info. *(pApp->last_new_info.m_pPaperInfo) = *(pApp->GetPaperInfo(pApp->last_new_info.orientation)); WORD wFlags = CPmwDoc::m_wGlobalDocumentFlags; CPmwDoc::m_wGlobalDocumentFlags |= CPmwDoc::FLAG_TestPrintDocument; CPmwDoc* pDoc = (CPmwDoc*)(pApp->m_pScratchTemplate->OpenDocumentFile(NULL, FALSE)); CPmwDoc::m_wGlobalDocumentFlags = wFlags; if (pDoc != NULL) { #ifndef WIN32 pDoc->DoNewDocument(-1, FALSE); #endif CPmwView* pView = pDoc->GetCurrentView(); // We have one page so far. Add the key text to it. // Create the key frame with text saying "FACE UP". WORD wDoubleSidedType = DBLPRN_Valid; pView->CreateKeyFrame(wDoubleSidedType); pView->CreateKeyArrow(wDoubleSidedType); CreateLeftFrame(pView, "A"); ASSERT(pDoc->NumberOfPages() == 1); // Create the second page. pDoc->AddPage(1); pDoc->GotoPage(1); pView->CreateKeyFrame(wDoubleSidedType); pView->CreateKeyArrow(wDoubleSidedType); CreateLeftFrame(pView, "B"); // Set the title for the print-out. CString csTitle; TRY csTitle.LoadString(IDS_PrintTest1); END_TRY pDoc->SetTitle(csTitle); // Do the print-out. pView->PrintNoDialog(); pDoc->OnCloseDocument(); } }
void CLabelView::OnLabelType() { CPmwDoc* pDoc = GetDocument(); CLabelTypeDialog Dialog(pDoc->GetPaperInfo(), this); if (Dialog.DoModal() == IDOK) { CLabelData* pLabel = Dialog.GetChosenLabel(); if (pLabel != NULL) { /* Get the paper info. */ pDoc->AssignPaperInfo(*pLabel); pDoc->SizeToInternalPaper(); pDoc->reset_views(); } } }
void CLabelView::SetLabelVariables(PrintContext& pc, int nPage) { CLabelPrintDialog* pDialog = (CLabelPrintDialog*)pc.m_pPD; ASSERT(!pDialog->m_fPageBreak); ASSERT(nPage < pDialog->m_nTotalPages); // Compute how many labels have been printed to this point. CPmwDoc* pDoc = GetDocument(); CPaperInfo* pLabelInfo = pDoc->GetPaperInfo(); int nStartingLabel = pDialog->m_nStartingLabel; int nSlots = pLabelInfo->Slots(); // This is how many labels have been printed so far. int nLabels = nPage*nSlots - nStartingLabel; // Compute the new name index and copy count. // Get the name list. CStdMacroServer* pMacroServer = pDoc->GetMacroServer(); NameListRecord* pNameList = pMacroServer->GetNameList(); int nNames = pNameList->Names(); if (nNames == 0) { pc.m_nCurrentName = -1; pc.m_nCurrentCopy = nLabels; } else { if (pDialog->m_fCollate) { pc.m_nCurrentName = nLabels % nNames; pc.m_nCurrentCopy = nLabels / nNames; } else { int nCopies = pDialog->m_nLabelCopies; ASSERT(nCopies > 0); pc.m_nCurrentName = nLabels / nCopies; pc.m_nCurrentCopy = nLabels % nCopies; } } }
BOOL CArtOleDropTarget::SaveClipObjectsToUserArt(COleDataObject* pDataObject, LPCTSTR pFilename) { CPmwDoc* pTempDoc = GET_PMWAPP()->NewHiddenDocument(); if (pTempDoc == NULL) { ASSERT(pTempDoc); return FALSE; } pTempDoc->size_to_paper(); BOOL retval = TRUE; if ((clipboard.PasteObjectsFromDatabase(pTempDoc) != ERRORCODE_None) || (pTempDoc->SaveToFile(pFilename, TRUE) != TRUE)) { retval = FALSE; } pTempDoc->OnCloseDocument(); return retval; }
int CLabelView::PrintLabelsBackward(PrintContext &pc, int nSide) { CPmwDoc* pDoc = GetDocument(); CLabelPrintDialog* pDialog = (CLabelPrintDialog*)pc.m_pPD; int nTotalPages = pDialog->m_nTotalPages; // Set the side. DWORD dwCurrentPage = pDoc->CurrentPageIndex(); if (nSide != (int)dwCurrentPage) { pDoc->GotoPage((DWORD)nSide, FALSE); } // Start at requested first label for first page. int nError = 0; // Run through all the pages. for (int nPage = nTotalPages; nPage-- > 0;) { pc.m_nStartingLabel = (nPage == 0) ? pDialog->m_nStartingLabel : 0; SetLabelVariables(pc, nPage); if ((nError = OnPrintLabels(pc, nPage, nTotalPages)) != 0) { // Aack! We got an error. Leave now. break; } } // Reset the page. if (dwCurrentPage != pDoc->CurrentPageIndex()) { pDoc->GotoPage(dwCurrentPage, FALSE); } return nError; }
void CLabelView::OnDraw(CDC* pDC) { // Print preview comes in as printing. Printing case does not come here. // So, IsPrinting() flag determines preview. if (!pDC->IsPrinting() || m_pPreviewExtent == NULL) { INHERITED::OnDraw(pDC); return; } /* // Save the scaled_source x0 and y0 in the printer rc since we will be // changing them. */ // Save the in extent since it gets change during interrupt. PBOX InExtent = m_pPreviewExtent->extent; PBOX SourcePbox = printer_rc.source_pbox; PPNT SourceOrigin; SourceOrigin.x = printer_rc.scaled_source_x0; SourceOrigin.y = printer_rc.scaled_source_y0; /* Get the document to work with. */ CPmwDoc* pDoc = GetDocument(); int nPrintOrientation = pDoc->get_orientation(); BOOL fLandscape = (nPrintOrientation == LANDSCAPE); /* Get the App and its info. */ CPmwApp* pApp = GET_PMWAPP(); CPaperInfo* pPaperInfo = pApp->GetPaperInfo(nPrintOrientation); CPrinterInfo* pPrinterInfo = pApp->GetPrinterInfo(nPrintOrientation); CFixedRect PaperPhysicalMargins = pPaperInfo->PhysicalMargins(); /* Get the paper info. */ CPaperInfo* pLabelInfo = pDoc->GetPaperInfo(); CFixedRect Margins = pLabelInfo->Margins(); // If this is landscape, rotate the margins correctly. pPrinterInfo->OrientRect(&Margins); /* Compute the number of slots we need to print. */ int nSlot = m_pPreviewExtent->update_object == NULL ? 0 : m_pPreviewExtent->m_nPreviewSlot; int nSlots = pLabelInfo->Slots(); /* Run through all the slots. */ while (nSlot < nSlots) { /* // Setup the parameters for this slot so that we will draw in the correct // spot on the page. */ ASSERT(pDoc->CurrentPageIndex() == 0 || pDoc->CurrentPageIndex() == 1); CFixedRect SlotBounds = pLabelInfo->SlotBounds(nSlot); BOOL fBack = (pDoc->CurrentPageIndex() == 1); CFixedPoint Dims = pLabelInfo->PaperDims(); CFixed lLeft = SlotBounds.Left; CFixed lTop = SlotBounds.Top; CFixed lWidth = SlotBounds.Width(); CFixed lHeight = SlotBounds.Height(); if (fLandscape) { switch (pPrinterInfo->Orientation()) { case 90: { // 90 degree rotation (like lasers) SlotBounds.Left = Dims.y - (lTop + lHeight); SlotBounds.Top = lLeft; break; } // case -1: // case 270: default: { // 270 degree rotation (like dot-matrix) SlotBounds.Left = lTop; SlotBounds.Top = Dims.x - (lLeft + lWidth); break; } } if (fBack) { // We are printing the back side. Reverse the slot. SlotBounds.Left = Dims.y - (SlotBounds.Left + lHeight); } SlotBounds.Right = SlotBounds.Left + lHeight; SlotBounds.Bottom = SlotBounds.Top + lWidth; } else { // Portrait. if (fBack) { // We are printing the back side. Reverse the slot. SlotBounds.Left = Dims.x - SlotBounds.Right; SlotBounds.Right = SlotBounds.Left + lWidth; } } CFixedPoint Org; Org.x = Margins.Left-PaperPhysicalMargins.Left; Org.y = Margins.Top-PaperPhysicalMargins.Top; if (fLandscape) { /* Printout is landscape. Reverse the origins. */ CFixed t = Org.x; Org.x = Org.y; Org.y = t; } PPNT Delta; Delta.x = MulFixed(SlotBounds.Left + Org.x, PAGE_RESOLUTION); Delta.y = MulFixed(SlotBounds.Top + Org.y, PAGE_RESOLUTION); printer_rc.source_pbox.x0 = SourcePbox.x0 - Delta.x; printer_rc.source_pbox.y0 = SourcePbox.y0 - Delta.y; printer_rc.source_pbox.x1 = SourcePbox.x1 - Delta.x; printer_rc.source_pbox.y1 = SourcePbox.y1 - Delta.y; printer_rc.scaled_source_x0 = /*SourceOrigin.x*/ - Delta.x*printer_rc.x_resolution; printer_rc.scaled_source_y0 = /*SourceOrigin.y*/ - Delta.y*printer_rc.y_resolution; if (IsBoxOnBox(&printer_rc.source_pbox, &InExtent)) { // Do the draw. INHERITED::OnDraw(pDC); if (m_pPreviewExtent->update_object != NULL) { m_pPreviewExtent->m_nPreviewSlot = nSlot; m_pPreviewExtent->extent = InExtent; break; } } /* // Update the parameters for the next label to draw. */ nSlot++; } /* // Restore the scaled source x0 from the saved values. */ printer_rc.source_pbox = SourcePbox; printer_rc.scaled_source_x0 = SourceOrigin.x; printer_rc.scaled_source_y0 = SourceOrigin.y; }
void CLabelView::OnDraw(PrintContext* pc) { CPmwDoc* pDoc = GetDocument(); DWORD dwPage = pDoc->CurrentPageIndex(); // Verify we are doing a normal page. if (dwPage != 0 && dwPage != 1) { // Non-standard page (like the "key" page). Defer to the base class. CPmwView::OnDraw(pc); return; } /* // Save the scaled_source x0 and y0 in the printer rc since we will be // changing them. */ PBOX SourcePbox = printer_rc.source_pbox; PPNT SourceOrigin; SourceOrigin.x = printer_rc.scaled_source_x0; SourceOrigin.y = printer_rc.scaled_source_y0; /* Get the document to work with. */ int nPrintOrientation = pDoc->get_orientation(); BOOL fLandscape = (nPrintOrientation == LANDSCAPE); /* Get the App and its info. */ CPmwApp* pApp = GET_PMWAPP(); CPaperInfo* pPaperInfo = pApp->GetPaperInfo(nPrintOrientation); CPrinterInfo* pPrinterInfo = pApp->GetPrinterInfo(nPrintOrientation); CFixedRect PaperPhysicalMargins = pPaperInfo->PhysicalMargins(); /* Get the paper info. */ CPaperInfo* pLabelInfo = pDoc->GetPaperInfo(); CFixedRect Margins = pLabelInfo->Margins(); // If this is landscape, rotate the margins correctly. pPrinterInfo->OrientRect(&Margins); /* Get the label print dialog. */ CLabelPrintDialog* pDialog = (CLabelPrintDialog*)pc->m_pPD; /* Get the name list. */ CStdMacroServer* pMacroServer = pDoc->GetMacroServer(); NameListRecord* pNameList = pMacroServer->GetNameList(); /* Compute the number of slots we need to print. */ int nSlot = pc->m_nStartingLabel; int nSlots = pLabelInfo->Slots(); /* Run through all the slots. */ while (nSlot < nSlots && !UserAbort) { /* // See if the name we want is the one that's bound. */ if (pc->m_nBoundName != pc->m_nCurrentName) { pc->m_nBoundName = pc->m_nCurrentName; ASSERT(pc->m_pCursor != NULL); if (pc->m_pCursor != NULL) { pMacroServer->BindToRecord(pc->m_pCursor, pNameList->Name(pc->m_nBoundName)); pDoc->ReflowMacros(); } } /* // Setup the parameters for this slot so that we will draw in the correct // spot on the page. */ ASSERT(dwPage == 0 || dwPage == 1); CFixedRect SlotBounds = pLabelInfo->SlotBounds(nSlot); BOOL fBack = (dwPage == 1); CFixedPoint Dims = pLabelInfo->PaperDims(); CFixed lLeft = SlotBounds.Left; CFixed lTop = SlotBounds.Top; CFixed lWidth = SlotBounds.Width(); CFixed lHeight = SlotBounds.Height(); if (fLandscape) { switch (pPrinterInfo->Orientation()) { case 90: { // 90 degree rotation (like lasers) SlotBounds.Left = Dims.y - (lTop + lHeight); SlotBounds.Top = lLeft; break; } // case -1: // case 270: default: { // 270 degree rotation (like dot-matrix) SlotBounds.Left = lTop; SlotBounds.Top = Dims.x - (lLeft + lWidth); break; } } if (fBack) { // We are printing the back side. Reverse the slot. SlotBounds.Left = Dims.y - (SlotBounds.Left + lHeight); } SlotBounds.Right = SlotBounds.Left + lHeight; SlotBounds.Bottom = SlotBounds.Top + lWidth; } else { // Portrait. if (fBack) { // We are printing the back side. Reverse the slot. SlotBounds.Left = Dims.x - SlotBounds.Right; SlotBounds.Right = SlotBounds.Left + lWidth; } } CFixedPoint Org; Org.x = Margins.Left-PaperPhysicalMargins.Left; Org.y = Margins.Top-PaperPhysicalMargins.Top; if (fLandscape) { /* Printout is landscape. Reverse the origins. */ CFixed t = Org.x; Org.x = Org.y; Org.y = t; } PPNT Delta; Delta.x = MulFixed(SlotBounds.Left + Org.x, PAGE_RESOLUTION); Delta.y = MulFixed(SlotBounds.Top + Org.y, PAGE_RESOLUTION); printer_rc.source_pbox.x0 = SourcePbox.x0 - Delta.x; printer_rc.source_pbox.y0 = SourcePbox.y0 - Delta.y; printer_rc.source_pbox.x1 = SourcePbox.x1 - Delta.x; printer_rc.source_pbox.y1 = SourcePbox.y1 - Delta.y; printer_rc.scaled_source_x0 = /*SourceOrigin.x*/ - Delta.x*printer_rc.x_resolution; printer_rc.scaled_source_y0 = /*SourceOrigin.y*/ - Delta.y*printer_rc.y_resolution; /* // Do the draw. */ CPmwView::OnDraw(&pc->m_dcPrint); /* // Update the parameters for the next label to draw. */ if (pDialog->m_fCollate) { if (++pc->m_nCurrentName == pNameList->Names()) { /* Reset the name index. */ pc->m_nCurrentName = (pNameList->Names() == 0) ? -1 : 0; /* Advance to the next copy. */ pc->m_nCurrentCopy++; if (pc->m_nCurrentCopy == pDialog->m_nLabelCopies) { /* All done! */ break; } /* // Finished another set. // If we need to stop here, do so now. */ if (pDialog->m_fPageBreak) { /* Move to the next page. */ break; } } } else { /* We want to do the next copy. */ if (++pc->m_nCurrentCopy == pDialog->m_nLabelCopies) { /* Reset the copy count. */ pc->m_nCurrentCopy = 0; /* Advance to the next name. */ pc->m_nCurrentName++; if (pc->m_nCurrentName == pNameList->Names()) { /* All done! */ break; } /* // Finished another set. // If we need to stop here, do so now. */ if (pDialog->m_fPageBreak) { /* Move to the next page. */ break; } } } nSlot++; } /* // Restore the scaled source x0 from the saved values. */ printer_rc.source_pbox = SourcePbox; printer_rc.scaled_source_x0 = SourceOrigin.x; printer_rc.scaled_source_y0 = SourceOrigin.y; }
int CLabelView::GrindOutPrintJob(PrintContext& pc) { /* // Print our document(s). */ CLabelPrintDialog* pDialog = (CLabelPrintDialog*)pc.m_pPD; CPmwDoc* pDoc = GetDocument(); pDialog->ComputeTotals(); /* Extract the name list. */ CStdMacroServer* pMacroServer = pDoc->GetMacroServer(); NameListRecord* pNameList = pMacroServer->GetNameList(); BOOL fMergePrint = FALSE; int nNames = pNameList->Names(); int nTotalPages = pDialog->m_nTotalPages; int nError = FALSE; BOOL fOldShow = pMacroServer->ShowMacroValues(); StorageFile* pDatabaseFile = NULL; CFlatFileDatabase* pDatabase = NULL; CFlatFileDatabaseCursor* pCursor = NULL; if (GetConfiguration()->SupportsAddressBook(FALSE)) { // get sender values for address book. pMacroServer->BindSender(); } if (!fOldShow) { pMacroServer->ShowMacroValues(TRUE); pDoc->ReflowMacros(); } pc.m_pCursor = NULL; PPNT dims = pDoc->get_dimensions(); pc.m_source.x0 = 0; pc.m_source.y0 = 0; pc.m_source.x1 = dims.x; pc.m_source.y1 = dims.y; /* // Set the printing conditions. */ pc.m_nBoundName = -1; pc.m_nCurrentName = (nNames == 0) ? -1 : 0; pc.m_nCurrentCopy = 0; CString csFullName; TRY { csFullName = pDoc->GetPathManager()->LocatePath(pNameList->AddressBookName()); TRACE("Open database %s for data!\r\n", (LPCSTR)csFullName); if (nNames != 0) { ERRORCODE Error = CAddressBook::OpenAddressBookDatabase(csFullName, pDatabaseFile, pDatabase, FALSE); if (Error != ERRORCODE_None) { ThrowErrorcodeException(Error); } // Create a cursor on the database. pCursor = new CFlatFileDatabaseCursor; pCursor->Attach(pDatabase); pc.m_pCursor = pCursor; } int nFromPage = pc.m_pInfo->GetFromPage(); int nToPage = pc.m_pInfo->GetToPage(); int nError = 0; pc.SaveStartOfBand(); for (;;) { if (pc.m_fDoubleSided && (nFromPage != nToPage)) { // // 1. Put up the dialog telling the user we are about to begin. // CPmwDialog BeginDialog(IDD_DOUBLE_SIDED_BEGIN); if (BeginDialog.DoModal() != IDOK) { nError = -1; break; } // We need to do the double-sided thing. // // 2. Print the first half of the document. // // Print the key sheet now if it goes first. if ((pc.m_wDoubleSidedType & DBLPRN_FRONTKEYMASK) == DBLPRN_FrontKeyFirst) { if ((nError = PrintKeySheetFront(pc)) != 0) { break; } } // Print the document pages. pc.ToStartOfBand(); if ((nError = PrintLabelsFront(pc)) != 0) { break; } // Print the key sheet now if it goes last. if ((pc.m_wDoubleSidedType & DBLPRN_FRONTKEYMASK) == DBLPRN_FrontKeyLast) { if ((nError = PrintKeySheetFront(pc)) != 0) { break; } } // End the first print job. EndPrintDoc(pc, 0); // // 3. Put up the dialog telling the user to re-insert the stack. // CPmwDialog NotifyDialog(IDD_DOUBLE_SIDED_NOTIFY); if (NotifyDialog.DoModal() != IDOK) { nError = -1; break; } // // 4. Print the second half of the document. // // Start up the second print job. if ((nError = StartPrintDoc(pc)) != 0) { break; } // Print the key sheet now if it goes first. if ((pc.m_wDoubleSidedType & DBLPRN_BACKKEYMASK) == DBLPRN_BackKeyFirst) { if ((nError = PrintKeySheetBack(pc)) != 0) { break; } } // Print the document pages. pc.ToStartOfBand(); if ((nError = PrintLabelsBack(pc)) != 0) { break; } // Print the key sheet now if it goes last. if ((pc.m_wDoubleSidedType & DBLPRN_BACKKEYMASK) == DBLPRN_BackKeyLast) { if ((nError = PrintKeySheetBack(pc)) != 0) { break; } } } else { // Not double-sided. See what page(s) to print. // // Here are the cases: // From == 1, To == 1 (Front only) // From == 2, To == 2 (Back only) // From == 1, To == 2 (Both pages) // // So, we print page 1 if "from" is 1, and we print page 2 if "to" is 2. if (nFromPage == 1) { // Print the fronts in forward order. pc.ToStartOfBand(); if ((nError = PrintLabelsForward(pc, 0)) != 0) { break; } } if (nToPage == 2) { // Print the backs in forward order. pc.ToStartOfBand(); if ((nError = PrintLabelsForward(pc, 1)) != 0) { break; } } } // Done. Always leave! break; } } END_TRY BOOL fReflow = !fOldShow; pMacroServer->ShowMacroValues(fOldShow); if (nNames != 0 && pc.m_nCurrentName > 0) { /* Go back to the first name. */ if (pCursor != NULL) { pMacroServer->BindToRecord(pCursor, pNameList->Name(0)); } fReflow = TRUE; } if (fReflow) { pDoc->ReflowMacros(); } delete pCursor; pCursor = NULL; CAddressBook::CloseAddressBookDatabase(pDatabaseFile, pDatabase); return nError; }
SHORT CCatalogView::OnPrintDocument(PrintContext &pc, int32 aCurrentDocument, int32 aNumDocuments) { CPmwDoc *pDoc = GetDocument(); SHORT bError = FALSE; SHORT x, y; PCOORD grid_width, grid_height, step_width, step_height, text_height, new_x; PBOX pbox; int32 current_page, num_pages; #ifdef SPECIAL_CATALOG PCOORD x0 = 0, y0 = (PAGE_RESOLUTION*3)/4; #endif CCatalogPrint *pdlg = (CCatalogPrint *)pc.m_pPD; #ifdef OLD_CATALOG_STYLE CString csNameBuffer; #endif /* Compute the size of the grid and the step. */ PPNT dims = pDoc->get_dimensions(); PMGDatabasePtr const database = pDoc->get_database(); CTextStyle Style(database); #ifdef CATALOG_BACKGROUND PATTERN_CREATE_STRUCT pcs; pcs.bound.x0 = 0; pcs.bound.y0 = 0; pcs.bound.x1 = dims.x; pcs.bound.y1 = dims.y; pcs.pattern = 0; pcs.color = COLOR_WHITE; pcs.bcolor = MAKE_COLOR(0, 0, 0, 32); #endif #ifdef SPECIAL_CATALOG dims.x -= x0; dims.y -= y0; SHORT const across = 10; SHORT const down = 5; #else SHORT const across = pdlg->m_x_count; SHORT const down = pdlg->m_y_count; #endif grid_width = dims.x/across; grid_height = dims.y/down; step_width = scale_pcoord(grid_width, 9, 10); Style.SetDefault(); SHORT base_size; #ifdef DOUBLE_NAMES step_height = scale_pcoord(grid_height, 7, 10); text_height = (grid_height - step_height)/2; base_size = (SHORT)scale_pcoord(text_height, (72*6)/10, PAGE_RESOLUTION); #else step_height = scale_pcoord(grid_height, 9, 10); text_height = grid_height - step_height; base_size = (SHORT)scale_pcoord(text_height, (72*2)/3, PAGE_RESOLUTION); #endif /* Set the text style. */ if (base_size > 12) { base_size = 12; } Style.Size(MakeFixed(base_size)); Style.BaseSize(MakeFixed(base_size)); #ifdef DOUBLE_NAMES Style.Bold(TRUE); #endif Style.UpdateFontMetrics(); /* Figure out number of pages we will print. */ num_pages = #ifdef SPACE_ON_FIRST across + #endif m_picture_list.GetSize(); { SHORT n; n = across * down; num_pages = (num_pages + n - 1) / n; } current_page = 0; /* Run through all the graphics. */ ObjectListPtr list = pDoc->object_list(); int nMaxNames = m_picture_list.GetSize(); BOOL broken; int nEntry; for (broken = FALSE, nEntry = 0; !broken && nEntry < nMaxNames ;) { // Tell the user what we're doing. printer_update_name(NULL, GET_PMWAPP()->GetResourceStringPointer (IDS_BUILDING_PAGE), (VOIDPTR)&pc); // Make sure the current page is blank. list->destroy_objects(); // Build the next page. BeginWaitCursor(); #ifdef CATALOG_BACKGROUND PatternObjectPtr patobj; if ((patobj = database->create_pattern_object(&pcs)) != NULL) { pDoc->append_object(patobj); } #endif #ifdef SPECIAL_CATALOG for (pbox.y0 = y0, y = 0; #else for (pbox.y0 = 0, y = 0; #endif y < down && !broken; y++, pbox.y0 += grid_height) { #ifdef SPACE_ON_FIRST if (current_page == 0 && y == 0) { continue; } #endif pbox.y1 = pbox.y0 + step_height; #ifdef SPECIAL_CATALOG for (pbox.x0 = x0, x = 0; #else for (pbox.x0 = 0, x = 0; #endif x < across; x++, pbox.x0 += grid_width, nEntry++) { CFrameObject* pFrame; PPNT p; // Make sure we are on a good node. if (nEntry == nMaxNames) { /* All done! */ y = down; break; } CString strName = m_picture_list.GetAt(nEntry); /* Show the name. */ // multi_context.current_name = node->name; /* We have a selected node. Make a graphic for it. */ pbox.x1 = pbox.x0 + step_width; /* Create the graphic object. */ #ifdef OLD_CATALOG_STYLE csNameBuffer = m_chosen_dir; csNameBuffer += strName; #endif GraphicObjectPtr object; GRAPHIC_CREATE_STRUCT gcs; #ifdef OLD_CATALOG_STYLE gcs.m_csFileName = csNameBuffer; #else gcs.m_csFileName = strName; #endif if ((object = database->create_graphic_object(&gcs)) != NULL) { /* Get the size of the graphic. */ if (object->original_dims(&p)) { pDoc->append_object(object); dims.x = (PCOORD)step_width; dims.y = (PCOORD)step_height; /* Fit the graphic to its box. */ if ((new_x = scale_pcoord(dims.y, p.x, p.y)) > dims.x) { dims.y = scale_pcoord(dims.x, p.y, p.x); } else { dims.x = new_x; } /* Set the bound. */ PBOX bound; bound.x0 = (pbox.x0 + pbox.x1 - dims.x)/2; bound.x1 = bound.x0 + dims.x; bound.y0 = (pbox.y0 + pbox.y1 - dims.y)/2; bound.y1 = bound.y0 + dims.y; object->set_bound(bound); object->calc(); } else { delete object; object = NULL; } } /* Add a text frame for the name. */ FRAMEOBJ_CREATE_STRUCT fcs; LPCSTR text = strName; fcs.bound.x0 = pbox.x0; fcs.bound.x1 = pbox.x1; fcs.bound.y0 = pbox.y1; fcs.alignment = ALIGN_center; fcs.vert_alignment = ALIGN_top; // fcs.text = NULL; fcs.flags = 0; fcs.pStyle = NULL; #ifdef SPECIAL_CATALOG CHAR buffer[100]; LPCSTR ptr; if ((ptr = strrchr(text, '\\')) == NULL) { ptr = text; } else { /* Move off of '\'. */ ptr++; } strcpy(buffer, ptr); LPSTR foop; if ((foop = strrchr(buffer, '.')) != NULL) { /* Remove extension. */ *foop = '\0'; } fcs.bound.y1 = fcs.bound.y0+text_height; text = buffer; #elif defined(DOUBLE_NAMES) fcs.bound.y1 = fcs.bound.y0+text_height*2; CHAR name[64]; CHAR buffer[100]; LPCSTR ptr; if ((ptr = strrchr(text, '\\')) == NULL) { ptr = text; } else { /* Move off of '\'. */ ptr++; } BOOL blanket = FALSE; /* porpoise-ly (just for pun) */ if (object == NULL) { blanket = TRUE; } else { object->get_name(name, sizeof(name), -1); if (stricmp(name, ptr) == 0) { blanket = TRUE; strcpy(name, " "); } } if (blanket) { /* Blank it. */ strcpy(name, " "); } // sprintf(buffer, "%s\n%s", name, p); strcpy(buffer, name); strcat(buffer, "\n"); strcat(buffer, ptr); text = buffer; #else fcs.bound.y1 = fcs.bound.y0+text_height; #endif if ((pFrame = pDoc->create_frame_object(&fcs)) == NULL) { broken = TRUE; break; } int nCharacters = strlen(text); if (nCharacters != 0) { CTxp Txp(database); Txp.Init(pFrame, 0); Txp.SetHorizontalAlignment(fcs.alignment); Txp.Style(Style); TRY { CHARACTER* pText = new CHARACTER[nCharacters]; for (int n = 0; n < nCharacters; n++) { pText[n] = (CHARACTER)text[n]; } #ifdef DOUBLE_NAMES // First line is name + CR... int nLine1 = strlen(name)+1; // ...second line is the rest. int nLine2 = nCharacters - nLine1; // Insert line 1. Txp.InsertText(pText, nLine1); // Compute style for line 2: // no bold, and 8/10 the size. Txp.Style().Bold(FALSE); CFixed lSize = Txp.Style().BaseSize(); lSize = MulDivFixed(lSize, MakeFixed(8), MakeFixed(10)); Txp.Style().BaseSize(lSize); Txp.Style().Size(lSize); Txp.Style().UpdateFontMetrics(); // Insert line 2. Txp.InsertText(pText+nLine1, nLine2); #else Txp.InsertText(pText, nCharacters); #endif delete [] pText; } END_TRY } pDoc->append_object(pFrame); } } EndWaitCursor(); /* See if we broke! */ if (broken) { break; } /* Print the page. */ if (list->count() != 0) { /* We have objects! Print them. */ ++current_page; if (bError = CPmwView::OnPrintDocument(pc, current_page, num_pages)) { break; } } }
void CFontPreviewWnd::OnPaint() { CPaintDC dc(this); // device context for painting // Draw the background CRect rct; GetClientRect(rct); dc.FillSolidRect(&rct, RGB(255, 255, 255)); // Get the active view CMDIFrameWnd *pFrame = (CMDIFrameWnd*)GET_PMWAPP()->m_pMainWnd; CMDIChildWnd *pChild = (CMDIChildWnd *) pFrame->GetActiveFrame(); CPmwView *pView = (CPmwView *)pChild->GetActiveView(); // Find the current document CPmwDoc* pDoc = (CPmwDoc*)(pChild->GetActiveDocument()); ASSERT(pDoc != NULL); // Get the database PMGDatabasePtr database = pDoc->get_database(); // Get the current style CTextStyle Style(database); CTxp* pTxp = pView->GetTxp(); Style = pTxp->Style(); // If text color is white, make it black so we can see it FillFormatV1& Fill = Style.Fill(); if (Fill.m_ForegroundColor == COLOR_WHITE) { Fill.m_ForegroundColor = COLOR_BLACK; } // Get the entry for this face. FaceEntry* entry; int face_to_use = m_nFontID; int font_number = -1; if ((entry = typeface_server.face_list.get_face(face_to_use)) != NULL) { int nVariation = 0; if (Style.Bold()) { nVariation |= FONT_STYLE_Bold; } if (Style.Italic()) { nVariation |= FONT_STYLE_Italic; } VARIATION_TYPE vtype = entry->get_variation_type(nVariation); if (vtype == VARIATION_TYPE_VIRTUAL || vtype == VARIATION_TYPE_REGISTRATION) { // We want to use the preview font for "virtual" (PMW.FFL) fonts. Check if // the font has an entry in the preview font. font_number = entry->get_preview_font_number(nVariation); if (font_number != -1) { // Set the font number back to -1 in case we fail. It will // be reloaded if we can sucessfully use the preview font. font_number = -1; // We want to use the font preview. Try to switch to the preview font. PCSTR pn = typeface_server.preview_face_name(); if (pn != NULL) { int found_face; if ((found_face = typeface_server.find_face(pn, FALSE)) != -1) { face_to_use = found_face; font_number = entry->get_preview_font_number(nVariation); } } } } } // Get a database record for this face. // This will be a 'temporary' reference which we must free. PMGFontServer *pFontServer = (PMGFontServer*)pDoc->get_font_server(); DB_RECORD_NUMBER f_record = pFontServer->font_face_to_record(face_to_use); // Set the face in the style. The style gets its own reference. Style.Font(f_record); // Default to 36 point. Style.BaseSize(MakeFixed(36)); Style.Size(Style.BaseSize()); Style.UpdateFontMetrics(); // Free our temp reference. database->free_font_record(f_record, TRUE); // Build the redisplay context. RedisplayContext rc; rc.destination_hdc = dc.m_hDC; rc.hwnd = m_hWnd; rc.scaled_source_x0 = rc.scaled_source_y0 = 0; rc.destination_rect = rct; rc.destination_x0 = 0; rc.destination_y0 = 0; rc.x_resolution = GetDeviceCaps(dc.m_hDC, LOGPIXELSX); rc.y_resolution = GetDeviceCaps(dc.m_hDC, LOGPIXELSY); //rc.outline_gamma_curve = rc.bitmap_gamma_curve = screen_gamma_curve; //rc.set_check_interrupt(standard_check_interrupt, (void*)&rc); rc.terminate_interrupts = TRUE; rc.clip_rect = rct; // Initialize the redisplay context so we can use it rc.set_info(dc.m_hDC); rc.screen_to_pbox(&rct, &rc.source_pbox); // Create the frame object now. FRAMEOBJ_CREATE_STRUCT fcs; fcs.alignment = ALIGN_center; fcs.vert_alignment = ALIGN_middle; fcs.bound = rc.source_pbox; CFrameObject* pObject; if ((pObject = database->create_frame_object(&fcs)) != NULL) { // This object is not on the page! pObject->OnPage(FALSE); // Nor is it selected! pObject->remove_select_flags(SELECT_FLAG_boundary); // Prepare to add some text. CTxp Txp(database); CHARACTER Text[4]; if (font_number == -1) { Text[0] = 'T'; Text[1] = 'y'; Text[2] = 'p'; Text[3] = 'e'; } else { // We substituted the preview font int ch_base = font_number*4 + '!'; Text[0] = ch_base++; Text[1] = ch_base++; Text[2] = ch_base++; Text[3] = ch_base++; } // Stick in some text Txp.Init(pObject, 0); Txp.SetHorizontalAlignment(ALIGN_center); Txp.Style(Style); Txp.InsertText(Text, 4); // Select our palette in. CPalette* pOldPalette = dc.SelectPalette(pOurPal, FALSE); if (pOldPalette != NULL) { dc.RealizePalette(); } // And draw the object! UpdateStatePtr ustate; if ((ustate = pObject->update(&rc, &fcs.bound, &rct, NULL, REFRESH_ALL)) != NULL) { // See what happened switch (ustate->type) { case UPDATE_TYPE_Interrupted: { // This should not happen delete ustate; // Fall through to... } case UPDATE_TYPE_Terminated: { // Try again later InvalidateRect(&rct, FALSE); break; } default: { break; } } } pObject->destroy(); // Remove from the document. delete pObject; // Select our palette back out. if (pOldPalette != NULL) { dc.SelectPalette(pOldPalette, FALSE); } } // Do not call CBarMRUCombo::OnPaint() for painting messages }
void CPmwView::DoFileSaveAsGraphic() { BOOL fRet = FALSE; CPmwDoc *pDoc = GetDocument (); CString Filter; Filter.LoadString (IDS_SAVE_AS_GRAPHIC_FILT); // this array must match the order in the above string! SaveGraphicType graphicTypes[] = { None, Pmo, Bmp8, Bmp24, Jpeg, Png, Gif, Pcx, Tiff, WMeta }; CString InitialDir = pDoc->GetPathManager()->ExpandPath("[[P]]"); CString defExt = "*.pmo"; // This must match the first selection in the filter string CFileSaveAsGraphicDlg fileDlg(pDoc->something_selected(), Filter, defExt, InitialDir, this); PBOX WorldAll, WorldSel; pDoc->get_panel_world (&WorldAll, pDoc->get_current_panel()); if (pDoc->GetSelectBound (&WorldSel) != TRUE) WorldSel = WorldAll; CDC *pDC = GetDC(); if (!pDC) { return; // just bail... } int LogPixX = pDC->GetDeviceCaps (LOGPIXELSX); int LogPixY = pDC->GetDeviceCaps (LOGPIXELSY); fileDlg.SetDimensions(&WorldAll, &WorldSel, LogPixX, LogPixY); ReleaseDC (pDC); if (fileDlg.DoModal () == IDOK) { CString Filename = fileDlg.GetPathName (); CPoint cpDims; cpDims.x = fileDlg.m_Width; cpDims.y = fileDlg.m_Height; enum SaveGraphicType gt; gt = graphicTypes[fileDlg.GetGraphicTypeIndex ()]; ASSERT ((gt > None) && (gt < Invalid)); BOOL fSelected = fileDlg.IsSaveSelected(); ERRORCODE error = ERRORCODE_Memory; if (gt == Pmo) { // save as "PrintMaster Objects" file error = SavePMObjectsToFile(Filename, pDoc, fSelected); } else { CDibToGraphicFile pDibToGraphicFile(Filename); pDibToGraphicFile.CreateGraphicFile (pDoc, gt, cpDims, fSelected, NULL, LogPixX); error = pDibToGraphicFile.GetErrorCode(); } if (error != ERRORCODE_None) AfxMessageBox (IDS_ERROR_SAVING); else { if (fileDlg.AddToGallery() == TRUE) { CPMWCollection* pCollection = GetGlobalCollectionManager()->GetUserCollection(CPMWCollection::typeArt); if (pCollection != NULL) { int nResult = pCollection->ImportItem(Filename, NULL, NULL, fileDlg.m_strCategory, FALSE); if (nResult != ERRORCODE_None) AfxMessageBox (IDS_ERROR_SAVING); } } } } }
void CCardView::OnCardServer() { // Some configurations do not support online greetings ("card server"). if (!GetConfiguration()->SupportsCardServer()) { return; } // Get our document. CPmwDoc* pDoc = GetDocument(); if(GetGlobalContentManager()->CheckAccountStatus()) { CString strID = GetGlobalContentManager()->GetAccountID(); if(strID != "") { // Put up the card server dialog. CCardServerDialog Dialog(this); Dialog.m_ctTime = CTime::GetCurrentTime(); if (Dialog.DoModal() == IDOK) { // Put up the disclaimer dialog. CCardServerDisclaimer Disclaimer(this); if (Disclaimer.DoModal() == IDOK) { // Create the directory we want to use as our FTP source. CString csDir = pDoc->GetPathManager()->ExpandPath("[[U]]\\NETCARD"); if (!Util::MakeDirectory(csDir)) { // Not able to make the directory. // LPCSTR pFormat = "Can't create the directory\n%s"; LPCSTR pFormat = GET_PMWAPP()->GetResourceStringPointer(IDS_ErrCreateDirectory); CString csMessage; csMessage.Format(pFormat, (LPCSTR)csDir); AfxMessageBox(csMessage); return; } // Construct the text file. CString csTextFile; Util::ConstructPath(csTextFile, csDir, "INFO.INI"); CFile cfText; CString csVersion; CString csPPN; TRY { CFileException e; //if (!cfText.Open(csTextFile, // CFile::modeCreate // | CFile::modeWrite, // &e)) //{ // AfxThrowFileException(e.m_cause, e.m_lOsError); //} //do the time stuff //time zone difference from PST struct _timeb tstruct; _ftime( &tstruct ); int timecorrection = PacificTimeCorrection(tstruct.timezone); //get date of delivery - include current time struct tm when; CString strDate; CTime testtime = CTime::GetCurrentTime(); when = *testtime.GetLocalTm(NULL); SYSTEMTIME sysTime = *Dialog.GetTime(); if((when.tm_mday != sysTime.wDay) || (when.tm_mon != (sysTime.wMonth - 1))) { when.tm_mday = sysTime.wDay; when.tm_mon = sysTime.wMonth - 1; ConvertToPST(&when, timecorrection); CString str_ampm = "AM"; if( when.tm_hour > 12 ) /* Set up extension. */ str_ampm = "PM"; if( when.tm_hour > 12 ) /* Convert from 24-hour */ when.tm_hour -= 12; /* to 12-hour clock. */ if( when.tm_hour == 0 ) /*Set hour to 12 if midnight. */ when.tm_hour = 12; strDate.Format("%d/%d/%d %d:%d:%d%s", (int)((int)when.tm_mon + 1),when.tm_mday,when.tm_year,when.tm_hour,when.tm_min,when.tm_sec,str_ampm); } else { strDate = ""; } CString strPSTCorrection; strPSTCorrection.Format("%d", timecorrection); // Construct the version string. CString csEol = "\r\n"; csVersion = GetConfiguration()->ReplacementText('T'); csVersion += ' '; csVersion += GET_PMWAPP()->GetVersion(); csPPN = GET_PMWAPP()->GetParentPartNumber(); WritePrivateProfileString( "UserData", "UserId", GetGlobalContentManager()->GetAccountID(), csTextFile); WritePrivateProfileString( "UserData", "Description", csVersion, csTextFile); WritePrivateProfileString( "UserData", "SenderEmail", Dialog.m_csFrom, csTextFile); WritePrivateProfileString( "UserData", "RecipientEmail", Dialog.m_csTo, csTextFile); WritePrivateProfileString( "UserData", "sku", csPPN, csTextFile); WritePrivateProfileString( "CardData", "Title", Dialog.m_csTitle, csTextFile); WritePrivateProfileString( "CardData", "Date", strDate, csTextFile); WritePrivateProfileString( "CardData", "Offset", strPSTCorrection, csTextFile); #if 0 // Write version cfText.Write(csVersion, csVersion.GetLength()); cfText.Write(csEol, csEol.GetLength()); // Write "from" email address cfText.Write(Dialog.m_csFrom, Dialog.m_csFrom.GetLength()); cfText.Write(csEol, csEol.GetLength()); // Write "to" email address cfText.Write(Dialog.m_csTo, Dialog.m_csTo.GetLength()); cfText.Write(csEol, csEol.GetLength()); // Write Parent Part Number cfText.Write(csPPN, csPPN.GetLength()); cfText.Write(csEol, csEol.GetLength()); #endif //cfText.Close(); } CATCH_ALL(e) { // Could not write the text file. Complain. // LPCSTR pFormat = "Can't create the file\n%s"; LPCSTR pFormat = GET_PMWAPP()->GetResourceStringPointer(IDS_ErrCreateFile); CString csMessage; csMessage.Format(pFormat, (LPCSTR)csTextFile); AfxMessageBox(csMessage); return; } END_CATCH_ALL // Figure out how big we want the panels to be. CPoint cpFrontDims; CPoint cpInsideDims; PBOX World; pDoc->get_panel_world(&World, CARD_PANEL_Front); // Fit the front panel into a 425x425 square. PPNT FrontDims; FrontDims.x = World.x1 - World.x0; FrontDims.y = World.y1 - World.y0; double dScale = 425.0/(double)FrontDims.x; double dYScale = 425.0/(double)FrontDims.y; if (dScale > dYScale) dScale = dYScale; cpFrontDims.x = (int)((double)FrontDims.x*dScale); cpFrontDims.y = (int)((double)FrontDims.y*dScale); pDoc->get_panel_world(&World, CARD_PANEL_Inside); cpInsideDims.x = (int)((double)(World.x1-World.x0)*dScale); cpInsideDims.y = (int)((double)(World.y1-World.y0)*dScale); TRACE("Front: %d, %d; Inside: %d, %d\n", cpFrontDims.x, cpFrontDims.y, cpInsideDims.x, cpInsideDims.y); BOOL fSuccess = FALSE; CCardServerProgressDialog ProgressDialog(AfxGetMainWnd()); CString csName; Util::ConstructPath(csName, csDir, "front.gif"); ProgressDialog.SetStatus(IDS_BuildingFront); if (DumpPanel(CARD_PANEL_Front, csName, cpFrontDims)) { ProgressDialog.SetStatus(IDS_BuildingInside); Util::ConstructPath(csName, csDir, "inside.gif"); if(DumpPanel(CARD_PANEL_Inside, csName, cpInsideDims)) fSuccess = TRUE; } if (!fSuccess) { // "Can't create card pictures." AfxMessageBox(GET_PMWAPP()->GetResourceStringPointer(IDS_ErrWriteCardPictures)); return; } // Now, invoke the DLL to write the data. CCardServerDLL DLL; #ifdef WIN32 CString csDLLName = pDoc->GetPathManager()->ExpandPath("FTP32.DLL"); #else CString csDLLName = pDoc->GetPathManager()->ExpandPath("FTP16.DLL"); #endif // Startup the dialog. if (DLL.Startup(csDLLName)) { if(CheckForValidConnection()){ // Put up our progress dialog. // Send the files. int nResult = DLL.SendFiles(csDir, ProgressDialog); // Take down the progress dialog now. ProgressDialog.DestroyWindow(); // Shut down the DLL. DLL.Shutdown(); CPmwDialog Dialog(nResult == 0 ? IDD_CARD_SERVER_SUCCESS : IDD_CARD_SERVER_FAILURE); Dialog.DoModal(); } } else { // Not able to load the DLL. Complain. // LPCSTR pFormat = "The file\n%s\nis missing or bad."; LPCSTR pFormat = GET_PMWAPP()->GetResourceStringPointer(IDS_ErrMissingDLL); CString csMessage; csMessage.Format(pFormat, (LPCSTR)csDLLName); AfxMessageBox(csMessage); } }