ExpressView Class Reference

Renders the current document into the device context given in OnDraw() This is primarily used for embedding documents. More...

#include <exprview.h>

Inheritance diagram for ExpressView:

View ListItem CCObject SimpleCCObject List of all members.

Public Member Functions

 ExpressView (Document *)
 First stage of two part constructor.
BOOL Init ()
 Second stage of two part constructor.
virtual ~ExpressView ()
 Destroys a printing view - this is because it has finished printing or something went wrong during printing.
virtual BOOL ViewStateChanged ()
 Inform the ExpressView that its OIL view object has changed the shared ViewState structure.
virtual void SetViewPixelSize ()
 Sets up the normal and scaled pixel sizes according to this view.
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 CDCGetRenderDC ()
 Access function for the device context of this ExpressView passed in via OnDraw().
virtual BOOL GetForeBackMode ()
 To find out if background rendering is on.
virtual void SetForeBackMode (BOOL)
 Set the background render flag for this view. Notes: Should never be asked to render in background.
BOOL DoRender (CDC *pDC, DocRect drClip, const DocRect &BitmapSize, BPP Bpp)
 Renders immediately this ExpressView's bitmap.
OILBitmapGetBitmap () const
 Having called DoRender() to render the document into a bitmap of the given specification, we can get a pointer to it here.
virtual DocRect GetDocViewRect (Spread *)
 To find the rectangle describing the viewport onto the document.
virtual void SetExtent (DocCoord, DocCoord)
 Informs the ExpressView 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.

Protected Member Functions

virtual Matrix ConstructRenderingMatrix (Spread *pSpread)
 From the given spread, construct a matrix that will convert spread coordinates to OS coordinates.
virtual void MakeNewRenderRegion (Spread *, DocRect, CDC *, 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

FIXED16 m_XScale
FIXED16 m_YScale
Matrix m_ScaleMatrix
GRenderBitmapm_pBitmapRegion
CDCm_pCDC
BPP m_Bpp
OILBitmapm_pBitmap

Detailed Description

Renders the current document into the device context given in OnDraw() This is primarily used for embedding documents.

Author:
Colin_Barfoot (Xara Group Ltd) <camelotdev@xara.com>
Date:
18/09/96

Definition at line 123 of file exprview.h.


Constructor & Destructor Documentation

ExpressView::ExpressView Document pOwnerDoc  ) 
 

First stage of two part constructor.

Author:
Colin_Barfoot (Xara Group Ltd) <camelotdev@xara.com> (from Tim)
Date:
18/09/96
Parameters:
pDocument - the document to attach to (i.e. the one to print) [INPUTS]
See also:
ExpressView::Init()

Definition at line 143 of file exprview.cpp.

00144 {
00145     // Set up document; no CamView yet.
00146     pDoc        = pOwnerDoc;
00147     pViewWindow = NULL;
00148 
00149     m_pBitmapRegion = NULL;
00150     m_pCDC          = NULL;
00151     m_pBitmap       = NULL;
00152     m_Bpp           = 8;
00153 
00154     m_XScale    = 1.0;
00155     m_YScale    = 1.0;
00156 }

ExpressView::~ExpressView  )  [virtual]
 

Destroys a printing view - this is because it has finished printing or something went wrong during printing.

Author:
Colin_Barfoot (Xara Group Ltd) <camelotdev@xara.com> (from Tim)
Date:
18/09/96
See also:
ExpressView; View

Definition at line 206 of file exprview.cpp.

00207 {
00208     delete pVState;
00209     pVState = 0;
00210 }


Member Function Documentation

Matrix ExpressView::ConstructRenderingMatrix Spread pSpread  )  [protected, virtual]
 

From the given spread, construct a matrix that will convert spread coordinates to OS coordinates.

Author:
Colin_Barfoot (Xara Group Ltd) <camelotdev@xara.com> (from Tim & Rik)
Date:
18/09/96
Parameters:
pSpread - the spread that is to be rendered. [INPUTS]
Returns:
The required transformation matrix.
See also:
ExpressView::OnDraw

Reimplemented from View.

Definition at line 488 of file exprview.cpp.

00489 {
00490     ERROR2IF(pSpread == NULL, Matrix(), "pSpread == NULL");
00491 
00492     // Get the PIXELISED origin of spread coordinates, in document coords
00493     DocCoord SpreadCoordOrigin = pSpread->GetSpreadCoordOrigin(TRUE, this);
00494 
00495     // Convert it into logical Work Coords
00496     // NOTE: We convert this via the spread, because the Spread Coord Origin can now
00497     // lie *outside* the current chapter/spread pasteboard bounds, and so the version
00498     // of this call that takes a document pointer can't find the enclosing chapter!
00499     // Of course, we know the enclosing chapter, because this point is in a known spread!
00500     WorkCoord WorkCoordOffset = SpreadCoordOrigin.ToWork(pSpread, this);
00501 
00502     // Offset it by the window scroll position
00503     WorkCoordOffset.x -= pVState->GetScrollPos().x;
00504     WorkCoordOffset.y -= pVState->GetScrollPos().y;
00505     
00506     // Construct the transformation matrix for the spread.
00507     Matrix RenderMatrix;
00508 
00509     // We can chop the 64bit values down to 32bit now, as we have them in the correct range
00510     Matrix TranslateToOrigin( (INT32)WorkCoordOffset.x, (INT32)WorkCoordOffset.y);
00511 
00512     Matrix ScaleMat(Scale, Scale);
00513 
00514     // The following matrix compositions MUST be performed in this order.
00515     // If you are tempted to optimise this code MAKE SURE THAT THEY ARE STILL
00516     // IN THIS ORDER WHEN YOU'VE FINISHED!
00517 
00518     // Apply scale factors to convert from millipoint distances to pixel distances...
00519     RenderMatrix *= ScaleMat;
00520 
00521     // And to the bitmap size
00522     RenderMatrix *= m_ScaleMatrix;
00523 
00524     // Apply scroll-offset translation to move origin to viewing position...
00525     RenderMatrix *= TranslateToOrigin;
00526 
00527     return RenderMatrix;
00528 }

void ExpressView::ContinueRenderView RenderRegion pRRegion,
Spread pSpread,
BOOL  fRenderPaper = TRUE,
BOOL  fDeleteRegionAfter = TRUE,
BOOL  bForceImmediate = FALSE
[virtual]
 

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.

Author:
Colin_Barfoot (Xara Group Ltd) <camelotdev@xara.com> (from Tim)
Date:
18/09/96
Parameters:
pRRegion - the region to use to render the view. [INPUTS] pSpread - the spread that is being rendered. fRenderPaper --- by default TRUE fDeleteRegionAfter --- if TRUE then the View will deallocate the render-region when it has finished rendering. If FALSE then it won't. By default TRUE.

Implements View.

Definition at line 256 of file exprview.cpp.

00259 {
00260     // Render the document in one operation.
00261     Matrix mxRndr = ConstructRenderingMatrix(pSpread);
00262 
00263     // Scroll offsets etc may have changed, so transfer matrix.
00264     pRRegion->SetMatrix(mxRndr);
00265 
00266 #ifdef RALPH
00267     // Wait until it's safe to enter
00268     CCamApp::EnterGDrawCriticalSection();
00269 #endif
00270 
00271     // Tell the RenderRegion that I am going to start rendering.
00272     if (!pRRegion->StartRender())
00273     {
00274         TRACEALL( _T("StartRender failed in RenderView\n"));
00275                                                             // will be deleted quickly
00276     }
00277     else
00278     {
00279         // Never render the paper but do all the ink (non-paper) parts of the document.
00280         pRRegion->RenderTree(pSpread, FALSE);
00281 
00282         // Reset state to new posn in tree.
00283         pRRegion->StopRender();
00284 
00285     }
00286     // Our render regions are always Bitmap ones
00287     // Assume there's only one
00288     GRenderBitmap* pGRBRegion = (GRenderBitmap*)pRRegion;
00289     ERROR3IF(!pGRBRegion->IS_KIND_OF(GRenderBitmap), "pGRBRegion isn't kinda GRenderBitmap");
00290     m_pBitmap = pGRBRegion->ExtractBitmapCopy();
00291 
00292 #ifdef RALPH
00293     // Let another process have a go
00294     CCamApp::ExitGDrawCriticalSection();
00295 #endif
00296 
00297 
00298     if (fDeleteRegionAfter)
00299     {
00300         delete pRRegion;
00301     }
00302 }

BOOL ExpressView::DoRender CDC pDC,
DocRect  drClip,
const DocRect BitmapSize,
BPP  Bpp
 

Renders immediately this ExpressView's bitmap.

Author:
Colin_Barfoot (Xara Group Ltd) <camelotdev@xara.com>
Date:
18/09/96
Returns:
TRUE if completed successfully FALSE otherwise

Definition at line 602 of file exprview.cpp.

00604 {
00605     ERROR2IF(pDC == NULL, FALSE, "pDC == NULL");
00606 
00607     TRACEUSER( "Colin", _T("dpi %d drClip %ld,%ld\tBitmapSize %ld,%ld BPP %d Quality %d\n"), 
00608                 pDC->GetDeviceCaps(LOGPIXELSX),
00609                 drClip.hix, drClip.hiy, 
00610                 BitmapSize.hix, BitmapSize.hiy,
00611                 Bpp,
00612                 RenderQuality.GetQuality());
00613     // Remember the current view so we can give it back after rendering
00614     View* pCurrentView = GetCurrent();
00615 
00616     m_pCDC  = pDC;
00617     m_Bpp   = Bpp;
00618 
00619     // Convert clip rect to OIL coords
00620 PORTNOTE("spread", "Multi-spread warning!")
00621     Spread* pSpread = pDoc->FindFirstSpread();
00622     ERROR2IF(!pSpread, FALSE, "pSpread NULL");
00623 
00624     pSpread->DocCoordToSpreadCoord(&drClip);
00625     OilRect orClip = drClip.ToOil(pSpread, this);
00626 
00627     // Scale to the bitmap size
00628     m_ScaleMatrix = Matrix(drClip, BitmapSize);
00629 
00630     // Construct the invalid render regions
00631     OnDraw(pDC, orClip);
00632 
00633     BOOL bSuccessful = FALSE;
00634     // And render them into the given DC
00635     if (m_pBitmapRegion != NULL)
00636     {
00637 #ifndef RALPH
00638         // Start the rendering indicator going.
00639         if (GetApplication()->GetpStatusLine())
00640             GetApplication()->GetpStatusLine()->SetRenderIndicator(Rendering);
00641 #endif
00642         // Render it.
00643         Error::RenderThreadIn();        // Make errors close window
00644         m_pBitmapRegion->DefaultRender();
00645         Error::RenderThreadOut();       // Normal errors
00646 
00647 #ifndef RALPH
00648         // Disable rendering indicator.
00649         if (GetApplication()->GetpStatusLine())
00650             GetApplication()->GetpStatusLine()->SetRenderIndicator(NotRendering);
00651 #endif
00652         bSuccessful = TRUE;
00653     }
00654     // Restore the view
00655     pCurrentView->SetCurrent();
00656     return bSuccessful;
00657 }

OILBitmap * ExpressView::GetBitmap void   )  const
 

Having called DoRender() to render the document into a bitmap of the given specification, we can get a pointer to it here.

Author:
Colin_Barfoot (Xara Group Ltd) <camelotdev@xara.com>
Date:
18/09/96
Returns:
A pointer to the currently rendered bitmap

Definition at line 671 of file exprview.cpp.

00672 {
00673     return m_pBitmap;
00674 }

DocRect ExpressView::GetDocViewRect Spread pSpread  )  [virtual]
 

To find the rectangle describing the viewport onto the document.

Author:
Colin_Barfoot (Xara Group Ltd) <camelotdev@xara.com> (from Phil)
Date:
18/09/96
Parameters:
pSpread - the spread that we are interested in [INPUTS]
Returns:
A DocCoords rectangle describing the viewport onto the document which this view is displaying. I.E. The top left corner of this rectangle is the same as the value returned by GetScrollOffsets() except in DocCoords.

Implements View.

Definition at line 466 of file exprview.cpp.

00467 {
00468     ERROR3("GetDocViewRect() called");
00469     return DocRect(0,0,0,0);
00470 }

BOOL ExpressView::GetForeBackMode  )  [virtual]
 

To find out if background rendering is on.

Author:
Colin_Barfoot (Xara Group Ltd) <camelotdev@xara.com> (from Tim)
Date:
18/09/96
Returns:
FALSE always, indicating foreground rendering only.

Implements View.

Definition at line 389 of file exprview.cpp.

00390 {
00391     // ExpressViews don't background render yet.
00392     return FALSE;
00393 }

CDC * ExpressView::GetRenderDC  )  [virtual]
 

Access function for the device context of this ExpressView passed in via OnDraw().

Author:
Colin_Barfoot (Xara Group Ltd) <camelotdev@xara.com> (from Tim)
Date:
18/09/96
Returns:
The printer DC.

Implements View.

Definition at line 226 of file exprview.cpp.

00227 {
00228     return m_pCDC;
00229 }

WorkRect ExpressView::GetViewRect  )  [virtual]
 

To find the rectangle describing the viewport onto the document.

Author:
Colin_Barfoot (Xara Group Ltd) <camelotdev@xara.com> (from Phil)
Date:
18/09/96
Returns:
A WorkCoords rectangle describing the viewport onto the document which this view is displaying. I.E. The top left corner of this rectangle is the same as the value returned by GetScrollOffsets().

Implements View.

Definition at line 443 of file exprview.cpp.

00444 {
00445     ERROR3("GetViewRect() called");
00446     return WorkRect(0,0,0,0);
00447 }

BOOL ExpressView::Init void   ) 
 

Second stage of two part constructor.

Author:
Colin_Barfoot (Xara Group Ltd) <camelotdev@xara.com>
Date:
18/09/96
Returns:
TRUE if successful, FALSE otherwise
See also:
ExpressView::ExpressView()

Reimplemented from SimpleCCObject.

Definition at line 171 of file exprview.cpp.

00172 {
00173     pVState = new ViewState;
00174     if (pVState == NULL)
00175     {
00176         TRACE( _T("Unable to create ViewState\n"));
00177         return FALSE;
00178     }
00179     // Connect this view state to this view
00180     pVState->pView = this;
00181 
00182 PORTNOTE("spread", "Multi-spread warning!")
00183     Spread* pSpread = pDoc->FindFirstSpread();
00184     DocView* pView = pDoc->GetFirstDocView();
00185 
00186     // Get the real bounds, in millipoints, of the document's first spread, converted
00187     // to pixels.
00188     GetScaledPixelSize(&ScaledPixelWidth, &ScaledPixelHeight);
00189 
00190     return TRUE;
00191 }

void ExpressView::MakeNewRenderRegion Spread pSpread,
DocRect  ClipRect,
CDC pDevContext,
RenderType  rType,
BOOL  PaintPaper = FALSE,
Node pInvalidNode = NULL
[protected, virtual]
 

Renders the document to the printer. This function will build all the render regions needed to do a print.

Author:
Colin_Barfoot (Xara Group Ltd) <camelotdev@xara.com> (from Rik)
Date:
18/09/96
Parameters:
pSpread - The Spread to render [INPUTS] ClipRect - the Clipping rectangle of the bit to draw pDevContext - the Device Context to render to rType - the Type of the render region PaintPaper - Should we draw the paper?
See also:
View::MakeNewRenderRegion

Definition at line 549 of file exprview.cpp.

00551 {
00552     // Construct the transformation matrix for the spread.
00553     Matrix RenderMatrix = ConstructRenderingMatrix(pSpread);
00554 
00555     // Go and create the new render region
00556     m_pBitmapRegion = NULL;
00557     double dpi = pDevContext->GetDeviceCaps(LOGPIXELSX);
00558     // We'll restrict it to 96dpi for now to avoid huge bitmaps
00559     if (dpi > 96.0)
00560     {
00561         TRACE( _T("dpi request for %f\n"), dpi);
00562         dpi = 96.0;
00563     }
00564 
00565     m_pBitmapRegion = new GRenderBitmap (ClipRect, RenderMatrix, Scale, m_Bpp, dpi, 
00566                                     FALSE, XARADITHER_ERROR_DIFFUSION, 0, TRUE);
00567 
00568     // See if it worked
00569     if (m_pBitmapRegion == NULL)
00570     {
00571         TRACEALL( _T("Not enough memory to create render region\n"));
00572         return;
00573     }
00574 
00575     // If the construction was succesful then
00576     // Attach the new RenderRegion to a Window and its DC for rendering...
00577     if (!m_pBitmapRegion->AttachDevice(this, pDevContext, pSpread))
00578     {
00579         // the AttachDevice failed, so tidy up
00580         delete m_pBitmapRegion;
00581         return;
00582     }
00583 
00584     m_pBitmapRegion->SetBackmostChangedNode(pInvalidNode);
00585 }

void ExpressView::SetExtent DocCoord  lolog,
DocCoord  hilog
[virtual]
 

Informs the ExpressView 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).

Author:
Colin_Barfoot (Xara Group Ltd) <camelotdev@xara.com> (from Phil)
Date:
18/09/96
Parameters:
Two DocCoords describing the low and high corners of a rectangle in logical [INPUTS] space describing the full extent of the document. I.E. the bottom-left corner of the last chapter and the top-right corner of the first.

Implements View.

Definition at line 411 of file exprview.cpp.

00412 {
00413     // "Pixelise" the extent DocCoords.
00414     // Effectively, this helps ensure that the spread will be aligned to a whole pixel boundary
00415     // and allows both GDraw and GDI to consistently plot the same pixels when rendering
00416     // the same primitive.
00417     lolog.Pixelise(this);
00418     hilog.Pixelise(this);
00419 
00420     // Convert the extent given in DocCoord to WorkCoords...
00421     pVState->WorkAreaExtent.lo = lolog.ToWork(pDoc, this);
00422     pVState->WorkAreaExtent.hi = hilog.ToWork(pDoc, this);
00423 }

void ExpressView::SetForeBackMode BOOL  NewFlag  )  [virtual]
 

Set the background render flag for this view. Notes: Should never be asked to render in background.

Author:
Tim_Browse (Xara Group Ltd) <camelotdev@xara.com>
Date:
10/2/95
Parameters:
NewFlag - New bg render flag. [INPUTS]

Implements View.

Definition at line 370 of file exprview.cpp.

00371 {
00372     // Nobody should try to set the printing to be background yet.
00373     ERROR3IF(NewFlag, "Trying to make a ExpressView background render!");
00374 }

void ExpressView::SetViewPixelSize  )  [virtual]
 

Sets up the normal and scaled pixel sizes according to this view.

Author:
Colin_Barfoot (Xara Group Ltd) <camelotdev@xara.com> (from Tim)
Date:
18/09/96

Implements View.

Definition at line 349 of file exprview.cpp.

00350 {
00351     // Set the scaled pixel size
00352     ScaledPixelWidth = PixelWidth / m_XScale;
00353     ScaledPixelHeight = PixelHeight / m_YScale;
00354 }

BOOL ExpressView::ViewStateChanged  )  [virtual]
 

Inform the ExpressView that its OIL view object has changed the shared ViewState structure.

Author:
Colin_Barfoot (Xara Group Ltd) <camelotdev@xara.com> (from Tim)
Date:
18/09/96
Returns:
TRUE if all ok; FALSE if not.
See also:
View::ViewStateChanged

Implements View.

Definition at line 319 of file exprview.cpp.

00320 {
00321     // Sanity checks.
00322     ERROR2IF(this==NULL,FALSE,"DocView member func called on NULL pointer");
00323     ERROR2IF(pDoc==NULL,FALSE,"ViewStateChanged: There MUST be an owner doc for this view!");
00324     
00325     DocCoord    ExtentLo;                       // coord of bottom-left of logical extent
00326     DocCoord    ExtentHi;                       // coord of top-right of logical extent
00327 
00328     // Read DocCoords extent of document & set extent in platform-indy ViewState struct.
00329     pDoc->GetExtents(&ExtentLo, &ExtentHi, &PhysExtent, this);
00330 
00331     // Set extent in platform-indy ViewState struct
00332     SetExtent(ExtentLo, ExtentHi);              
00333 
00334     return TRUE;
00335 }


Member Data Documentation

BPP ExpressView::m_Bpp [protected]
 

Definition at line 166 of file exprview.h.

OILBitmap* ExpressView::m_pBitmap [protected]
 

Definition at line 167 of file exprview.h.

GRenderBitmap* ExpressView::m_pBitmapRegion [protected]
 

Definition at line 163 of file exprview.h.

CDC* ExpressView::m_pCDC [protected]
 

Definition at line 165 of file exprview.h.

Matrix ExpressView::m_ScaleMatrix [protected]
 

Definition at line 161 of file exprview.h.

FIXED16 ExpressView::m_XScale [protected]
 

Definition at line 159 of file exprview.h.

FIXED16 ExpressView::m_YScale [protected]
 

Definition at line 160 of file exprview.h.


The documentation for this class was generated from the following files:
Generated on Sat Nov 10 03:54:07 2007 for Camelot by  doxygen 1.4.4