node.h

Go to the documentation of this file.
00001 // $Id: node.h 1708 2006-08-17 17:13:38Z 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 // Declaration of the following classes:
00100 /*
00101     Node                           (Implementation in node.cpp)    
00102     
00103         NodeRenderable             (Implementation in noderend.cpp)
00104             NodeRenderableInk
00105             NodeRenderablePaper     
00106         NodeHidden
00107         NodeGroup
00108 */ 
00109 
00110 
00111 // Check in comments
00112 /*
00113 */    
00114       
00115       
00116 #ifndef INC_NODE
00117 #define INC_NODE
00118 
00119 // All include files here
00120 #include <assert.h>
00121 //#include "binds.h"
00122 #include "release.h"
00123 
00124 class CCAPI NodeRenderablePaper;
00125 class NodeRenderableInk;
00126 class CCAPI Chapter;  
00127 class CCAPI Layer;
00128 class RenderRegion;
00129 class NodeAttribute;
00130 class Spread;
00131 class List;
00132 class TransformBase;
00133 class UndoableOperation;
00134 class BaseDocument;
00135 class BecomeA;
00136 class ObjChangeParam;
00137 class Filter;
00138 class KernelBitmap;
00139 class NodeHidden;
00140 class InternalClipboardFormat;
00141 class NodePath;
00142 class BaseCamelotFilter;
00143 class ExtendParams;
00144 class NodeCompound;
00145 
00146 #if _RELEASE
00147 #define DEBUG_TREE  0
00148 #else
00149 #define DEBUG_TREE  1
00150 #endif
00151 
00152 #ifdef RALPH
00153 #undef DEBUG_TREE
00154 #define DEBUG_TREE  0
00155 #endif
00156 
00157 
00158 // The AttachNode direction type specifies a direction in which one node is to be attached
00159 // to another. 
00160 enum AttachNodeDirection { PREV, NEXT, FIRSTCHILD, LASTCHILD }; 
00161 
00162 // A set of flags used to determine which nodes should be rendered.
00163 // See Find{First,Next}ForClippedInkRender functions.
00164 typedef struct
00165 {
00166     unsigned Required   : 1;
00167     unsigned Attribute  : 1;
00168     unsigned Renderable : 1;
00169     unsigned Intersects : 1;
00170 } ClippedInkFlags;
00171 
00172 
00173 /***********************************************************************************************
00174 
00175 >   typedef enum ChangeCode
00176 
00177     Author:     Mike_Kenny (Xara Group Ltd) <camelotdev@xara.com>
00178     Date:       13/01/95
00179     Purpose:    Define type of change results which can be returned by OnChildChange and
00180                 WarnParentOfChange
00181 
00182 ***********************************************************************************************/
00183 
00184 typedef enum ChangeCode
00185 {
00186     CC_OK,
00187     CC_NORECORD,
00188     CC_FAIL
00189 };
00190 
00191 
00192 /***********************************************************************************************
00193 
00194 >   typedef enum SubtreeRenderState
00195 
00196     Author:     Phil_Martin (Xara Group Ltd) <camelotdev@xara.com>
00197     Date:       22/06/2004
00198     Purpose:    Enumerates the different actions that RenderTree can take when given the root
00199                 node of a subtree to be rendered
00200                 (Return values for the RenderSubtree function and stored in SubRenderContext)
00201 
00202 ***********************************************************************************************/
00203 typedef enum SubtreeRenderState
00204 {
00205     SUBTREE_NORENDER = 0,
00206     SUBTREE_ROOTONLY,
00207     SUBTREE_ROOTANDCHILDREN,
00208     SUBTREE_JUMPTO,
00209     SUBTREE_RUNTO
00210 };
00211 
00212 // OpPermissionState
00213 //
00214 // This is to do with the mechanism used to allow ops to determine whether a node can have an op applied to
00215 // them, which may change depending on the node's parent (e.g. blends don't allow child nodes to be deleted)
00216 //
00217 // This gives readable meanings to the combined states of the OpPermission1 and OpPermission2 flags in Node.  These
00218 // flags get set up by Ops that want to work correctly on nodes that are selected inside other nodes.
00219 //
00220 // An operation should NOT be applied to a node if the permission value is PERMISSION_DENIED.  The other two
00221 // states will allow ops to happen to a node.
00222 //
00223 // The default state of a node is PERMISSION_UNDEFINED, which allows all ops to work as they do currently
00224 //
00225 // This permission state is used by the Range class.  Ranges will not return nodes that have values of PERMISSION_DENIED.
00226 //
00227 // Use Get/SetOpPermission() funcs to access a node's op permission state.
00228 //
00229 // Markn 3/2/95
00230 
00231 enum OpPermissionState  {   PERMISSION_UNDEFINED,
00232                             PERMISSION_DENIED,
00233                             PERMISSION_ALLOWED
00234                         };
00235 
00236 
00237 /***********************************************************************************************
00238 
00239 >   typedef enum CopyType
00240 
00241     Author:     Mike_Kenny (Xara Group Ltd) <camelotdev@xara.com>
00242     Date:       3/5/95
00243     Purpose:    Define the copy type a node supports. the Node class defaults to SIMPLECOPY
00244                 which means its SimpleCopy() function will be used during object copy. This
00245                 gives the default action of making a straight copy of the node. COMPLEXCOPY
00246                 is used by nodes which cannot exist on their own. It may be necessary for
00247                 them to return a tree of nodes when one node is asked to be copied. This type
00248                 is specifically used for complex group objects
00249                 
00250 ***********************************************************************************************/
00251 
00252 typedef enum CopyType
00253 { 
00254     SIMPLECOPY, 
00255     COMPLEXCOPY
00256 };
00257 
00258 typedef enum CopyStage
00259 { 
00260     COPYOBJECT, 
00261     COPYFINISHED 
00262 };
00263 
00264 typedef enum CopyControlFlags
00265 {
00266     ccALL,
00267     ccLOCKED,
00268     ccMANGLED,
00269     ccMARKED,
00270     ccSELECTED,
00271     ccRENDERABLE
00272 };
00273 
00274 
00275 /********************************************************************************************
00276 
00277 class AttrTypeItem: public ListItem
00278 
00279     Author:     Simon_Maneggio (Xara Group Ltd) <camelotdev@xara.com>
00280     Created:    11/5/95
00281     Purpose:    AttrTypeItem's are held in AttrTypeSets
00282     SeeAlso:    AttrTypeSet
00283     SeeAlso:    Node::AppliedAttrSet
00284 
00285 ********************************************************************************************/
00286 
00287 class AttrTypeItem: public ListItem
00288 {
00289 public:
00290     CCRuntimeClass* AttributeType;  
00291 };
00292 
00293 /********************************************************************************************
00294 
00295 >   class AttrTypeSet: public List
00296 
00297     Author:     Simon_Maneggio (Xara Group Ltd) <camelotdev@xara.com>
00298     Created:    15/5/95
00299     Purpose:    A set of AttrTypeitems
00300     SeeAlso:    AttrTypeItem
00301 
00302 ********************************************************************************************/
00303 
00304 class AttrTypeSet: public List
00305 {
00306 public:
00307     
00308     // A function to return a copy of the AppliedAttrSet
00309     AttrTypeSet* CopySet();
00310     
00311     // A simple function to add attr types to the AppliedAttrSet (Chiecks for duplicates)
00312     virtual BOOL AddToSet(CCRuntimeClass* AttrType);
00313 
00314     virtual BOOL AddToSet(List& AttributeList);
00315                            
00316     // A function to determine if AttrType is in the set
00317     BOOL InSet(CCRuntimeClass* AttrType);
00318     
00319     ~AttrTypeSet() { DeleteAll(); };
00320           
00321 };
00322 
00323 
00324 
00325 /***********************************************************************************************
00326 
00327 >    Class Node: public CCObject
00328 
00329      Author:       Simon_Maneggio (Xara Group Ltd) <camelotdev@xara.com>
00330      Date:         19/4/93
00331      Base Classes: CCObject       
00332      
00333      Purpose:      This abstract class describes the fundamental type of object which can
00334                    be linked into a camelot tree. All other objects which are linked into
00335                    the tree are derived from this class.   
00336                
00337                    IMPORTANT: When producing derived classes of Node, the virtual functions 
00338                    SimpleCopy and ShowDebugTreeDetails() must be redefined.  
00339 
00340      SeeAlso:      CCObject
00341 
00342 ***********************************************************************************************/
00343                         
00344 class CCAPI Node: public CCObject
00345 {                    
00346     CC_DECLARE_DYNAMIC( Node ) 
00347     
00348 public:                       
00349 
00350     // Node Constructors
00351     Node();
00352     Node(Node* ContextNode,  
00353          AttachNodeDirection Direction, 
00354          BOOL Locked=FALSE, 
00355          BOOL Mangled=FALSE,  
00356          BOOL Marked=FALSE, 
00357          BOOL Selected=FALSE, 
00358          BOOL Renderable=FALSE); 
00359               
00360     // Destructor
00361     virtual ~Node();
00362 
00363     virtual void Render( RenderRegion* pRender );
00364     void RenderTreeAtomic(RenderRegion* pRender);
00365 
00366     virtual BOOL NeedsToRender(RenderRegion* pRender);
00367     virtual void PreExportRender( RenderRegion* pRender ); 
00368     virtual BOOL ExportRender( RenderRegion* pRender ); 
00369     virtual BOOL NeedsToExport(RenderRegion* pRender, BOOL VisibleLayersOnly = FALSE,
00370                                BOOL CheckSelected = FALSE);
00371     virtual String Describe(BOOL Plural, BOOL Verbose = TRUE);
00372 
00373     // Functions for handling child nodes changing inside compound node,
00374     virtual ChangeCode  OnChildChange(ObjChangeParam* pParam);
00375 
00376     // Access functions to the node's op permission state
00377     virtual OpPermissionState   GetOpPermission();
00378     virtual void                SetOpPermission(OpPermissionState NewState,BOOL AndParents = FALSE);
00379 
00380     // Permission enquiry functions.
00381     virtual BOOL AllowOp(ObjChangeParam* pParam,BOOL SetOpPermissionState = TRUE,
00382                                                 BOOL DoPreTriggerEdit = TRUE);
00383     virtual BOOL AllowOp_AccountForCompound(ObjChangeParam* pParam,
00384                                             BOOL SetOpPermissionState=TRUE,
00385                                             BOOL DoPreTriggerEdit = TRUE);
00386 
00387     // Node deletion methods
00388     void CascadeDelete(void);
00389 
00390     // Rendering PreChild function - See Function Declaration in node.cpp for more info
00391     virtual SubtreeRenderState RenderSubtree(RenderRegion* pRender, Node** ppNextNode = NULL, BOOL bClip = TRUE);
00392     virtual void RenderAfterSubtree(RenderRegion* pRender) {;}
00393 
00394     // Version 2 file format functions
00395     virtual BOOL WritePreChildrenWeb(BaseCamelotFilter* pFilter);
00396     virtual BOOL WritePreChildrenNative(BaseCamelotFilter* pFilter);
00397     virtual BOOL WritePostChildrenWeb(BaseCamelotFilter* pFilter);
00398     virtual BOOL WritePostChildrenNative(BaseCamelotFilter* pFilter);
00399     virtual BOOL CanWriteChildrenWeb(BaseCamelotFilter* pFilter);
00400     virtual BOOL CanWriteChildrenNative(BaseCamelotFilter* pFilter);
00401 
00402     virtual BOOL WriteBeginChildRecordsWeb(BaseCamelotFilter* pFilter);
00403     virtual BOOL WriteBeginChildRecordsNative(BaseCamelotFilter* pFilter);
00404     virtual BOOL WriteEndChildRecordsWeb(BaseCamelotFilter* pFilter);
00405     virtual BOOL WriteEndChildRecordsNative(BaseCamelotFilter* pFilter);
00406 
00407     virtual BOOL ReadPostChildrenWeb(BaseCamelotFilter* pFilter);
00408     virtual BOOL ReadPostChildrenNative(BaseCamelotFilter* pFilter);
00409 
00410     // Progressive rendering & the new file format
00411     virtual BOOL AreYouSafeToRender();
00412 
00413     // Node copy and move methods
00414     BOOL CopyNode(Node* DestinationNode, 
00415                   AttachNodeDirection Direction);
00416     virtual BOOL NodeCopy(Node** ppNodeCopy);
00417     virtual BOOL CloneNode(Node** ppNoeCopy, BOOL bLightweight);
00418     BOOL CopyComplexRange(Range& RangeToCopy);
00419     
00420     BOOL CopyChildrenTo(Node* DestinationNode, CopyControlFlags CopyFlags=ccALL); 
00421 
00422     void MoveNode(Node* DestinationNode, 
00423                   AttachNodeDirection Direction);
00424                    
00425     void AttachNode(Node* ContextNode, 
00426                     AttachNodeDirection Direction,
00427                     BOOL fCheckTransparent = TRUE,
00428                     BOOL InvalidateChildren = TRUE);
00429 
00430     // function to insert a chain of siblings, but does little more than alter pointers
00431     void InsertChainSimple(Node* ContextNode, AttachNodeDirection Direction);
00432     
00433     virtual BOOL PostImport();          // function called after import
00434     virtual BOOL PostDuplicate(UndoableOperation* pOp);     // function called after node has been copied.
00435 
00436     UINT32 GetTag() const;     
00437     
00438     virtual UINT32 GetNodeSize() const;             // Returns size of node in bytes
00439     virtual CopyType GetCopyType();
00440     UINT32 GetSubtreeSize();                    // Returns size of subtree in bytes 
00441     BOOL IsUnder(Node* pTestNode, BOOL bFirstCall = TRUE) const;        // Find whether this is under the test node in render order
00442 
00443     
00444     // Query flag's status methods
00445     BOOL IsLocked() const;  
00446     BOOL IsMangled() const; 
00447     BOOL IsMarked() const;  
00448     BOOL IsRenderable() const;
00449     BOOL IsParentOfSelected() const;
00450     BOOL IsSelected() const;
00451     BOOL IsChildOfSelected();
00452 
00453     virtual BOOL ShouldBeRendered() const;
00454     virtual BOOL NeedsTransparency() const;
00455     virtual INT32 EstimateNodeComplexity (OpParam* details) { return (1); }
00456 
00457     // Fast type detection functions
00458     // whether this node is a complex compound eg bevel, shadow, contour etc
00459     // Implementing them here tells the compiler that they should be inlined if possible
00460     virtual BOOL IsAnObject() const {return FALSE;}
00461     virtual BOOL IsAnAttribute() const {return FALSE;}
00462     virtual BOOL IsKindOfTextAttribute() const { return FALSE; }
00463     virtual BOOL IsPaper() const {return FALSE;}
00464     virtual BOOL IsLayer() const {return FALSE;}
00465     virtual BOOL IsSpread() const {return FALSE;}
00466     virtual BOOL IsChapter() const {return FALSE;}
00467     virtual BOOL IsNodeDocument() const {return FALSE;}
00468     virtual BOOL IsNodeRenderableClass() const {return FALSE;}
00469     virtual BOOL IsNodeHidden() const {return FALSE;}
00470     virtual BOOL IsNodePath() const {return FALSE;}
00471     virtual BOOL IsARegularShape() const {return FALSE;}
00472     virtual BOOL IsOrHidesAnAttribute() const {return FALSE;}
00473     virtual BOOL IsABitmap() const {return FALSE;}
00474     virtual BOOL IsAFillAttr() const {return FALSE;}
00475     virtual BOOL IsABitmapFill() const {return FALSE;}
00476     virtual BOOL IsABitmapColourFill() const {return FALSE;}
00477     virtual BOOL IsABitmapTranspFill() const {return FALSE;}
00478     virtual BOOL IsAFeatherAttr() const { return FALSE; }
00479     virtual BOOL IsAClipViewAttr() const { return FALSE; }
00480     virtual BOOL IsBounded() const {return FALSE;}
00481     virtual BOOL IsDragged() const {return FALSE; }
00482     virtual BOOL IsController() { return FALSE;}
00483     virtual BOOL IsABlend () { return FALSE; }
00484     virtual BOOL IsCompound() const {return FALSE;} 
00485     virtual BOOL IsCompoundClass() const {return FALSE;} 
00486     virtual BOOL IsAVisibleTextNode() const {return FALSE;}
00487     virtual BOOL IsAnAbstractTextChar() const {return FALSE;}
00488     virtual BOOL IsATextChar() const {return FALSE;}
00489     virtual BOOL IsABaseTextClass() const {return FALSE;}
00490     virtual BOOL IsATypeface() const {return FALSE;}
00491     virtual BOOL IsAnObjectName() const {return FALSE;}
00492     virtual BOOL IsUserAttribute() const {return FALSE;}
00493     virtual BOOL IsSetCandidate() const {return FALSE;}
00494     virtual BOOL IsCacheCompound() const { return FALSE; } 
00495     virtual BOOL IsABevel() const { return FALSE; } 
00496     virtual BOOL IsABevelController() const { return FALSE; } 
00497     virtual BOOL IsAContour() const { return FALSE; } 
00498     virtual BOOL IsAContourController() const { return FALSE; } 
00499     virtual BOOL IsAShadow() const { return FALSE; } 
00500     virtual BOOL IsAShadowController() const { return FALSE; } 
00501     virtual BOOL IsABrush() const {return FALSE;}
00502     virtual BOOL IsEffect() const {return FALSE;}
00503     virtual BOOL IsBitmapEffect() const {return FALSE;}
00504     virtual BOOL IsRenderedAsInk() const {return FALSE;}
00505 
00506     BOOL IsBrushed() const;// does this node have a brush attribute?
00507 
00508     virtual NodePath* IsAnEditablePath();
00509 
00510     // virtual ID fn's for ClipView nodes.
00511     virtual BOOL IsANodeClipViewController() const { return FALSE; }
00512     virtual BOOL IsANodeClipView() const { return FALSE; }
00513 
00514     // virtual ID fn for a group node.
00515     virtual BOOL IsAGroup() const { return FALSE; }
00516 
00517     // virtual ID fn for an insertion node.
00518     virtual BOOL IsAnInsertionNode() const { return FALSE; }
00519 
00520     // virtual ID fn for a NodeMould.
00521     virtual BOOL IsANodeMould() const {return FALSE;}
00522 
00523     // Function for interrogation by clipboard to determine exportable data types
00524     virtual BOOL SupportsClipboardFormat(InternalClipboardFormat *Format) const;
00525 
00526     // This virtual was added because we need to know about nodes which can discard their child
00527     // attributes, an example is the CaretNode. If an attribute gets applied to such a node 
00528     // then no undo info can be generated, the base class function returns FALSE
00529     virtual BOOL DiscardsAttributeChildren() const; 
00530 
00531     // Function to allow nodes to provide flexible edit surfaces.
00532     virtual Node* HasEditableChild(CCRuntimeClass* ChildClass, Node* pPrevNode);
00533 
00534     // This function returns NULL in the base class.
00535     virtual KernelBitmap* EnumerateBitmaps(UINT32 Count);
00536 
00537     // This function returns the special value 1e9 to indicate no effective minimum
00538     virtual double GetEffectiveBitmapMinDPI(KernelBitmap* pBitmap) { return(1e9); }
00539 
00540     // Replace a specific bitmap with another one
00541     virtual BOOL ReplaceBitmap(KernelBitmap* pOrigBitmap, KernelBitmap* pNewBitmap) { return(FALSE); }
00542 
00543     // Find out the optoken of the default operation for this node. (See EditSelectionOp and Return hotkey.)
00544     virtual TCHAR* GetDefaultOpToken() {return NULL;}
00545         
00546     // Set Flag's status methods
00547     void SetLocked(BOOL Status);       
00548     void SetMangled(BOOL Status);
00549     void SetMarker(BOOL Status); 
00550     virtual void SetSelected(BOOL Status); 
00551     void SetRender(BOOL Status, BOOL bAndChildren=FALSE);
00552     void SetParentOfSelected(BOOL Status);
00553 
00554     // Support functions for SetSelected
00555     BOOL HasSelectedChildren() const;
00556 
00557     // Fast way of clearing all selected flags (Selected and SelectedChildren) of the node, and only this node.
00558     // Note: this is NOT a substitute for SetSelected(FALSE). Only use if you know what you're doing
00559     void ClearSelection(BOOL AndChildren=FALSE);
00560 
00561     // Used when adding a sub-tree to a document, any part of which may contain
00562     // transparency.
00563     BOOL ChildrenNeedTransparency();
00564 
00565     // Find Node pointer methods   
00566     // These routines should be made inline as they are called oodles of times during rendering.
00567     Node* FindNext(void) const;
00568     Node* FindPrevious(void) const;
00569     Node* FindParent(void) const;        
00570     Node* FindFirstChild(void) const;
00571     Node* FindLastChild(BOOL ExcludeInsertionNode = FALSE) const;  
00572 
00573     Node* FindParent(CCRuntimeClass* ParentClass) const;
00574     Node* FindNext(CCRuntimeClass* Class) const; 
00575     Node* FindPrevious(CCRuntimeClass* Class) const; 
00576     Node* FindFirstChild(CCRuntimeClass* Class) const;
00577     Node* FindLastChild(CCRuntimeClass* Class) const;
00578 
00579     NodeRenderableInk* FindNextInk() const;
00580     NodeRenderableInk* FindPreviousInk() const;
00581     NodeRenderableInk* FindFirstChildInk() const;
00582     NodeRenderableInk* FindLastChildInk() const;
00583 
00584     BaseDocument *FindOwnerDoc() const;
00585 
00586     // check all our parents for a node of the given type, which is,
00587     // or has as one of _its_ parents, the given node.
00588     BOOL IsFamily(CCRuntimeClass* ccrcType, Node* pAncestor) const;
00589 
00590     // These functions have a very special purpose. They are very Dangerous to use. So don't use it them unless
00591     // you are very sure what you are doing.
00592     void SetParentDangerous(Node* NewParent); 
00593     void SetNextDangerous(Node* NewNext);
00594     void SetPreviousDangerous(Node* NewPrev);
00595     void SetChildDangerous(Node* NewChild);
00596 
00597     // The following routines are provided to access the nodes in the tree without being 
00598     // passed back pointers to hidden nodes. They are slower that the Node pointer methods
00599     // and should therefore only be used where neccesary.
00600 
00601     Node* FindNextNonHidden(void) const; 
00602     Node* FindPrevNonHidden(void) const; 
00603 
00604     // Tree traversal methods.
00605 
00606     Spread* FindParentSpread();
00607 
00608     // These are the old FindFirstDepthFirst and FindNextDepthFirst routines 
00609     static Node* DocFindFirstDepthFirst(BaseDocument *pDocToSearch);
00610     Node* DocFindNextDepthFirst(void);
00611 
00612     Node* FindFirstDepthFirst();
00613     Node* FindNextDepthFirst(Node* Subtree);
00614     Node* FindFirstPreorder();
00615     Node* FindNextPreorder(Node* pRoot = NULL, BOOL bSkipSubtree = FALSE);
00616 
00617     static Chapter* FindFirstChapter(BaseDocument* pDocToSearch);
00618     Chapter* FindNextChapter(void); 
00619 
00620     NodeRenderablePaper* FindNextForClippedPaperRender(void);
00621 
00622     // ---------------------------------------------------------------------
00623     // !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
00624     // These functions are deprecated and nearly ready to be removed!
00625     // DO NOT USE THEM!
00626     // Use RenderTree instead to enable the more intelligent tree scanning
00627     // needed by Cacheing, Effects and Effect attributes
00628     Node* FindFirstForClippedInkRender(DocRect* pClipRect,
00629                                        RenderRegion* pRender,
00630                                        BOOL ExcludeLockedLayers = FALSE,
00631                                        Node* pStopNode = NULL);
00632 
00633     Node* FindNextForClippedInkRender(DocRect* pClipRect, 
00634                                       RenderRegion *pRender, 
00635                                       BOOL ExcludeLockedLayers = FALSE,
00636                                       Node* pStopNode = NULL);
00637 
00638     Node* FindFirstForUnclippedInkRender(RenderRegion* pRender);
00639     Node* FindNextForUnclippedInkRender(RenderRegion *pRender);
00640     // !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
00641     // ---------------------------------------------------------------------
00642 
00643     Chapter* FindEnclosingChapter(DocCoord* ChapterPos, XLONG* ChapterDepth); 
00644 
00645     // Ilan - Support the new extensions to the attribute system (ie geometry linked attributes)
00646     NodeAttribute* FindFirstGeometryLinkedAttr();
00647     NodeAttribute* FindNextGeometryLinkedAttr();
00648 
00649     virtual void UnlinkNodeFromTree(BaseDocument *pOwnerDoc = NULL);
00650 
00651     // Select-inside functions
00652     Node* FindParentOfSelected();
00653     virtual NodeCompound* GetParentController() const {return NULL;}    // Implement if your node was created by a PostProcessor of some sort
00654 
00655     // These two functions are used to convert to shapes, and are implemented in mkshapes.cpp
00656     virtual BOOL CanBecomeA(BecomeA* pBecomeA); 
00657     virtual BOOL DoBecomeA(BecomeA* pBecomeA);
00658 
00659 #ifdef _DEBUG
00660     void DT();                                      // dump doc tree  containing this node
00661     void DST();                                     // dump a subtree from this node
00662     void DST1(INT32 FormParent=0);                  // dump a subtree containing this node
00663     void DST2(INT32 FormParent=0, INT32 MaxDepth=9999); // dump a subtree containing this node
00664 #endif
00665 
00666     // This function is used to inform parents of a child change
00667     ChangeCode WarnParentOfChange(ObjChangeParam* pParam, BOOL AllParents=TRUE);
00668 
00669     virtual BOOL AllowSelectInside() const { return TRUE; }
00670 
00671     // The ShowDebugTree method is only required in the debug version                  
00672 #if !_RELEASE
00673     #ifdef _DEBUG
00674     
00675     void ShowDebugTree() const;  
00676     virtual void ShowDebugTreeDetails() const; 
00677     
00678     #endif    
00679     
00680     virtual void GetDebugDetails(StringBase* Str);   // This is used by the Debug Tree dialog
00681                                                      // It will probably be deleted when we ship !.
00682 #endif
00683 
00684     // Methods to increment and decrement the Hidden node refference count                                               
00685     void IncHiddenCnt(void); 
00686     void DecHiddenCnt(void); 
00687 
00688     UINT32 GetHiddenCnt(void);
00689 
00690     #ifdef _DEBUG
00691         const TCHAR* Name() const;
00692     #endif 
00693 
00694     BOOL OptimiseAttributes();
00695 
00696     // Functions called when the node is hidden or re-shown
00697     virtual BOOL HidingNode();
00698     virtual BOOL ShowingNode();
00699     virtual INT32 ComplexHide(UndoableOperation* pOp, Node* pNextInRange);
00700 
00701     // Functions to managed node marks
00702     void MarkNodeAndChildren();
00703     void MarkChildren();
00704     void ClearMarks();
00705     void ClearChildMarks();
00706 
00707 public:
00708     virtual BOOL IsDifferent(Node *pOther);
00709         // Determine if 2 nodes are considered to be equal.
00710         // NOTE: This may not be implemented fully for all derived classes, so for certain
00711         // types of node, the comparison will only be to see if they are of the same class!
00712         // (This was originally added for the StrokeComponent to be able to compare 2
00713         // subtrees to see if they are equal - a simple base-class implementation plus
00714         // overrides in NodeRenderable & NopdePath suffices to distinguish most Stroke clipart)
00715 
00716 public:
00717     // Functions for examining and manipulating child attributes
00718     virtual void CountChildNodes(UINT32* pChildCount, UINT32* pChildAttrCount);
00719     virtual BOOL AreChildAttrsIdentical(Node* pOtherNode);
00720     virtual BOOL HasThisChildAttr(NodeAttribute* pAttr);
00721     virtual BOOL CopyChildAttrs(Node* pDestNode);
00722     
00723     // DMc - returns TRUE if the given node is in the subtree of this node
00724     virtual BOOL IsNodeInSubtree(Node * pNode);
00725 
00726     // DMc 11/5/99
00727     // Selection & regeneration functions
00728     
00729     // causes the node to regenerate itself (in an undoable way given an undoable operation)
00730     // bCacheRender is FALSE if the node is to regenerate itself now, or TRUE if it is to
00731     // regenerate itself on the next render click
00732     // Returns TRUE to indicate that the node was changed, FALSE if nothing changed
00733     virtual BOOL RegenerateNode(UndoableOperation * pOp = NULL,
00734                                 BOOL bCacheRender = FALSE,
00735                                 BOOL bInformParents = TRUE) { return FALSE; }
00736     
00737     // when the user clicks on a child node, this tells the hit testing code
00738     // whether to promote the hit test to this node
00739     virtual BOOL PromoteHitTestOnChildrenToMe() const { return TRUE; }
00740 
00741     // this indicates whether node should transform with its children
00742     virtual BOOL ShouldITransformWithChildren() const { return FALSE; }
00743 
00744     // this indicates that the node needs a parent node of a particular type
00745     virtual BOOL NeedsParent(Node * pClassNode) const { return FALSE; }
00746 
00747     // indicates whether this node should be ignored by marquee select
00748     virtual BOOL MarqueeSelectNode() const { return TRUE; }
00749     
00750     // calls the protected function SimpleCopy
00751     virtual Node* PublicCopy(); 
00752 
00753     void RemoveAttrTypeFromSubtree(CCRuntimeClass* AttrType, Node* pExceptThis = NULL);
00754 
00755 protected:    
00756 
00757     // The NodeFlags type is used to hold the status of a Node                
00758     struct CCAPI NodeFlags
00759     {
00760         BOOL Locked: 1;       // Not used currently
00761         BOOL Mangled: 1;      // Used by the ArtWorks importer
00762         BOOL Marked: 1;       // Used by CopyMarkedObjects
00763 
00764         // these should only be set in a NodeRenderable
00765         BOOL Selected: 1;           // This node has been selected by the user
00766         BOOL Renderable:1;          // This node is renderable
00767         BOOL SelectedChildren: 1;   // This node has children that have been selected by the user
00768 
00769         BOOL OpPermission1: 1;      // These two flags are used together to encode the node's tri-state
00770         BOOL OpPermission2: 1;      // op permission value.  Values are defined by enum OpPermissionState.
00771     };
00772    
00773     UINT32 Tag;         // Unique node identifier
00774     NodeFlags Flags;   // Flags indicating the objects status    
00775     
00776      // Links to other nodes
00777     Node *Previous;    // Node's previous sibling
00778     Node *Next;        // Node's next sibling
00779     Node *Child;       // Node's first child
00780     Node *Parent;      // Node's parent   
00781 
00782 
00783 
00784     UINT32 HiddenRefCnt; // Reference count of the number of NodeHidden nodes which hide the node
00785 
00786     virtual Node* SimpleCopy(); 
00787     virtual INT32 ComplexCopy(CopyStage Stage, Range& RangeToCopy, Node** pOutput);
00788     void CopyNodeContents(Node* nodeCopy);      
00789 
00790     // Size of pixel in document coords
00791     static MILLIPOINT PixelWidth; 
00792     static MILLIPOINT PixelHeight;
00793 
00794     Node *FindChildToRender(DocRect *const pClipRect, RenderRegion *const pRender, 
00795                             BOOL ExcludeLockedLayers,
00796                             Node* pStopNode = NULL);
00797 
00798     Node *FindChildToRenderUnclipped(RenderRegion *const pRender);
00799 
00800 private:
00801     // Support functions to attach a node to a context node
00802     void AttachAsPreviousNode(Node* ContextNode); 
00803     void AttachAsNextNode(Node* ContextNode);                                 
00804     void AttachAsFirstChildNode(Node* ContextNode);       
00805     void AttachAsLastChildNode(Node* ContextNode); 
00806 
00807     void SetTags(BaseDocument *pOwnerDoc);
00808 
00809 public:
00810     void DeleteChildren(Node* FirstChild);
00811 
00812 private:
00813     static BOOL HourglassOn;
00814 
00815 public:
00816     static void StartHourglass() { HourglassOn = TRUE; };
00817     static void StopHourglass() { HourglassOn = FALSE; };
00818     static BOOL ShowHourglass() { return HourglassOn;} 
00819 
00820 protected:
00821     BOOL CopyChildren(Node* FirstChild, 
00822                       Node* NewParent,
00823                       CopyControlFlags = ccALL);
00824 
00825 private:    
00826     // Support function for ShowDebugTree method
00827 #ifdef _DEBUG
00828     void ShowDebugTreeHelper(const Node* const Root, 
00829                              INT32 TreeLevel, 
00830                              BYTE* IndentString) const;
00831 #endif
00832 
00833     // Select-inside functions
00834 protected:
00835     BOOL DeSelectSubtree();
00836 
00837 public:
00838     friend class NodeHidden;
00839     virtual BOOL SetParentLayerAsEdited();
00840 
00841 public:
00842     // Returns the first attribute of the given class that applies to this node, or null
00843     // if there isn't one.  Follow with calls to NodeAttribute::FindNextAttrClass on the
00844     // returned attribute.
00845     typedef BOOL (Node::*TypeFunc)() const;
00846     NodeAttribute* FindFirstAttr(TypeFunc pfnTest) const;
00847 
00848     // Karim MacDonald 25/11/1999
00849     // Extend functions. Maybe these functions should really originate in NodeRenderable?
00850     // Note that if a sub-class returns TRUE from IsTypeExtendible, it must
00851     // also provide complete implementations of ValidateExtend and Extend,
00852     // which should usually check/extend its children.
00853 public:
00854     virtual BOOL IsTypeExtendible() const { return FALSE; }
00855     virtual DocRect ValidateExtend(const ExtendParams& ExtParams);
00856     virtual void Extend(const ExtendParams& ExtParams);
00857 };
00858 
00859 
00860 
00862 //
00863 //  Inline versions of Node traversal functions.
00864 //
00865 //  Note that we only bother with small non-virtual functions which are likely to be called
00866 //  in a loop.
00867 //
00869 
00870 
00871 /***********************************************************************************************
00872 
00873 >   UINT32 Node::GetTag() const
00874 
00875     Author:     Simon_Maneggio (Xara Group Ltd) <camelotdev@xara.com>
00876     Created:    30/4/93
00877     Inputs:     -
00878     Outputs:    -
00879     Returns:    Tag field of the node 
00880     Purpose:    For finding a nodes TAG, which is a unique identifier for each node stored
00881                 within a document. 
00882     Errors:     -
00883 
00884 ***********************************************************************************************/
00885        
00886 inline UINT32 Node::GetTag() const
00887 { 
00888     return Tag; 
00889 }       
00890  
00891  
00892 /*********************************************************************************************
00893 
00894 >    BOOL Node::IsLocked(void) const
00895 
00896      Author:    Simon_Maneggio (Xara Group Ltd) <camelotdev@xara.com>
00897      Created:   19/4/93
00898      Inputs:    -
00899      Outputs:   -
00900      Returns:   TRUE if the node is locked, and FALSE if the node is not locked.  
00901      Purpose:   For finding the status of the nodes locked flag
00902      Errors:    
00903 
00904 **********************************************************************************************/
00905        
00906 inline BOOL Node::IsLocked(void) const 
00907 { 
00908     return Flags.Locked; 
00909 } 
00910 
00911 
00912 /*********************************************************************************************
00913 
00914 >    BOOL Node::IsMangled(void) const
00915 
00916      Author:    Simon_Maneggio (Xara Group Ltd) <camelotdev@xara.com>
00917      Created:   19/4/93
00918      Inputs:    -
00919      Outputs:   -
00920      Returns:   TRUE if the node is mangled, and FALSE if the node is not mangled.  
00921      Purpose:   For finding the status of the nodes mangled flag
00922      Errors:    
00923 
00924 **********************************************************************************************/
00925        
00926 inline BOOL Node::IsMangled(void) const                
00927 { 
00928     return Flags.Mangled; 
00929 } 
00930 
00931 
00932 /*********************************************************************************************
00933 
00934 >    BOOL Node::IsMarked(void) const
00935 
00936      Author:    Simon_Maneggio (Xara Group Ltd) <camelotdev@xara.com>
00937      Created:   19/4/93
00938      Inputs:    -
00939      Outputs:   -
00940      Returns:   TRUE if the node is marked, and FALSE if the node is not marked.  
00941      Purpose:   For finding the status of the nodes marked flag
00942      Errors:    
00943 
00944 **********************************************************************************************/
00945        
00946 inline BOOL Node::IsMarked(void) const         
00947 { 
00948     return Flags.Marked; 
00949 } 
00950 
00951 
00952 /*********************************************************************************************
00953 
00954 >    BOOL Node::IsRenderable(void) const
00955 
00956      Author:    Simon_Maneggio (Xara Group Ltd) <camelotdev@xara.com>
00957      Created:   19/4/93
00958      Inputs:    -
00959      Outputs:   -
00960      Returns:   TRUE if the node is renderable, and FALSE if the node is not renderable.  
00961      Purpose:   For finding the status of the nodes renderable flag
00962      Errors:    
00963 
00964 **********************************************************************************************/
00965        
00966 inline BOOL Node::IsRenderable() const
00967 { 
00968     return Flags.Renderable; 
00969 }
00970 
00971 
00972 /*********************************************************************************************
00973 
00974 >    virtual BOOL Node::IsSelected() const
00975 
00976      Author:    Simon_Maneggio (Xara Group Ltd) <camelotdev@xara.com>
00977      Created:   19/4/93
00978      Inputs:    -
00979      Outputs:   -
00980      Returns:   TRUE if the node is selected, and FALSE if the node is not selected.  
00981      Purpose:   For finding the status of the nodes selected flag
00982      Errors:    
00983 
00984 **********************************************************************************************/
00985        
00986 inline BOOL Node::IsSelected() const           
00987 { 
00988     return Flags.Selected; 
00989 }  
00990 
00991 
00992 /*********************************************************************************************
00993 
00994 >    BOOL Node::IsParentOfSelected(void) const
00995 
00996      Author:    Phil_Martin (Xara Group Ltd) <camelotdev@xara.com>
00997      Created:   07/10/94
00998      Inputs:    -
00999      Outputs:   -
01000      Returns:   TRUE if the node *may* have selected children.
01001                 FALSE otherwise
01002      Purpose:   For finding the status of the nodes SelectedChildren flag
01003                 Note: When this function returns TRUE it is not guaranteed that there will be
01004                 selected children - there may be none!
01005      Errors:    
01006 
01007 **********************************************************************************************/
01008        
01009 inline BOOL Node::IsParentOfSelected() const           
01010 { 
01011     return Flags.SelectedChildren; 
01012 }  
01013 
01014 
01015 /*********************************************************************************************
01016 
01017 >    void Node::SetLocked(BOOL Status) const
01018 
01019      Author:    Simon_Maneggio (Xara Group Ltd) <camelotdev@xara.com>
01020      Created:   19/4/93
01021      Inputs:    Status: Status of node's locked flag
01022      Outputs:   -
01023      Returns:   -
01024      Purpose:   To set the node's locked status (TRUE/FALSE)
01025      Errors:    -
01026 
01027 **********************************************************************************************/
01028        
01029 inline void Node::SetLocked( BOOL Status )        
01030 { 
01031     Flags.Locked = Status; 
01032 }    
01033  
01034                  
01035 /*********************************************************************************************
01036 
01037 >    void Node::SetMangled(BOOL Status) const
01038 
01039      Author:    Simon_Maneggio (Xara Group Ltd) <camelotdev@xara.com>
01040      Created:   19/4/93
01041      Inputs:    Status: Status of node's mangled flag
01042      Outputs:   -
01043      Returns:   -
01044      Purpose:   To set Nodes mangled status (TRUE/FALSE)
01045      Errors:    -
01046 
01047 **********************************************************************************************/
01048       
01049  
01050 inline void</