exprview.cpp

Go to the documentation of this file.
00001 // $Id: exprview.cpp 1282 2006-06-09 09:46:49Z alex $
00002 /* @@tag:xara-cn@@ DO NOT MODIFY THIS LINE
00003 ================================XARAHEADERSTART===========================
00004  
00005                Xara LX, a vector drawing and manipulation program.
00006                     Copyright (C) 1993-2006 Xara Group Ltd.
00007        Copyright on certain contributions may be held in joint with their
00008               respective authors. See AUTHORS file for details.
00009 
00010 LICENSE TO USE AND MODIFY SOFTWARE
00011 ----------------------------------
00012 
00013 This file is part of Xara LX.
00014 
00015 Xara LX is free software; you can redistribute it and/or modify it
00016 under the terms of the GNU General Public License version 2 as published
00017 by the Free Software Foundation.
00018 
00019 Xara LX and its component source files are distributed in the hope
00020 that it will be useful, but WITHOUT ANY WARRANTY; without even the
00021 implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
00022 See the GNU General Public License for more details.
00023 
00024 You should have received a copy of the GNU General Public License along
00025 with Xara LX (see the file GPL in the root directory of the
00026 distribution); if not, write to the Free Software Foundation, Inc., 51
00027 Franklin St, Fifth Floor, Boston, MA  02110-1301 USA
00028 
00029 
00030 ADDITIONAL RIGHTS
00031 -----------------
00032 
00033 Conditional upon your continuing compliance with the GNU General Public
00034 License described above, Xara Group Ltd grants to you certain additional
00035 rights. 
00036 
00037 The additional rights are to use, modify, and distribute the software
00038 together with the wxWidgets library, the wxXtra library, and the "CDraw"
00039 library and any other such library that any version of Xara LX relased
00040 by Xara Group Ltd requires in order to compile and execute, including
00041 the static linking of that library to XaraLX. In the case of the
00042 "CDraw" library, you may satisfy obligation under the GNU General Public
00043 License to provide source code by providing a binary copy of the library
00044 concerned and a copy of the license accompanying it.
00045 
00046 Nothing in this section restricts any of the rights you have under
00047 the GNU General Public License.
00048 
00049 
00050 SCOPE OF LICENSE
00051 ----------------
00052 
00053 This license applies to this program (XaraLX) and its constituent source
00054 files only, and does not necessarily apply to other Xara products which may
00055 in part share the same code base, and are subject to their own licensing
00056 terms.
00057 
00058 This license does not apply to files in the wxXtra directory, which
00059 are built into a separate library, and are subject to the wxWindows
00060 license contained within that directory in the file "WXXTRA-LICENSE".
00061 
00062 This license does not apply to the binary libraries (if any) within
00063 the "libs" directory, which are subject to a separate license contained
00064 within that directory in the file "LIBS-LICENSE".
00065 
00066 
00067 ARRANGEMENTS FOR CONTRIBUTION OF MODIFICATIONS
00068 ----------------------------------------------
00069 
00070 Subject to the terms of the GNU Public License (see above), you are
00071 free to do whatever you like with your modifications. However, you may
00072 (at your option) wish contribute them to Xara's source tree. You can
00073 find details of how to do this at:
00074   http://www.xaraxtreme.org/developers/
00075 
00076 Prior to contributing your modifications, you will need to complete our
00077 contributor agreement. This can be found at:
00078   http://www.xaraxtreme.org/developers/contribute/
00079 
00080 Please note that Xara will not accept modifications which modify any of
00081 the text between the start and end of this header (marked
00082 XARAHEADERSTART and XARAHEADEREND).
00083 
00084 
00085 MARKS
00086 -----
00087 
00088 Xara, Xara LX, Xara X, Xara X/Xtreme, Xara Xtreme, the Xtreme and Xara
00089 designs are registered or unregistered trademarks, design-marks, and/or
00090 service marks of Xara Group Ltd. All rights in these marks are reserved.
00091 
00092 
00093       Xara Group Ltd, Gaddesden Place, Hemel Hempstead, HP2 6EX, UK.
00094                         http://www.xara.com/
00095 
00096 =================================XARAHEADEREND============================
00097  */
00098 
00099 // ExpressView - subclass of View for direct rendering to DC
00100 
00101 
00102 #include "camtypes.h"
00103 #include "exprview.h"
00104 
00105 //#include "view.h" - in camtypes.h [AUTOMATICALLY REMOVED]
00106 #include "vstate.h"
00107 //#include "errors.h" - in camtypes.h [AUTOMATICALLY REMOVED]
00108 #include "camelot.h"
00109 #include "ccdc.h"
00110 //#include "document.h" - in camtypes.h [AUTOMATICALLY REMOVED]
00111 //#include "rndrgn.h" - in camtypes.h [AUTOMATICALLY REMOVED]
00112 //#include "spread.h" - in camtypes.h [AUTOMATICALLY REMOVED]
00113 //#include "node.h" - in camtypes.h [AUTOMATICALLY REMOVED]
00114 //#include "app.h" - in camtypes.h [AUTOMATICALLY REMOVED]
00115 #include "grndbmp.h"
00116 //#include "bitmap.h" - in camtypes.h [AUTOMATICALLY REMOVED]
00117 #include "statline.h"
00118 
00119 
00120 DECLARE_SOURCE("$Revision: 1282 $");
00121 
00122 
00123 // Place any IMPLEMENT type statements here
00124 CC_IMPLEMENT_DYNAMIC(ExpressView, View)
00125 
00126 
00127 #define new CAM_DEBUG_NEW
00128 
00129 // Functions follow
00130 
00131 
00132 /********************************************************************************************
00133 
00134 >   ExpressView::ExpressView(Document *pOwnerDoc)
00135 
00136     Author:     Colin_Barfoot (Xara Group Ltd) <camelotdev@xara.com> (from Tim)
00137     Created:    18/09/96
00138     Inputs:     pDocument - the document to attach to (i.e. the one to print)
00139     Purpose:    First stage of two part constructor
00140     SeeAlso:    ExpressView::Init()
00141 
00142 ********************************************************************************************/
00143 ExpressView::ExpressView(Document *pOwnerDoc)
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 }
00157 
00158 
00159 
00160 /********************************************************************************************
00161 
00162 >   BOOL ExpressView::Init()
00163 
00164     Author:     Colin_Barfoot (Xara Group Ltd) <camelotdev@xara.com>
00165     Created:    18/09/96
00166     Purpose:    Second stage of two part constructor
00167     Returns:    TRUE if successful, FALSE otherwise
00168     SeeAlso:    ExpressView::ExpressView()
00169 
00170 ********************************************************************************************/
00171 BOOL ExpressView::Init()
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 }
00192 
00193 
00194 /********************************************************************************************
00195 
00196 >   ~ExpressView::ExpressView()
00197 
00198     Author:     Colin_Barfoot (Xara Group Ltd) <camelotdev@xara.com> (from Tim)
00199     Created:    18/09/96
00200     Purpose:    Destroys a printing view - this is because it has finished printing or
00201                 something went wrong during printing.
00202     SeeAlso:    ExpressView; View
00203 
00204 ********************************************************************************************/
00205 
00206 ExpressView::~ExpressView()
00207 {
00208     delete pVState;
00209     pVState = 0;
00210 }
00211 
00212 
00213 
00214 /********************************************************************************************
00215 
00216 >   CDC *ExpressView::GetRenderDC()
00217 
00218     Author:     Colin_Barfoot (Xara Group Ltd) <camelotdev@xara.com> (from Tim)
00219     Created:    18/09/96
00220     Returns:    The printer DC.
00221     Purpose:    Access function for the device context of this ExpressView passed in via
00222                 OnDraw()
00223 
00224 ********************************************************************************************/
00225 
00226 CDC* ExpressView::GetRenderDC()
00227 {
00228     return m_pCDC;
00229 }
00230 
00231 
00232 
00233 
00234 /********************************************************************************************
00235 
00236 >   void ExpressView::ContinueRenderView(RenderRegion* pRRegion, Spread* pSpread,
00237                                         BOOL fRenderPaper = TRUE,
00238                                         BOOL fDeleteRegionAfter = TRUE,
00239                                         BOOL bForceImmediate = FALSE)
00240 
00241     Author:     Colin_Barfoot (Xara Group Ltd) <camelotdev@xara.com> (from Tim)
00242     Created:    18/09/96
00243     Inputs:     pRRegion - the region to use to render the view.
00244                 pSpread - the spread that is being rendered.
00245                 fRenderPaper --- by default TRUE
00246                 fDeleteRegionAfter --- if TRUE then the View will deallocate the
00247                 render-region when it has finished rendering.  If FALSE then it
00248                 won't.  By default TRUE.
00249     Purpose:    Used by RenderRegion::DefaultRender() to carry on rendering a view.
00250                 In this case (i.e. printing) it only gets called once, as it calls
00251                 RenderView which prints the view in one go, i.e. we don't do
00252                 background rendering.
00253 
00254 ********************************************************************************************/
00255 
00256 void ExpressView::ContinueRenderView(RenderRegion* pRRegion, Spread* pSpread,
00257                                    BOOL fRenderPaper, BOOL fDeleteRegionAfter,
00258                                      BOOL bForceImmediate)
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 }
00303 
00304 
00305 /********************************************************************************************
00306 
00307 >   BOOL ExpressView::ViewStateChanged()
00308 
00309     Author:     Colin_Barfoot (Xara Group Ltd) <camelotdev@xara.com> (from Tim)
00310     Created:    18/09/96
00311     Returns:    TRUE if all ok;
00312                 FALSE if not.
00313     Purpose:    Inform the ExpressView that its OIL view object has changed the shared 
00314                 ViewState structure.
00315     SeeAlso:    View::ViewStateChanged
00316 
00317 ********************************************************************************************/
00318 
00319 BOOL ExpressView::ViewStateChanged()
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 }
00336 
00337 
00338 
00339 /********************************************************************************************
00340 
00341 >   void ExpressView::SetViewPixelSize()
00342 
00343     Author:     Colin_Barfoot (Xara Group Ltd) <camelotdev@xara.com> (from Tim)
00344     Created:    18/09/96
00345     Purpose:    Sets up the normal and scaled pixel sizes according to this view.
00346 
00347 ********************************************************************************************/
00348 
00349 void ExpressView::SetViewPixelSize()
00350 {
00351     // Set the scaled pixel size
00352     ScaledPixelWidth = PixelWidth / m_XScale;
00353     ScaledPixelHeight = PixelHeight / m_YScale;
00354 }
00355 
00356 
00357 
00358 /*********************************************************************************************
00359 
00360 >   void ExpressView::SetForeBackMode(BOOL NewFlag)
00361 
00362     Author:     Tim_Browse (Xara Group Ltd) <camelotdev@xara.com>
00363     Created:    10/2/95
00364     Inputs:     NewFlag - New bg render flag.
00365     Purpose:    Set the background render flag for this view.
00366     Notes:      Should never be asked to render in background
00367                                                                  
00368 *********************************************************************************************/
00369 
00370 void ExpressView::SetForeBackMode(BOOL NewFlag)
00371 {
00372     // Nobody should try to set the printing to be background yet.
00373     ERROR3IF(NewFlag, "Trying to make a ExpressView background render!");
00374 }
00375 
00376 
00377 
00378 /*********************************************************************************************
00379 
00380 >   BOOL ExpressView::GetForeBackMode()
00381 
00382     Author:     Colin_Barfoot (Xara Group Ltd) <camelotdev@xara.com> (from Tim)
00383     Created:    18/09/96
00384     Returns:    FALSE always, indicating foreground rendering only.
00385     Purpose:    To find out if background rendering is on
00386                                                                  
00387 *********************************************************************************************/
00388 
00389 BOOL ExpressView::GetForeBackMode()
00390 {
00391     // ExpressViews don't background render yet.
00392     return FALSE;
00393 }
00394 
00395 
00396 /********************************************************************************************
00397 
00398 >   void ExpressView::SetExtent(DocCoord lolog, DocCoord hilog)
00399 
00400     Author:     Colin_Barfoot (Xara Group Ltd) <camelotdev@xara.com> (from Phil)
00401     Created:    18/09/96
00402     Inputs:     Two DocCoords describing the low and high corners of a rectangle in logical
00403                 space describing the full extent of the document. I.E. the bottom-left corner
00404                 of the last chapter and the top-right corner of the first.
00405     Purpose:    Informs the ExpressView that the extent of the document has changed in some way and 
00406                 that the view must be altered to take this into account (namely the 
00407                 scrollbars).
00408 
00409 ********************************************************************************************/
00410 
00411 void ExpressView::SetExtent(DocCoord lolog, DocCoord hilog)
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 }
00424 
00425 
00426 
00427 
00428 
00429 
00430 /********************************************************************************************
00431 
00432 >   WorkRect ExpressView::GetViewRect()
00433 
00434     Author:     Colin_Barfoot (Xara Group Ltd) <camelotdev@xara.com> (from Phil)
00435     Created:    18/09/96
00436     Returns:    A WorkCoords rectangle describing the viewport onto the document which this
00437                 view is displaying. I.E. The top left corner of this rectangle is the same as
00438                 the value returned by GetScrollOffsets().
00439     Purpose:    To find the rectangle describing the viewport onto the document.
00440 
00441 ********************************************************************************************/
00442 
00443 WorkRect ExpressView::GetViewRect()
00444 {
00445     ERROR3("GetViewRect() called");
00446     return WorkRect(0,0,0,0);
00447 }
00448 
00449 
00450 
00451 
00452 /********************************************************************************************
00453 
00454 >   DocRect ExpressView::GetDocViewRect(Spread* pSpread)
00455 
00456     Author:     Colin_Barfoot (Xara Group Ltd) <camelotdev@xara.com> (from Phil)
00457     Created:    18/09/96
00458     Inputs:     pSpread - the spread that we are interested in
00459     Returns:    A DocCoords rectangle describing the viewport onto the document which this
00460                 view is displaying. I.E. The top left corner of this rectangle is the same as
00461                 the value returned by GetScrollOffsets() except in DocCoords.
00462     Purpose:    To find the rectangle describing the viewport onto the document.
00463 
00464 ********************************************************************************************/
00465 
00466 DocRect ExpressView::GetDocViewRect(Spread* pSpread)
00467 {
00468     ERROR3("GetDocViewRect() called");
00469     return DocRect(0,0,0,0);
00470 }
00471 
00472 
00473 
00474 
00475 /********************************************************************************************
00476 
00477 >   Matrix View::ConstructRenderingMatrix(Spread *pSpread)
00478 
00479     Author:     Colin_Barfoot (Xara Group Ltd) <camelotdev@xara.com> (from Tim & Rik)
00480     Created:    18/09/96
00481     Inputs:     pSpread - the spread that is to be rendered.
00482     Returns:    The required transformation matrix.
00483     Purpose:    From the given spread, construct a matrix that will convert spread
00484                 coordinates to OS coordinates.
00485     SeeAlso:    ExpressView::OnDraw
00486 
00487 ********************************************************************************************/
00488 Matrix ExpressView::ConstructRenderingMatrix(Spread *pSpread)
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 }
00529 
00530 
00531 /********************************************************************************************
00532 
00533 >   void ExpressView::MakeNewRenderRegion(  Spread* pSpread, DocRect ClipRect, 
00534                                         CDC* pDevContext, RenderType rType, BOOL PaintPaper, Node* pInvalidNode = NULL)
00535 
00536     Author:     Colin_Barfoot (Xara Group Ltd) <camelotdev@xara.com> (from Rik)
00537     Created:    18/09/96
00538     Inputs:     pSpread - The Spread to render
00539                 ClipRect - the Clipping rectangle of the bit to draw
00540                 pDevContext - the Device Context to render to
00541                 rType - the Type of the render region
00542                 PaintPaper - Should we draw the paper?
00543     Purpose:    Renders the document to the printer. This function will build all the render
00544                 regions needed to do a print.
00545     SeeAlso:    View::MakeNewRenderRegion
00546 
00547 ********************************************************************************************/
00548 
00549 void ExpressView::MakeNewRenderRegion(  Spread* pSpread, DocRect ClipRect, CDC* pDevContext, 
00550                                         RenderType rType, BOOL PaintPaper, Node* pInvalidNode)
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 }
00586 
00587 
00588 /********************************************************************************************
00589 
00590 >   BOOL ExpressView::DoRender(CDC* pDC, const DocRect& drClip, const DocRect& BitmapSize, 
00591                                 BPP Bpp)
00592 
00593     Author:     Colin_Barfoot (Xara Group Ltd) <camelotdev@xara.com>
00594     Created:    18/09/96
00595     Returns:    TRUE if completed successfully
00596                 FALSE otherwise
00597     Purpose:    Renders immediately this ExpressView's bitmap
00598 
00599 
00600 ********************************************************************************************/
00601 
00602 BOOL ExpressView::DoRender(CDC* pDC, DocRect drClip, const DocRect& BitmapSize, 
00603                                 BPP Bpp)
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 }
00658 
00659 
00660 /********************************************************************************************
00661 
00662 >   OILBitmap* ExpressView::GetBitmap() const
00663 
00664     Author:     Colin_Barfoot (Xara Group Ltd) <camelotdev@xara.com>
00665     Created:    18/09/96
00666     Returns:    A pointer to the currently rendered bitmap
00667     Purpose:    Having called DoRender() to render the document into a bitmap of the given
00668                 specification, we can get a pointer to it here.
00669 
00670 ********************************************************************************************/
00671 OILBitmap* ExpressView::GetBitmap() const
00672 {
00673     return m_pBitmap;
00674 }
00675 
00676 
00677 

Generated on Sat Nov 10 03:45:07 2007 for Camelot by  doxygen 1.4.4