spread.h

Go to the documentation of this file.
00001 // $Id: spread.h 1273 2006-06-08 19:41:59Z 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 // Spread class
00100 
00101 #ifndef INC_SPREAD
00102 #define INC_SPREAD
00103 
00104 #include "npaper.h"
00105 #include "convert.h"
00106 #include "dibconv.h"
00107 #include "paldefs.h"
00108 #include "animparams.h"
00109 
00110 class NodeGrid;
00111 
00112 // NEW_PASTEBOARD compile switch
00113 // =============================
00114 // Set this value to 1 to enable Jason's new pasteboard code. This should work fine, except
00115 // that load/save will sometimes get quickshapes or text in the wrong place. D'oh!
00116 // Note that I've set it to fail to compile until you've been made aware of the problem!
00117 
00118 #define NEW_PASTEBOARD 0
00119 
00120 
00121 /***********************************************************************************************
00122 
00123 >   class Spread : public NodeRenderablePaper
00124 
00125     Author:     Simon_Maneggio (Xara Group Ltd) <camelotdev@xara.com>
00126     Created:    25/4/93
00127     Purpose:    Spreads group together those pages which appear beside each other in the final
00128                 document. 
00129                 
00130     SeeAlso:    NodeRenderablePaper; Chapter; Page; Layer   
00131 
00132 ***********************************************************************************************/
00133 
00134 class Layer; 
00135 class Page;
00136 class View;
00137 
00138 class Spread: public NodeRenderablePaper
00139 {         
00140     CC_DECLARE_DYNAMIC( Spread )   
00141 
00142 public:         // Construction
00143     Spread();       
00144         
00145     Spread(Node* ContextNode,
00146            AttachNodeDirection Direction,   
00147            const DocRect& PasteRect,
00148            MILLIPOINT BleedOffset = 0, 
00149            BOOL Locked=FALSE,
00150            BOOL Mangled=FALSE,
00151            BOOL Marked=FALSE,
00152            BOOL Selected=FALSE
00153           );
00154 
00155 
00156 public:         // Spread interface
00157     virtual DocRect GetBoundingRect(BOOL DontUseAttrs=FALSE, BOOL HitTest=FALSE);
00158     DocRect GetDrawingSize() const;
00159 
00160     String  Describe(BOOL Plural, BOOL Verbose);                               
00161 
00162     Spread* FindNextSpread();
00163     Spread* FindPreviousSpread();
00164 
00165     Page*   FindFirstPageInSpread() const;
00166     Page*   FindLastPageInSpread() const;
00167 
00168     Document* FindParentDocument();
00169 
00170     Chapter* FindParentChapter();
00171 
00172     Layer*  FindActiveLayer();
00173     Layer*  FindFirstLayer() const; 
00174     Layer*  FindLastLayer() const; 
00175     Layer*  FindFirstGuideLayer() const;
00176     Layer*  FindFirstPageBackgroundLayer() const;
00177     Layer*  FindFirstFrameLayer() const;
00178     Layer*  FindLastFrameLayer() const;
00179 
00180     DimScale*   GetPtrDimScale();
00181 
00182     MILLIPOINT GetBleedOffset() const;          // Returns the current bleed offset
00183     BOOL SetBleedOffset(MILLIPOINT Bleed);      // Sets a new bleed offset 
00184 
00185     BOOL GetShowDropShadow() const;             // Returns the current drop shadow display state
00186     BOOL SetShowDropShadow(BOOL NewState);      // Sets a new current drop shadow display state
00187 
00188     virtual BOOL IsSpread() const;
00189     virtual SubtreeRenderState RenderSubtree(RenderRegion* pRender, Node** ppNextNode = NULL, BOOL bClip = TRUE);
00190     BOOL NeedsToExport(RenderRegion *pRender, BOOL VisibleLayersOnly = FALSE, BOOL CheckSelected = FALSE);
00191 
00192     void Render(RenderRegion* pRender);
00193       
00194 #ifdef _DEBUG
00195     void ShowDebugTreeDetails() const;
00196 #endif
00197 
00198     virtual UINT32 GetNodeSize() const;             // Returns size of node in bytes
00199 
00200     virtual void GetDebugDetails(StringBase* Str);  // This is used by the Debug Tree dialog
00201                                                     // It will probably be deleted when we ship (!!!)
00202 
00203     // Version 2 file format functions
00204     virtual BOOL WritePreChildrenWeb(BaseCamelotFilter* pFilter);
00205     virtual BOOL WritePreChildrenNative(BaseCamelotFilter* pFilter);
00206     virtual BOOL WriteBeginChildRecordsWeb(BaseCamelotFilter* pFilter);
00207     virtual BOOL WriteBeginChildRecordsNative(BaseCamelotFilter* pFilter);
00208     virtual BOOL WriteEndChildRecordsWeb(BaseCamelotFilter* pFilter);
00209     virtual BOOL WriteEndChildRecordsNative(BaseCamelotFilter* pFilter);
00210 
00211 protected:
00212     // Functions to write the actual data out
00213     virtual BOOL WriteSpreadInformation(BaseCamelotFilter* pFilter);
00214     virtual BOOL WriteSpreadScaling(BaseCamelotFilter* pFilter);
00215 
00216 
00217 public:         // Conversions between SpreadCoords and User/Page/Document Coords
00218     DocCoord GetUserOrigin();
00219     void SetUserOrigin(DocCoord origin) { UserOrigin=origin; }
00220 
00221     void SpreadCoordToDocCoord(DocCoord *pSpreadCoord) const;
00222     void SpreadCoordToDocCoord(DocRect  *pSpreadCoord) const;
00223     void DocCoordToSpreadCoord(DocCoord *pDocCoord) const;
00224     void DocCoordToSpreadCoord(DocRect  *pDocCoord) const;
00225             // Convert between Document and Spread coordinate space
00226 
00227     BOOL SpreadCoordToPagesCoord(DocCoord *pPagesCoord,  DocCoord SpreadCoord);
00228     BOOL PagesCoordToSpreadCoord(DocCoord *pSpreadCoord, DocCoord PagesCoord);
00229             // Convert between Page and Spread coordinate space
00230             // (Page coords are relative to the bottom left corner of the bounding rect of all pages)
00231 
00232     BOOL GetPagesRect(DocRect* pPagesRect);
00233 
00234     BOOL TextToSpreadCoord(DocCoord* pDocCoord, StringBase* pxText, StringBase* pyText);
00235     BOOL SpreadCoordToText(String_256* pxText, String_256* pyText, DocCoord DocCoord,
00236                             BOOL xUnitSpecifier=TRUE, BOOL yUnitSpecifier=TRUE, INT32 dp=-1);
00237 
00238     BOOL GetDecimalPlacesForPixelResolution(View *pView, INT32* dp);
00239 
00240 
00241 public:         // Grid related interface
00242     NodeGrid* FindFirstDefaultGridInSpread();
00243 
00244 public:
00245     BOOL CreateDefaultPageAndGrid(BOOL CreateGrid = TRUE);  // Sets up the spread so that it contains the default page & grid objects
00246 
00247 public:         // Page related interface
00248     DocRect GetPageBounds() const;          // The rectangle enclosing the spread's pages
00249     DocRect GetPageVisibleBounds() const;   // Same as above, but excludes invisible layers
00250 
00251     BOOL GetPageSize(MILLIPOINT *Width, MILLIPOINT *Height,
00252                      MILLIPOINT *Margin, MILLIPOINT *Bleed,
00253                      BOOL *Dps, BOOL *ShowDropShadow);
00254             // Retrieves the page size of all pages in the spread, as well as other page info
00255 
00256     BOOL SetPageSize(const MILLIPOINT Width, const MILLIPOINT Height,
00257                      const MILLIPOINT Margin, const MILLIPOINT Bleed,
00258                      const BOOL Dps, const BOOL ShowDropShadow);
00259             // Configures the spread's pages - sets their size (all pages must be the same size)
00260             // a margin of pasteboard area around the outside, single/double page spread, and
00261             // whether the pages should have a drop shadow.
00262 
00263 protected:
00264 #if NEW_PASTEBOARD
00265     BOOL AdjustAllPages(const MILLIPOINT Width, const MILLIPOINT Height,
00266                         const MILLIPOINT Margin, const BOOL Dps);
00267             // Ensures all pages are the given size, and butt up against each other properly
00268             // Also creates/deletes pages as necessary to achieve single/double page spread
00269             // (Equivalent of SetSizeOfAllPages)
00270 #else
00271     BOOL SetSizeOfAllPages(const MILLIPOINT Width, const MILLIPOINT Height,
00272                             const MILLIPOINT Margin, const BOOL Dps);
00273             // Ensures all pages are the given size, and butt up against each other properly
00274             // Also creates/deletes pages as necessary to achieve single/double page spread
00275             // (Equivalent of AdjustAllPages)
00276 
00277     BOOL AlignPasteboards(const DocRect NewPasteRect, const MILLIPOINT Margin);
00278             // Ensures that all pasteboards in the CHAPTER are large enough to encompass
00279             // all objects on the spreads.
00280 #endif
00281 
00282 
00283 public:         // Pasteboard related interface (see also the base class)
00284     DocRect GetWidePasteboard(View *pView);
00285             // Gets the wide pasteboard, which is: the area visible in the View or the
00286             // current pasteboard rectangle, whichever is the smaller.
00287 
00288     DocCoord GetSpreadCoordOrigin(BOOL Pixelise = TRUE, View *pView = NULL) const;
00289             // Retrieves the Document-Coordinate offset where the spread coord origin lies
00290             // (Add this origin to spread coords to convert to doc coords)
00291 
00292     void SetSpreadCoordOrigin(DocCoord NewOrigin);
00293             // Sets the spread coord origin. This effectively translates enclosed
00294             // pages/objects in the opposite direction by the amount the origin has moved.
00295             // Use with care! (talk to Jason)
00296 
00297     DocCoord GetMaxPasteboardSize(void);
00298             // Gets the maximum x,y extents to which the pasteboard can expand
00299 
00300     BOOL ExpandPasteboardToInclude(DocRect IncludeRect);
00301             // Expand (if possible) the pasteboard to include the given rectangle.
00302             // Returns FALSE if IncludeRect could not be included in the new pasteboard bounds
00303 
00304     void AdjustPasteboards(void);
00305             // Ensures that all pasteboards from this spread onwards are moved so that
00306             // there is no overlap, and also ensures that all default grids cover the
00307             // resulting new pasteboard bounds. Also makes sure that each pasteboard
00308             // is large enough to encompass all the objects contained in the spread.
00309 
00310     virtual void PolyCopyNodeContents(NodeRenderable* pNodeCopy);
00311 
00312 protected:      // Overridden base class interfaces
00313     virtual void SetInitialPasteboardRect(const DocRect& PasteRect);
00314             // When setting the initial rect, also now sets the Spread Coord Origin
00315 
00316     virtual BOOL PostImport();
00317             // Called after import of this document. The spread resizes its pasteboard automatically
00318 
00319 
00320 protected:      // Internal routines
00321     void RenderPasteboard(RenderRegion* pRender);
00322     void RenderBleedArea(RenderRegion* pRender);
00323     virtual Node* SimpleCopy();
00324     void CopyNodeContents(Spread* NodeCopy);
00325     void RenderDropShadows(RenderRegion* pRender);
00326 
00327 
00328 protected:      // Internal variables
00329     MILLIPOINT BleedOffset;
00330     BOOL ShowDropShadow;
00331     BOOL RalphDontShowPaper;
00332     DocCoord SpreadOrigin;      // The origin of the spread coordinate space (in document coords)
00333     DocCoord UserOrigin;        // The origin of user (displayed on screen) coordinates (ruler origin)
00334     AnimPropertiesParam     m_AnimPropertiesParam;
00335                                 // The following values for a GIF animation will be stored in a spread.
00336                                 // Animation loop   
00337                                 // Global Delay
00338                                 // Dither
00339                                 // Palette  
00340                                 // Number of Cols In Palette
00341                                 // Use System Colours flag
00342     
00343 public:
00344     // Selector functions.
00345     
00346     BOOL SetSpreadAnimPropertiesParam(const DWORD &Loop, const DWORD &GlobalDelay, const DITHER &Dither, 
00347                                         const WEB_PALETTE &WebPalette, const PALETTE_COLOURS &ColoursPalette,
00348                                         const DWORD &NumColsInPalette, const BOOL& UseSystemColours,
00349                                         const BOOL& IsBackgroundTransparent);
00350 
00351 
00352 
00353     BOOL GetSpreadAnimPropertiesParam(DWORD *Loop, DWORD *GlobalDelay, DITHER *Dither, 
00354                                         WEB_PALETTE *WebPalette, PALETTE_COLOURS* ColoursPalette,
00355                                         DWORD* NumColsInPalette, BOOL* UseSystemColours,
00356                                         BOOL* pIsBgTransparent);
00357 
00358     AnimPropertiesParam& GetSpreadAnimPropertiesParam();
00359     void SetSpreadAnimPropertiesParam(const AnimPropertiesParam& Param);
00360     void SetAnimationDelay(const DWORD GlobalDelay);
00361     void SetAnimationLoop(const DWORD &Loop);
00362 
00363     void SetAnimationColours(const DITHER& Dither, const WEB_PALETTE& WebPalette,
00364                              const PALETTE_COLOURS& ColoursPalette, const DWORD& NumColsInPalette,
00365                              const BOOL& IsBackgroundTransparent);
00366     void GetAnimationColours(DITHER * pDither, WEB_PALETTE * pWebPalette, 
00367                              PALETTE_COLOURS * pColoursPalette, DWORD * pNumColsInPalette,
00368                              BOOL * pIsBackgroundTransparent);
00369         
00370     virtual BOOL WriteSpreadAnimProperties(BaseCamelotFilter* pFilter);
00371 
00372     // The bounding rectangle for the animation
00373     DocRect GetAnimationBoundingRect();
00374     void SetAnimationBoundingRect(const DocRect& BoundingRect);
00375 
00376     // The quality level that the animation was captured at
00377     Quality GetAnimationQuality();
00378     void SetAnimationQuality(const Quality& NewQuality);
00379 
00380 //#endif //debug
00381 
00382 private:
00383     DimScale SpreadDimScale;
00384 };   
00385 
00386 #endif

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