#include <prntview.h>
Inheritance diagram for PrintView:
Public Member Functions | |
PrintView (Document *) | |
None. | |
virtual | ~PrintView () |
Destroys a printing view - this is because it has finished printing or something went wrong during printing. | |
virtual void | ContinueRenderView (RenderRegion *, Spread *, BOOL=TRUE, BOOL=TRUE, BOOL bForceImmediate=FALSE) |
Used by RenderRegion::DefaultRender() to carry on rendering a view. In this case (i.e. printing) it only gets called once, as it calls RenderView which prints the view in one go, i.e. we don't do background rendering. | |
virtual CNativeDC * | GetRenderDC () |
Access function for the device context of this printing view object. | |
virtual BOOL | GetForeBackMode () |
To find out if background rendering is on. | |
virtual void | SetForeBackMode (BOOL) |
Set the background render flag for this view. | |
virtual void | SetViewPixelSize () |
Sets up the normal and scaled pixel sizes according to this view. | |
void | AttachToDC (CNativeDC *pDC) |
Attach a PrintView to a particular printer DC. We need this because there is no special 'PrintCamView' to ask for it, so ScreenCamView gives us this DC when it receives an OnDraw() call, so we know which DC to print to. | |
void | OnDraw (CNativeDC *, OilRect) |
Do the printing, guv. | |
virtual BOOL | ViewStateChanged () |
Inform the PrintView that its OIL view object has changed the shared ViewState structure. | |
Matrix | ConstructRenderingMatrix (Spread *pSpread) |
From the given spread, construct a matrix that will convert spread coordinates to OS coordinates. | |
virtual DocRect | GetDocViewRect (Spread *) |
To find the rectangle describing the viewport onto the document. | |
virtual void | SetExtent (DocCoord, DocCoord) |
Informs the PrintView that the extent of the document has changed in some way and that the view must be altered to take this into account (namely the scrollbars). | |
virtual WorkRect | GetViewRect () |
To find the rectangle describing the viewport onto the document. | |
Static Public Member Functions | |
static void | CorrectRotatedRectangle (Rect *) |
Patches up rectangles after having been transformed by the rendering matrix. Because printing can involve a rotation through a multiple of 90 degress, the corners can become swapped, so we check for this and swap them back around if necessary. | |
Public Attributes | |
PrintPatchInfo | PatchInfo |
Protected Member Functions | |
void | PrintRegion (Spread *pSpread, DocRect ClipRect, CNativeDC *pDevContext, RenderType rType) |
virtual void | MakeNewRenderRegion (Spread *, DocRect, CNativeDC *, RenderType, BOOL PaintPaper=FALSE, Node *pInvalidNode=NULL) |
Renders the document to the printer. This function will build all the render regions needed to do a print. | |
Protected Attributes | |
CNativeDC * | PrintDC |
Friends | |
class | ScreenView |
Definition at line 108 of file prntview.h.
|
None.
Definition at line 143 of file prntview.cpp. 00144 { 00145 // Set up document; no CamView yet. 00146 pDoc = pOwnerDoc; 00147 pViewWindow = NULL; 00148 00149 // No DC yet 00150 PrintDC = NULL; 00151 00152 // BODGE ALERT!!! Do this properly sometime. 00153 pVState = new ViewState; 00154 PORTNOTE("printing", "removed broken memory handling") 00155 #ifndef EXCLUDE_FROM_XARALX 00156 if (pVState == NULL) 00157 AfxThrowMemoryException(); 00158 #endif 00159 00160 // Connect this view state to this view 00161 pVState->pView = this; 00162 00163 // Get print information for this document. 00164 PrintComponent *pPrint = 00165 (PrintComponent *) pOwnerDoc->GetDocComponent(CC_RUNTIME_CLASS(PrintComponent)); 00166 if (pPrint == NULL) 00167 { 00168 ERROR2RAW("Unable to find PrintComponent in document."); 00169 return; 00170 } 00171 00172 PrintControl *pPrintControl = pPrint->GetPrintControl(); 00173 if (pPrintControl == NULL) 00174 { 00175 ERROR2RAW("Unable to find PrintControl object in document component."); 00176 return; 00177 } 00178 00179 PrintMethodType PrintType = pPrintControl->GetPrintMethod(); 00180 00181 // Work out whether or not to Anti-alias printing 00182 if (PrintType == PRINTMETHOD_AABITMAP) 00183 { 00184 Quality AntiAlias(Quality::QualityMax); 00185 RenderQuality = AntiAlias; 00186 } 00187 }
|
|
Destroys a printing view - this is because it has finished printing or something went wrong during printing.
Definition at line 201 of file prntview.cpp.
|
|
Attach a PrintView to a particular printer DC. We need this because there is no special 'PrintCamView' to ask for it, so ScreenCamView gives us this DC when it receives an OnDraw() call, so we know which DC to print to.
Definition at line 552 of file prntview.cpp. 00553 { 00554 // Use this DC. 00555 PrintDC = pDC; 00556 00557 // If its a real DC (i.e. we are not being detached from a DC) then 00558 // get and remember the pixel size (used by PrintView::SetPixelSize()). 00559 if (PrintDC != NULL) 00560 { 00561 INT32 pixwidth = OSRenderRegion::GetFixedDCPPI(*pDC).GetWidth(); 00562 INT32 pixheight = OSRenderRegion::GetFixedDCPPI(*pDC).GetHeight();; 00563 00564 // Set our own idea of pixel size. 00565 PixelWidth = FIXED16(72000.0 / pixwidth); 00566 PixelHeight = FIXED16(72000.0 / pixheight); 00567 } 00568 }
|
|
From the given spread, construct a matrix that will convert spread coordinates to OS coordinates.
Reimplemented from View. Definition at line 633 of file prntview.cpp. 00634 { 00635 // First, translate page to origin, taking account of rotation flag. 00636 DocCoord TranslateToOrigin; 00637 DocRect PatchClipRect = PatchInfo.GetClipRect(FALSE,FALSE); 00638 00639 if (PatchInfo.Rotate) 00640 TranslateToOrigin = DocCoord(-PatchClipRect.lo.x, -PatchClipRect.lo.y); 00641 else 00642 TranslateToOrigin = DocCoord(-PatchClipRect.lo.x, -PatchClipRect.hi.y); 00643 00644 // Construct the translation matrix 00645 Matrix TranslateToOriginMatrix = Matrix(TranslateToOrigin.x, TranslateToOrigin.y); 00646 00647 // Do the optional rotation 00648 Matrix RotateMatrix(FIXED16(0)); 00649 if (PatchInfo.Rotate) 00650 RotateMatrix = Matrix(FIXED16(270)); 00651 00652 // Do the scale operation (convert from percentage to ratio) 00653 FIXED16 fxScale = PatchInfo.Scale / FIXED16(100); 00654 Matrix PrintScaleMatrix(fxScale, fxScale); 00655 00656 // Find the patch height so we can work out our final translation 00657 MILLIPOINT PatchHeight; 00658 PatchHeight = ((PatchInfo.Rotate) ? (PatchClipRect.Width()) : (PatchClipRect.Height())); 00659 00660 // Calculate the translation to move our patch rectangle to the bottom of the paper 00661 MILLIPOINT YShift = -(PatchInfo.PaperHeight - ((MILLIPOINT) (PatchHeight * fxScale))); 00662 MILLIPOINT XShift = 0; 00663 00664 // Conceptually speaking we now have a transform which scales the patch (area to print) 00665 // and positions it located at (0,-PaperHeight) bottom left on the paper with (x,y) increasing positive 00666 // to the left and up. This is the model used in the print control class to calculate a patch 00667 // position when working out best fit/multi/curstom fit. That class calculates +ive x,y translations 00668 // to fit pages onto paper considering (0,0) to be bottom left. ok so we now simply need to add 00669 // in those calculated translations and we're done. 00670 00671 XShift += PatchInfo.XTrans; 00672 YShift += PatchInfo.YTrans; 00673 00674 Matrix PatchTranslateMatrix(XShift, YShift); 00675 00676 // Generate a flip matrix if necessary 00677 Matrix FlipX; 00678 if (PatchInfo.EmulsionDown) 00679 { 00680 if (PatchInfo.Rotate) 00681 FlipX = Matrix(FIXED16(1), FIXED16(0), FIXED16(0), FIXED16(-1), 0, -PatchInfo.PaperHeight); 00682 else 00683 FlipX = Matrix(FIXED16(-1), FIXED16(0), FIXED16(0), FIXED16(1), PatchInfo.PaperWidth, 0); 00684 } 00685 00686 // MarkN wrote (way back when first descovered) 00687 // For some reason, NT takes the top-left corner of the printable area as the origin of the paper 00688 // so we compensate for that here by adjusting our X & Y translations accordingly 00689 00690 // NB. this used to be for NT only, but it seems that MS have brought Win32s and Win95 00691 // print borders into line with NT's setup so there is a consistent Win32 interface. 00692 00693 // Mike wrote (more recently) 00694 // I've stollen the code out of PrintControl, which used to do this but now doesn't. 00695 // Finally fix the operating system origin. The operating system drivers 00696 // render everything as if (PALeftMargin, PATopMargin) was the origin, so 00697 // we need to shift everything slightly. 00698 Matrix FixOpTranslate(-PatchInfo.PALeftMargin,PatchInfo.PATopMargin); 00699 00700 // The following matrix compositions MUST be performed in this order. 00701 // If you are tempted to optimise this code MAKE SURE THAT THEY ARE STILL 00702 // IN THIS ORDER WHEN YOU'VE FINISHED! 00703 00704 // Start with identity 00705 Matrix RenderMatrix; 00706 00707 // Translate to Origin 00708 RenderMatrix *= TranslateToOriginMatrix; 00709 00710 // Optional rotate 00711 if (PatchInfo.Rotate) 00712 RenderMatrix *= RotateMatrix; 00713 00714 // Scale (as in Print UI) 00715 RenderMatrix *= PrintScaleMatrix; 00716 00717 // Patch translation 00718 RenderMatrix *= PatchTranslateMatrix; 00719 00720 // Optional Flip around for emulsion down if nec. 00721 if (PatchInfo.EmulsionDown) 00722 RenderMatrix *= FlipX; 00723 00724 // Opsys translation 00725 RenderMatrix *= FixOpTranslate; 00726 00727 // All done. 00728 return RenderMatrix; 00729 }
|
|
Used by RenderRegion::DefaultRender() to carry on rendering a view. In this case (i.e. printing) it only gets called once, as it calls RenderView which prints the view in one go, i.e. we don't do background rendering.
Implements View. Definition at line 250 of file prntview.cpp. 00253 { 00254 // Disable bitmap caching but remember the old state so we can set it back 00255 ScopedFlagSetter fsBitmapCacheing(NodeRenderableBounded::bEnableCacheing, FALSE); 00256 00257 // make sure the region is ok 00258 if (pRRegion==NULL) 00259 return; 00260 00261 // We need to find out what sort of rendering we need to do, based on the options 00262 // in the print dialog. Start by finding the view and the doc we are printing 00263 Document* pDoc = GetDoc(); 00264 if (pDoc!=NULL) 00265 { 00266 // Find print control object for this document, to see if we are 00267 // printing via bitmap or normally 00268 PrintComponent *pPrintComponent = (PrintComponent *) 00269 pDoc->GetDocComponent(CC_RUNTIME_CLASS(PrintComponent)); 00270 00271 // see if it exists or not. 00272 if (pPrintComponent==NULL) 00273 { 00274 if (fDeleteRegionAfter) delete pRRegion; 00275 return; 00276 } 00277 00278 // Find the Print Control out of the component 00279 PrintControl *pPrintControl = pPrintComponent->GetPrintControl(); 00280 if (pPrintControl == NULL) 00281 { 00282 if (fDeleteRegionAfter) delete pRRegion; 00283 return; 00284 } 00285 00286 // and finally find out the printing method 00287 PrintMethodType PrintType = pPrintControl->GetPrintMethod(); 00288 if ((PrintType == PRINTMETHOD_AABITMAP) || (PrintType == PRINTMETHOD_BITMAP)) 00289 { 00290 // Get the region to clip all the rendering to 00291 DocRect ClipRect = pRRegion->GetClipRect(); 00292 Matrix ViewTrans = pRRegion->GetMatrix(); 00293 00294 // Tell the RenderRegion that I am going to start rendering. 00295 if (!pRRegion->StartRender()) 00296 { 00297 if (fDeleteRegionAfter) delete pRRegion; 00298 return; 00299 } 00300 00301 // Render the spreads paper marks where necessary 00302 RenderPageMarks(pRRegion, ViewTrans, ClipRect, pSpread); 00303 00304 // No - time to start rendering ink nodes - find the first one. 00305 pRRegion->SetSubRenderState(NULL); 00306 00307 // Work out whether to print just selected objects, or all of them. 00308 if (pPrintControl->GetObjPrintRange() == PRINTRANGEOBJ_ALL) 00309 { 00310 // Print *all* objects 00311 pRRegion->RenderTree(pSpread, FALSE); 00312 } 00313 else 00314 { 00315 // Print only *selected objects* 00316 // (We do this by not rendering any bounded object that is not selected). 00317 // 00318 // This is in a different loop so that we don't impact performance of 00319 // normal printing. 00320 PrintRenderCallback MyCallback(this); 00321 pRRegion->RenderTree(pSpread, FALSE, TRUE, &MyCallback); 00322 } 00323 00324 // Finished rendering. 00325 pRRegion->StopRender(); 00326 00327 // The region has finished rendering - delete it. 00328 if (fDeleteRegionAfter) delete pRRegion; 00329 } 00330 else 00331 { 00332 // Build the view matrix to use 00333 Matrix ViewMatrix = pRRegion->GetMatrix(); 00334 00335 // Try and render the view using the 3 pass system 00336 if (PrintMonitor::PrintMaskType==PrintMonitor::MASK_OPTIMAL) 00337 RenderOptimalView(pRRegion, ViewMatrix, pSpread, FALSE); 00338 else 00339 RenderSimpleView(pRRegion, ViewMatrix, pSpread, FALSE); 00340 } 00341 } 00342 }
|
|
Patches up rectangles after having been transformed by the rendering matrix. Because printing can involve a rotation through a multiple of 90 degress, the corners can become swapped, so we check for this and swap them back around if necessary.
Definition at line 813 of file prntview.cpp. 00814 { 00815 MILLIPOINT Tmp; 00816 00817 if (pRect->lo.x > pRect->hi.x) 00818 { 00819 Tmp = pRect->lo.x; 00820 pRect->lo.x = pRect->hi.x; 00821 pRect->hi.x = Tmp; 00822 } 00823 00824 if (pRect->lo.y > pRect->hi.y) 00825 { 00826 Tmp = pRect->lo.y; 00827 pRect->lo.y = pRect->hi.y; 00828 pRect->hi.y = Tmp; 00829 } 00830 }
|
|
To find the rectangle describing the viewport onto the document.
Implements View. Definition at line 529 of file prntview.cpp. 00530 { 00531 ERROR3("GetDocViewRect() called on unimplemented printing class!"); 00532 return DocRect(0,0,0,0); 00533 }
|
|
To find out if background rendering is on.
Implements View. Definition at line 449 of file prntview.cpp. 00450 { 00451 // PrintViews don't background render yet. 00452 return FALSE; 00453 }
|
|
Access function for the device context of this printing view object.
Implements View. Definition at line 219 of file prntview.cpp. 00220 { 00221 return PrintDC; 00222 }
|
|
To find the rectangle describing the viewport onto the document.
Implements View. Definition at line 506 of file prntview.cpp. 00507 { 00508 ERROR3("GetViewRect() called on unimplemented printing class!"); 00509 return WorkRect(0,0,0,0); 00510 }
|
|
Renders the document to the printer. This function will build all the render regions needed to do a print.
Reimplemented from View. Definition at line 589 of file prntview.cpp. 00590 { 00591 // Construct the transformation matrix for the spread. 00592 Matrix RenderMatrix = ConstructRenderingMatrix(pSpread); 00593 00594 // Go and create the new render region 00595 RenderRegion* pNewRegion = NULL; 00596 if (pViewWindow != NULL) 00597 pNewRegion = NewRenderRegion(ClipRect, RenderMatrix, GetRenderDC(), pSpread, rType); 00598 00599 // See if it worked 00600 if (pNewRegion == NULL) 00601 { 00602 TRACEALL( _T("Not enough memory to create render region\n")); 00603 return; 00604 } 00605 00606 pNewRegion->SetBackmostChangedNode(pInvalidNode); 00607 00608 // Add the region to the list of regions to render and start the 00609 // rendering process off if it has some ink to render 00610 Camelot.AddRenderRegion(pNewRegion); 00611 00612 // Here we will actually want to create all the strange types of render region 00613 // that we will need and render them on the spot instead of putting them in 00614 // the list of render regions. Don't forget to remove the #include app.h 00615 // when the use of the Camelot var goes away. 00616 }
|
|
Do the printing, guv.
Reimplemented from View. Definition at line 744 of file prntview.cpp. 00745 { 00746 if (CCamApp::IsDisabled()) 00747 return; // If the system is disabled, ignore 00748 00749 // Find out what sort of (printing) device context we have. 00750 RenderType rType = CCDC::GetType(pDevContext, TRUE); 00751 00752 // Find out which spread we are rendering 00753 Spread *pSpread = Document::GetSelectedSpread(); // PatchInfo.Spread 00754 00755 // Get the rendering matrix for this view. 00756 Matrix RenderMatrix = ConstructRenderingMatrix(pSpread); 00757 00758 // Get its inverse matrix 00759 Matrix InverseMatrix = RenderMatrix.Inverse(); 00760 00761 // Use this to convert OIL coords to spread coords 00762 DocRect ClipRect; 00763 ClipRect.lo.x = OilClipRect.lo.x; 00764 ClipRect.lo.y = OilClipRect.lo.y; 00765 ClipRect.hi.x = OilClipRect.hi.x; 00766 ClipRect.hi.y = OilClipRect.hi.y; 00767 InverseMatrix.transform(&ClipRect.lo); 00768 InverseMatrix.transform(&ClipRect.hi); 00769 00770 // Rendering matrix may involve a rotation when printing so correct the rectangle 00771 // for this if necessary. 00772 CorrectRotatedRectangle((Rect *) &ClipRect); 00773 ERROR3IF(ClipRect.lo.x > ClipRect.hi.x, "PrintView::OnDraw clipping rect is invalid"); 00774 ERROR3IF(ClipRect.lo.y > ClipRect.hi.y, "PrintView::OnDraw clipping rect is invalid"); 00775 00776 // Get the page clip rect 00777 DocRect SpreadClipRect = PatchInfo.GetClipRect(FALSE,FALSE); 00778 RenderMatrix.transform(&SpreadClipRect.lo); 00779 RenderMatrix.transform(&SpreadClipRect.hi); 00780 CorrectRotatedRectangle((Rect *) &SpreadClipRect); 00781 PatchInfo.InflateRectBy(&SpreadClipRect,TRUE,TRUE); 00782 InverseMatrix.transform(&SpreadClipRect.lo); 00783 InverseMatrix.transform(&SpreadClipRect.hi); 00784 CorrectRotatedRectangle((Rect *) &SpreadClipRect); 00785 00786 // Clip to spread rectangle 00787 SpreadClipRect = SpreadClipRect.Intersection(ClipRect); 00788 00789 // Make sure that the clip region is valid after the intersection 00790 if ((SpreadClipRect.IsValid()) && (!SpreadClipRect.IsEmpty())) 00791 { 00792 MakeNewRenderRegion(pSpread, SpreadClipRect, pDevContext, rType, TRUE); 00793 00794 } 00795 }
|
|
|
|
Informs the PrintView that the extent of the document has changed in some way and that the view must be altered to take this into account (namely the scrollbars).
Implements View. Definition at line 471 of file prntview.cpp. 00472 { 00473 // "Pixelise" the extent DocCoords. 00474 // Effectively, this helps ensure that the spread will be aligned to a whole pixel boundary 00475 // and allows both GDraw and GDI to consistently plot the same pixels when rendering 00476 // the same primitive. 00477 // We need to do this even when printing because things like 00478 // DocCoord::FindEnclosingChapter() default to pixelising extents so we get errors 00479 // because our coords do not lie within the pixelised extents. 00480 lolog.Pixelise(this); 00481 hilog.Pixelise(this); 00482 00483 // Convert the extent given in DocCoord to WorkCoords... 00484 pVState->WorkAreaExtent.lo = lolog.ToWork(pDoc, this); 00485 pVState->WorkAreaExtent.hi = hilog.ToWork(pDoc, this); 00486 }
|
|
Set the background render flag for this view.
Implements View. Definition at line 430 of file prntview.cpp. 00431 { 00432 // Nobody should try to set the printing to be background yet. 00433 ERROR3IF(NewFlag, "Trying to make a PrintView background render!"); 00434 }
|
|
Sets up the normal and scaled pixel sizes according to this view.
Implements View. Definition at line 410 of file prntview.cpp. 00411 { 00412 // Set the scaled pixel size 00413 ScaledPixelWidth = PixelWidth / Scale; 00414 ScaledPixelHeight = PixelHeight / Scale; 00415 }
|
|
Inform the PrintView that its OIL view object has changed the shared ViewState structure.
Implements View. Definition at line 380 of file prntview.cpp. 00381 { 00382 // Sanity checks. 00383 ERROR2IF(this==NULL,FALSE,"DocView member func called on NULL pointer"); 00384 ERROR2IF(pDoc==NULL,FALSE,"ViewStateChanged: There MUST be an owner doc for this view!"); 00385 00386 DocCoord ExtentLo; // coord of bottom-left of logical extent 00387 DocCoord ExtentHi; // coord of top-right of logical extent 00388 00389 // Read DocCoords extent of document & set extent in platform-indy ViewState struct. 00390 pDoc->GetExtents(&ExtentLo, &ExtentHi, &PhysExtent, this); 00391 00392 // Set extent in platform-indy ViewState struct 00393 SetExtent(ExtentLo, ExtentHi); 00394 00395 return TRUE; 00396 }
|
|
Definition at line 156 of file prntview.h. |
|
Definition at line 154 of file prntview.h. |
|
Definition at line 134 of file prntview.h. |