view.h

Go to the documentation of this file.
00001 // $Id: view.h 1323 2006-06-14 18:52:43Z 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 // Base class for kernel View objects.
00100 
00101 #ifndef INC_VIEW
00102 #define INC_VIEW
00103 
00104 #include "listitem.h"
00105 #include "quality.h"
00106 #include "matrix.h"
00107 #include "docrect.h"
00108 #include "rendtype.h"
00109 #include "oilrect.h"
00110 #include "rndrgn.h"
00111 #include "colcarry.h"
00112 #include "colmodel.h"
00113 //#include "viewbitmapcache.h"
00114 
00115 class CCamView;
00116 class ViewState;
00117 class Document;
00118 class wxDC;
00119 class RenderRegion;
00120 class ScanningRenderRegion;
00121 class Spread;
00122 class PaperRenderRegion;
00123 class Node;
00124 class PrintControl;
00125 //  WEBSTER-ranbirr-13/11/96
00126 #ifndef WEBSTER
00127 class CCPrintInfo;
00128 #endif //webster
00129 class ColourPlate;
00130 
00131 
00132 /********************************************************************************************
00133 
00134 >   class ProgressInfo
00135 
00136     Author:     Tim_Browse (Xara Group Ltd) <camelotdev@xara.com>
00137     Created:    05/25/95
00138     Purpose:    Encapsulates various bits of information required to provide a progress
00139                 display while printing/exporting via View::RenderSimpleView().
00140     SeeAlso:    View::RenderSimpleView
00141 
00142 ********************************************************************************************/
00143 
00144 class ProgressDisplay
00145 {
00146 public:
00147     ProgressDisplay();
00148 
00149     // Functions to do the normal progress display (eekk)
00150     void SetUp(RenderRegion *pRender, ScanningRenderRegion* pScanner);
00151     BOOL IncProgress(INT32 NumNodes = 1);
00152     BOOL FirstStageDone();
00153     BOOL SecondStageDone();
00154     void AllStagesDone();
00155     void StartBitmapPhase(INT32 NumBands);
00156     void StartBitmapPhaseBand(INT32 TotalNumScanlines);
00157     BOOL BitmapPhaseBandRenderedTo(INT32 ScanlinesRendered);
00158     BOOL EndBitmapPhaseBand();
00159 
00160     // Functions to deal with the Optimal Render View function
00161     // this is much simpler, so it gets its own functions.
00162     void SetUpOptimal(RenderRegion *pRender, ScanningRenderRegion* pScanner);
00163     BOOL SetNodesRendered(INT32 NumNodes);
00164 
00165 protected:
00166     // General variables
00167     BOOL DoProgressDisplay;
00168     BOOL IsPrinting;
00169     INT32 NumNodesRendered;
00170     INT32 LastProgressUpdate;
00171 
00172     // 'Normal' node rendering.
00173     INT32 ProgressInterval;
00174     INT32 FirstStageCount;
00175     INT32 SecondStageCount;
00176     INT32 ThirdStageCount;
00177 
00178     // Banded bitmap rendering
00179     INT32 BandSize;
00180     INT32 BandHeight;
00181     INT32 BandOffset;
00182     INT32 BandIncrement;
00183 
00184     // Optimal Rendering vars
00185     INT32 TotalNodes;
00186 //  WEBSTER-ranbirr-13/11/96
00187 #ifndef WEBSTER
00188     // Used to update print progress (if printing)
00189     CCPrintInfo *pPrintInfo;
00190 #endif //webster
00191     // How much we have scaled up the node count by to get a decent progress resolution.
00192     INT32 ProgressScaleFactor;
00193 };
00194 
00195 /********************************************************************************************
00196 
00197 < RenderViewResult
00198 
00199     Comment:    This is used to indicate the outcome of calling View::RenderSimpleView.
00200     SeeAlso:    View::RenderSimpleView
00201 
00202 ********************************************************************************************/ 
00203 
00204 enum RenderViewResult       
00205 { 
00206     RENDERVIEW_SUCCESS,
00207     RENDERVIEW_NOTNEEDED,
00208     RENDERVIEW_FAILURE, 
00209     RENDERVIEW_USERABORT 
00210 };
00211 
00212 
00213 
00214 /********************************************************************************************
00215 
00216 >   class View : public ListItem
00217 
00218     Author:     Tim_Browse (Xara Group Ltd) <camelotdev@xara.com>
00219     Created:    02/07/95
00220     Purpose:    The basic kernel view item.  This class contains minimal functionality to
00221                 maintain the 'current' view, and the connection from a kernel view
00222                 object to an OIL view object.
00223                 DocView and PrintView are derived from this class.
00224     SeeAlso:    DocView; PrintView
00225 
00226 ********************************************************************************************/
00227 
00228 class View : public ListItem
00229 {
00230     CC_DECLARE_DYNAMIC(View);
00231 
00232 public:
00233     View();
00234     virtual ~View();
00235     static void Deinit();
00236 
00238 //  Interface to the OIL layer CCamView and the kernel Document.
00239 
00240 protected:
00241     CCamView*           pViewWindow;            // Pointer to the associated CCamView
00242     Document*           pDoc;                   // Pointer to owner document.
00243     ViewState*          pVState;                // Device independent state of the view.
00244 
00245 public:
00246     BOOL ConnectToOilView(CCamView*);           // Set up the link to the CCamView object
00247     
00248     Document* GetDoc() const;                   // Returns document associated with this
00249     CCamView* GetConnectionToOilView() const;   // Which CCamView are we linked to
00250     PrintControl *GetPrintControl();            // Get print control for our document.
00251 
00252     virtual void SetViewState(ViewState*);
00253     virtual BOOL ViewStateChanged() = 0;        // informs us that ViewState has changed
00254 
00255 
00257 //  "Current" and "Selected" Views
00258 
00259 protected:
00260     static View* Current;                       // Global which records Current View
00261 
00262 public:
00263     static View* GetCurrent();                  // Returns which View is current
00264     BOOL SetCurrent();                          // Make this View current
00265     static void SetNoCurrent();                 // Make NO View current
00266 
00267     virtual void SetViewPixelSize() = 0;        // Set pixel size according to this view.
00268 
00270 //  Rendering
00271 
00272 public:
00273     void OnDraw(wxDC*, OilRect);
00274     virtual void ContinueRenderView(RenderRegion*, Spread*,
00275                                     BOOL fRenderPaper = TRUE,
00276                                     BOOL fDeleteRegionAfter = TRUE,
00277                                     BOOL bForceImmediate = FALSE) = 0;
00278     virtual wxDC* GetRenderDC() = 0;
00279     virtual void AllocateDC();
00280     virtual void DoneWithDC();
00281     virtual BOOL RenderTreeCallback(Node* pNode, RenderRegion* pRender) {return TRUE;}
00282 
00283     Quality RenderQuality;                      // WYSIWYG value (only freinds of Quality can
00284                                                 // get/set numeric value
00285 
00286     // Functions to render complex shapes into simple render regions
00287     RenderViewResult RenderOptimalView(RenderRegion*r, Matrix&, Spread*, BOOL);
00288     SlowJobResult RenderOptimalBitmapPhase(DocRect& ClipRect, Matrix&, Spread*, RenderRegion*, Node*, Node*,
00289                             BOOL RenderAllObjects, BOOL bPrintPaper, INT32&, ProgressDisplay* pProgress, INT32 TotalProgress);
00290 
00291     virtual RenderViewResult RenderSimpleView(RenderRegion*, Matrix&, Spread*, BOOL);
00292     SlowJobResult RenderBitmapPhase(DocRect& ClipRect, Matrix&, Spread*, RenderRegion*, Node*, Node*,
00293                                     BOOL bRenderAll, BOOL bPrintPaper, ProgressDisplay& Progress);
00294 
00295     static void DeInitOnTopRegion();
00296     static BOOL IsPrintableNodeSelected(Node *);
00297 
00298     virtual void RenderPaper(Spread*, DocRect, wxDC*, Matrix&);
00299     virtual BOOL RenderPageMarks(RenderRegion*, Matrix&, DocRect&, Spread*);
00300 
00301 protected:
00302     virtual void RenderPaper(RenderRegion*, Spread*);
00303 
00304     SlowJobResult RenderSimpleNodes(Node *pNode, RenderRegion *pRender,
00305                            ProgressDisplay& Progress, Node *pLastComplexNode = NULL);
00306     SlowJobResult RenderSimpleNodesUnclipped(Node *pNode, RenderRegion *pRender,
00307                            ProgressDisplay& Progress, Node *pLastComplexNode = NULL);
00308 
00309 private:
00310     static PaperRenderRegion* pPaperRegion;     // Region to use when rendering paper only
00311                                                 // (i.e. only for screen views)
00312 
00313     static PaperRenderRegion* pOnTopRegion;     // Region to use when rendering blobs only
00314                                                 // (i.e. only for screen views)
00315 
00316 //  ViewBitmapCache m_CachedBitmaps;            // Collection of bitmaps for rendering optimisation
00317 
00318 public:
00319     virtual BOOL GetForeBackMode() = 0;
00320     virtual void SetForeBackMode(BOOL) = 0;
00321 
00322     virtual Matrix ConstructRenderingMatrix(Spread *pSpread);
00323     // Ilan 06/06/00
00324     virtual Matrix ConstructScaledRenderingMatrix(Spread *pSpread, double ScaleFactor);
00325 
00326 protected:
00327     RenderRegion *NewRenderRegion(DocRect InvalidRect, Matrix& ViewMatrix,
00328                                     wxDC* pDevContext, Spread* pSpread, RenderType rType,
00329                                     bool fOwned = false );
00330     
00331     // Function to build and control the render regions
00332     virtual void MakeNewRenderRegion(Spread *, DocRect, wxDC *, RenderType, BOOL PaintPaper = FALSE, Node* pInvalidNode = NULL);
00333 
00334 public:
00335     // Get/Set the size of OIL pixels that this view uses.
00336     FIXED16 GetPixelWidth();
00337     FIXED16 GetPixelHeight();
00338     void GetPixelSize(FIXED16 *PixelWidth, FIXED16 *PixelHeight);
00339     virtual void SetPixelSize(FIXED16 PixelWidth, FIXED16 PixelHeight);
00340 
00341     FIXED16 GetScaledPixelWidth();
00342     FIXED16 GetScaledPixelHeight();
00343     void GetScaledPixelSize(FIXED16 *PixelWidth, FIXED16 *PixelHeight);
00344     virtual void SetScaledPixelSize(FIXED16 PixelWidth, FIXED16 PixelHeight);
00345 
00346     virtual double GetConvertToEditableShapesDPI();
00347 
00348 protected:
00349     // Actual size of OIL pixels that this view uses.
00350     FIXED16 PixelWidth,
00351             PixelHeight;
00352 
00353     // Scaled size of OIL pixels that this view uses.
00354     FIXED16 ScaledPixelWidth,
00355             ScaledPixelHeight;
00356 
00357 
00358 public:     // Colour contexts
00359     ColourContext *GetColourContext(ColourModel Model, BOOL ReturnNULLIfNone = FALSE);
00360             // Find the view's context for the given colour model
00361 
00362     ColourPlate *GetColourPlate(void);
00363             // Find out what ColourPlate separation (if any) this view is using
00364 
00365     void SetColourPlate(ColourPlate *NewPlate, BOOL bSendContextChanged = TRUE);
00366             // Set the colour separation mode that will be used in all future output
00367             // from this view
00368 
00369     void SetColourContext(ColourModel Model, ColourContext *NewContext = NULL);
00370             // Set or clear the special colour context for a given colour model.
00371             // The View will delete the context when it is finished with it, or when
00372             // you call this function again with another context or a NULL pointer.
00373 
00374     BOOL GetForceDefaultColourContexts(void) { return(ForceDefaultColourContexts); }
00375     
00376     BOOL SetForceDefaultColourContexts(BOOL bForceDefault = TRUE)
00377     {
00378         BOOL bOldForce = ForceDefaultColourContexts;
00379         ForceDefaultColourContexts = bForceDefault;
00380         return(bOldForce);
00381     }
00382 
00383 protected:
00384     ColourPlate *ColPlate;                  // NULL, or Current colour separation options
00385     ColourContextArray ColourContexts;      // Cached colour contexts using the ColourPlate
00386     BOOL ShouldDeleteContext[16];           // Flags for each cached context
00387 
00388     BOOL ForceDefaultColourContexts;        // Internal flag
00389                                             // if TRUE, forces GetColourContext to return global
00390                                             // default colour contexts rather than special ones.
00391                                             // Used by RenderOptimalBitmapPhase to disable colour
00392                                             // separation/correction in masked bitmap rendering.
00393 
00394 
00396 //  Scrolling, scaling and extents
00397 
00398 protected:
00399     FIXED16     Scale;                              // User viewing/printing scale factor.
00400     DocRect     PhysExtent;                         // Size of a document (bang!)
00401 
00402 public:
00403     WorkCoord GetScrollOffsets() const;
00404     virtual BOOL SetScrollOffsets(WorkCoord, BOOL RedrawNeeded = TRUE);
00405 
00406     FIXED16 GetViewScale() const;                   // ? the user scale in this view
00407     virtual BOOL SetViewScale(FIXED16);             // Set the user scale factor
00408 
00409     virtual DocRect GetDocViewRect(Spread*) = 0;
00410     virtual void SetExtent(DocCoord, DocCoord) = 0; // Reset the extent of the document
00411     virtual WorkRect GetViewRect() = 0;             // The physical rect of the view
00412 
00413 
00415 //  Dragging
00416 
00417 protected:
00418     BOOL        m_bSolidDrag;                       // Flag indicating that current drag is solid
00419 
00420 };
00421 
00422 
00423 
00424 
00425 /********************************************************************************************
00426 
00427 >   class CountView : Public View
00428 
00429     Author:     Phil_Martin (Xara Group Ltd) <camelotdev@xara.com>
00430     Created:    28/06/2004
00431     Purpose:    For counting "rendered" objects without actually rendering them
00432     SeeAlso:    View
00433 
00434 ********************************************************************************************/
00435 
00436 /*class CountView : Public View
00437 {
00438     virtual BOOL RenderSubtreeCallback(Node* pNode, RenderRegion* pRender);
00439 };
00440 */
00441 
00442 
00443 class ScopedFlagSetter
00444 {
00445 public:
00446     ScopedFlagSetter(BOOL& bTarget, BOOL bNewVal)
00447     {
00448         // Remeber a pointer to the target and the original value
00449         m_pbTarget = &bTarget;
00450         m_bOldVal = bTarget;
00451         // And set the target to the new value
00452         bTarget = bNewVal;
00453     }
00454 
00455     ~ScopedFlagSetter()
00456     {
00457         // Reset the target to the original value
00458         *m_pbTarget = m_bOldVal;
00459     }
00460     BOOL m_bOldVal;
00461     BOOL* m_pbTarget;
00462 };
00463 
00464 
00465 
00466 #endif  // INC_VIEW

Generated on Sat Nov 10 03:47:20 2007 for Camelot by  doxygen 1.4.4