xpfrgn.h

Go to the documentation of this file.
00001 // $Id: xpfrgn.h 1380 2006-06-28 11:15:10Z gerry $
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 #ifndef INC_XPFRGN
00100 #define INC_XPFRGN
00101 
00102 //#include "view.h" - in camtypes.h [AUTOMATICALLY REMOVED]
00103 //#include "becomea.h" - in camtypes.h [AUTOMATICALLY REMOVED]
00104 
00105 class PluginNativeFilter;
00106 class CapabilityTree;
00107 class TextStory;
00108 class TextLine;
00109 class FormatRegion;
00110 class CommonTransInfo;
00111 
00112 /********************************************************************************************
00113 
00114 >   class XPFRenderRegion : public RenderRegion
00115 
00116     Author:     Gerry_Iles (Xara Group Ltd) <camelotdev@xara.com>
00117     Created:    26/01/05
00118     Purpose:    This is the custom render region for the capabilities conversion
00119 
00120 ********************************************************************************************/
00121 
00122 class XPFRenderRegion : public RenderRegion
00123 {
00124     // Give my name in memory dumps
00125     CC_DECLARE_DYNAMIC(XPFRenderRegion);
00126 
00127     // Construction and destruction
00128     XPFRenderRegion(PluginNativeFilter* pFilter, CapabilityTree* pPlugCaps, CommonTransInfo* pTransInfo = NULL);
00129     ~XPFRenderRegion();
00130 
00131     virtual BOOL AttachDevice(View*, CNativeDC*, Spread* SpreadToAttach = NULL);
00132 
00133     // Starting and stopping the rendering process
00134     virtual BOOL StartRender();
00135     virtual BOOL StopRender();
00136 
00137     // Functions that are meant to do the drawing
00138     virtual void DrawPathToOutputDevice(Path *PathToRender, PathShape shapePath=PATHSHAPE_PATH);
00139     virtual void DrawRect(DocRect *RectToRender);
00140     virtual void DrawLine(const DocCoord &StartPoint, const DocCoord &EndPoint);
00141     virtual void DrawPixel(const DocCoord &Point);
00142 
00143     // Functions that are supposed to draw bitmaps
00144     virtual void DrawBitmap(const DocCoord &Point, KernelBitmap* pBitmap);
00145     virtual void DrawBitmap(const DocCoord &Point, UINT32 BitmapID, UINT32 ToolID = NULL);
00146     virtual BOOL DrawTransformedBitmap(NodeBitmap *pNodeBitmap);
00147 
00148     // Other Pure virtual drawing functions that have to be overidden
00149     virtual void DrawDragRect(DocRect *RectToRender);
00150     virtual void DrawBlob(DocCoord p, BlobType type);
00151     virtual void DrawCross(const DocCoord &Point, const UINT32 Size);
00152     virtual void DrawBitmapBlob(const DocCoord &Point, KernelBitmap* BlobShape);
00153     virtual void DrawBitmapBlob(const DocCoord &Point, ResourceID resID);
00154 
00155     // Pure Virtual functions that have to be overidden to use this class.
00156     // They all do nothing in this class
00157     virtual void InitClipping();
00158     virtual void InitAttributes();
00159     virtual void SetLineAttributes();
00160     virtual void SetOSDrawingMode();
00161     virtual void SetQualityLevel();
00162     virtual MILLIPOINT CalcPixelWidth();
00163     virtual MILLIPOINT CalcScaledPixelWidth();
00164 
00165     // Force this to return a sensible value so that the capture system
00166     // doesn't get horribly upset
00167     virtual double GetPixelsPerInch() { return(m_PixelsPerInch); }
00168 
00169     // Make sure that offscreen attrs are rendered when out of bounds
00170     virtual BOOL CheckOffscreenBounds() { return(FALSE); }
00171 
00172     // Function to work out what things this type of render region is capable of rendering
00173     virtual void GetRenderRegionCaps(RRCaps* pCaps);
00174 
00175     // We must have all nodes rendered by RenderTree
00176     virtual BOOL RenderPaperAsInk() { return(TRUE); }
00177 
00178 protected:
00179     PluginNativeFilter* m_pFilter;
00180     double m_PixelsPerInch;
00181     CommonTransInfo* m_pTransInfo;
00182 };
00183 
00184 
00185 class CommonTransInfo
00186 {
00187 public:
00188     CommonTransInfo();
00189 
00190     BOOL IsCommonType() { return(m_bCommonType); }
00191     void UpdateCommonType(UINT32 Type);
00192     UINT32 GetCommonType();
00193     BOOL UsesNonAlpha() { return(m_bUsesNonAlpha); }
00194 
00195 protected:
00196     BOOL m_bCommonType;
00197     UINT32 m_CommonType;
00198     BOOL m_bUsesNonAlpha;
00199 };
00200 
00201 
00202 class SpanListItem : public ListItem
00203 {
00204 public:
00205     CC_DECLARE_DYNAMIC( SpanListItem )
00206     SpanListItem(Node* pFirstNode = NULL, Node* pLastNode = NULL, BOOL bNonAlpha = FALSE)
00207     {
00208         m_pFirstNode = pFirstNode;
00209         m_pLastNode = pLastNode ? pLastNode : pFirstNode;
00210         m_bNonAlphaTrans = bNonAlpha;
00211     }
00212     
00213     Node* m_pFirstNode;                 // pointer to first node in span
00214     Node* m_pLastNode;                  // pointer to last node in span
00215     BOOL m_bNonAlphaTrans;              // TRUE if span contains any non-alpha transparency
00216 };
00217 
00218 
00219 class NodeThreeBoolListItem : public ListItem
00220 {
00221 public:
00222     CC_DECLARE_DYNAMIC( NodeThreeBoolListItem )
00223 
00224     NodeThreeBoolListItem(Node* pNode = NULL, BOOL bFirst = FALSE, BOOL bSecond = FALSE, BOOL bThird = FALSE)
00225     {
00226         m_pNode = pNode;
00227         m_bFirst = bFirst;
00228         m_bSecond = bSecond;
00229         m_bThird = bThird;
00230     }
00231     
00232     Node* m_pNode;          // pointer to node
00233     BOOL m_bFirst;          // first flag
00234     BOOL m_bSecond;         // second flag
00235     BOOL m_bThird;          // third flag
00236 };
00237 
00238 
00239 
00240 /********************************************************************************************
00241 
00242 >   class XPFRenderCallback : public RenderCallback
00243 
00244     Author:     Gerry_Iles (Xara Group Ltd) <camelotdev@xara.com>
00245     Created:    26/01/05
00246     Purpose:    This is the custom render callback class for the capabilities conversion
00247 
00248 ********************************************************************************************/
00249 
00250 class XPFRenderCallback : public RenderCallback
00251 {
00252 public:
00253     XPFRenderCallback(PluginNativeFilter* pFilter, XPFRenderRegion* pXPFRegion, CapabilityTree* pCapTree, INT32 ConvertPass);
00254     ~XPFRenderCallback();
00255 
00256     virtual BOOL BeforeNode(RenderRegion* pRegion, Node* pNode);
00257     virtual BOOL BeforeSubtree(RenderRegion* pRegion, Node* pNode, Node** ppNextNode, BOOL bClip, SubtreeRenderState* pState);
00258 //  virtual BOOL AfterSubtree(RenderRegion* pRegion, Node* pNode);
00259 
00260 public:
00261     Spread* GetNewSpread() { return(m_pNewSpread); }
00262     void SetAttachContext(Node* pContext, AttachNodeDirection Direction)
00263     {
00264         m_pContextNode = pContext;
00265         m_Direction = Direction;
00266     }
00267 
00268     BOOL ConvertNodes();
00269 
00270 protected:
00271     BOOL ConvertNodesForPass2();
00272     BOOL ConvertNodesForPass3();
00273     BOOL ConvertNodesForPass4();
00274     BOOL ConvertNodesForPass5();
00275 
00276     void RemoveChildAttrs(Node* pNode, CCRuntimeClass* pClass);
00277     NodeAttribute* FindChildAttr(Node* pNode, CCRuntimeClass* pClass);
00278 
00279     Node* RenderNodesToBitmap(Node* pFirstNode, Node* pLastNode, BOOL bNonAlphaTrans);
00280     KernelBitmap* RenderFillToBitmap(Node* pNode, DocRect& BoundsRect);
00281     KernelBitmap* RenderTransToBitmap(Node* pNode, DocRect& BoundsRect, UINT32* pTransType);
00282     KernelBitmap* RenderFillAndTransToBitmap(Node* pNode, DocRect& BoundsRect);
00283 
00284     TextStory* ReformatTextStory(TextStory* pStory);
00285     Node* ReformatTextLine(TextLine* pLineNode, FormatRegion* pFormatRegion);
00286     BOOL CopyAttributesFromNode(Node* pDestNode, Node* pSrcNode);
00287 
00288     BOOL DoesNodeUseNonAlphaTrans(Node* pRootNode);
00289     BOOL FindCommonTransTypeToApply(Node* pFirstNode, Node* pLastNode, UINT32* pCommonType);
00290 
00291 private:
00292     INT32 m_ConvertPass;
00293     PluginNativeFilter* m_pFilter;
00294     XPFRenderRegion* m_pXPFRegion;
00295     CapabilityTree* m_pCapTree;
00296     Spread* m_pNewSpread;
00297     Node* m_pContextNode;
00298     AttachNodeDirection m_Direction;
00299     Node* m_pSpanParent;
00300     List m_ConvertList;
00301     List m_ParentList;
00302 };
00303 
00304 
00305 
00306 class XPFSpanRenderCallback : public RenderCallback
00307 {
00308 public:
00309     typedef enum
00310     {
00311         RS_BEFORESPAN = 0,
00312         RS_INSPAN,
00313         RS_AFTERSPAN,
00314     } RenderStateType;
00315 
00316     XPFSpanRenderCallback(Node* pFirst, Node* pLast, BOOL bBackground)
00317     {
00318         m_pFirstNode = pFirst;
00319         m_pLastNode = pLast;
00320         m_bBackground = bBackground;
00321         m_RenderState = RS_BEFORESPAN;
00322     }
00323 
00324     virtual BOOL BeforeNode(RenderRegion* pRegion, Node* pNode);
00325     virtual BOOL BeforeSubtree(RenderRegion* pRegion, Node* pNode, Node** ppNextNode, BOOL bClip, SubtreeRenderState* pState);
00326     virtual BOOL AfterSubtree(RenderRegion* pRegion, Node* pNode);
00327 
00328 protected:
00329     Node* m_pFirstNode;                 // pointer to first node in span
00330     Node* m_pLastNode;                  // pointer to last node in span
00331     BOOL m_bBackground;                 // True if nodes before first should be rendered
00332     RenderStateType m_RenderState;
00333 };
00334 
00335 
00336 /********************************************************************************************
00337 
00338 >   class XPFView : public View
00339 
00340     Author:     Gerry_Iles (Xara Group Ltd) <camelotdev@xara.com>
00341     Created:    16/08/2005
00342 
00343     Purpose:    Simple view class for use when converting for plugin filters
00344 
00345     SeeAlso:    View
00346 
00347 ********************************************************************************************/
00348 
00349 class XPFView : public View
00350 {
00351     CC_DECLARE_DYNAMIC(XPFView);
00352 public:
00353     virtual ~XPFView(); 
00354     BOOL Init(double DPI);
00355 
00356 public:
00357     virtual BOOL ViewStateChanged();            // informs us that ViewState has changed
00358 
00359 public:
00360     virtual void SetViewPixelSize();            // Set pixel size according to this view.
00361 
00362 public:
00363     virtual void ContinueRenderView(RenderRegion*, Spread*, BOOL = TRUE, BOOL = TRUE,
00364                                      BOOL bForceImmediate = FALSE);
00365     virtual CNativeDC *GetRenderDC();
00366 
00367 public:
00368     virtual BOOL GetForeBackMode();
00369     virtual void SetForeBackMode(BOOL);
00370     virtual double GetConvertToEditableShapesDPI();
00371 
00372 public:
00373     virtual DocRect GetDocViewRect(Spread*);
00374     virtual void SetExtent(DocCoord, DocCoord); // Reset the extent of the document
00375     virtual WorkRect GetViewRect();             // The physical rect of the view
00376 
00377 protected:
00378     double m_DPI;
00379 };
00380 
00381 
00382 
00383 #endif  // INC_XPFRGN

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