nodecomp.h

Go to the documentation of this file.
00001 // $Id: nodecomp.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 #ifndef NODECOMPOUND_H
00100 #define NODECOMPOUND_H
00101 
00102 #include "ink.h"
00103 
00104 class NodeCompound;
00105 class BlendNodeParam;
00106 class NodeBlend;
00107 class NodeGroup;
00108 
00109 
00110 /***********************************************************************************************
00111 
00112 >   class CompoundNodeTreeFactory : public CCObject
00113 
00114     Author:     David_McClarnon (Xara Group Ltd) <camelotdev@xara.com>
00115     Created:    11/5/99
00116     Purpose:    Encapsulates all data needed to create a new compound node of a particular type
00117                 Abstract base class to be inherited from
00118 
00119 ***********************************************************************************************/
00120 class CompoundNodeTreeFactory : public ListItem
00121 {
00122     CC_DECLARE_DYNCREATE(CompoundNodeTreeFactory);
00123 
00124 public:
00125 
00126     // pass in the list of nodes to apply the compound node to - WITHOUT CHILDREN !
00127     // these nodes will appear as first children of the new compound node
00128     // returns TRUE for success
00129 
00130     virtual NodeCompound * CreateNode(List *pList, UndoableOperation * pOp = NULL) { return NULL;}
00131 } ;
00132 
00133 
00134 
00135 
00136 /***********************************************************************************************
00137 
00138 >   enum ListType
00139 
00140     Author:     Unattributed (Xara Group Ltd) <camelotdev@xara.com>
00141     Created:    When?
00142     Purpose:    Identifies rampant lists of temporary nodes - URGH!
00143 
00144 ***********************************************************************************************/
00145 
00146 enum ListType
00147 {
00148     LT_SHADOWSLIST, LT_BEVELSLIST, LT_CONTOURSLIST, 
00149     LT_BECOMEA_SHADOWSLIST, LT_BECOMEA_BEVELSLIST, LT_BECOMEA_CONTOURSLIST
00150 };
00151 
00152 
00153                             
00154                             
00155 /***********************************************************************************************
00156 
00157 >   class NodeCompound : public NodeRenderableInk
00158 
00159     Author:     David_McClarnon (Xara Group Ltd) <camelotdev@xara.com>
00160     Created:    11/5/99
00161     Purpose:    Encapsulates everything to do with compound nodes
00162 
00163 ***********************************************************************************************/
00164 
00165 class NodeCompound : public NodeRenderableInk
00166 {
00167 // Give my name out in memory dumps
00168 CC_DECLARE_DYNCREATE(NodeCompound);
00169 
00170 public:
00171     NodeCompound(); 
00172     ~NodeCompound(); 
00173     
00174     NodeCompound(Node* ContextNode,  
00175                 AttachNodeDirection Direction,  
00176                 BOOL Locked = FALSE, 
00177                 BOOL Mangled = FALSE,  
00178                 BOOL Marked = FALSE, 
00179                 BOOL Selected = FALSE    
00180               );
00181     
00182     // does the regen code !
00183     virtual ChangeCode OnChildChange(ObjChangeParam* pParam);
00184 
00185     // special selection functions are required for some types of compound node.
00186     virtual void SetSelected(BOOL Status);
00187     virtual void Select(BOOL ReDraw);
00188     virtual void DeSelect(BOOL ReDraw, BOOL bDeselectChildren = FALSE);
00189 
00190     virtual BOOL IsCompound() const { return TRUE; }        // See also BaseTextClass
00191     virtual BOOL IsCompoundClass() const { return TRUE; }
00192 
00193     virtual INT32 EstimateNodeComplexity(OpParam* details);
00194     virtual BOOL HasVisibleChildren() const;
00195 
00196     virtual BOOL AllowOp_AccountForCompound(ObjChangeParam* pParam,
00197                                             BOOL SetOpPermissionState = TRUE,
00198                                             BOOL DoPreTriggerEdit = TRUE);
00199 
00200     // dpi for rendering
00201     void SetDPI(double dpi) { m_DPI = dpi; }
00202     double GetDPI() { return m_DPI; }
00203 
00204     // tells the node that we are printing
00205     void SetPrinting(BOOL bPrinting) { m_bPrinting = bPrinting; }
00206     BOOL IsPrinting() { return m_bPrinting; }
00207 
00208     // returns FALSE if I shouldn't regenerate before printing or export
00209     virtual BOOL RegenerateForPrinting() { return TRUE; }
00210 
00211     // gets the rectangle of all nodes under me without their 'NeedsParent' set
00212     virtual DocRect GetInsideBoundingRect();
00213 
00214     // in blending we need to get the blending node out of this node
00215     virtual NodeRenderableInk * GetNodeToBlend();
00216 
00217     virtual NodeCompound* GetParentController() const {return NULL;}
00218 
00219     // creates a tree wrapping up the given node
00220     virtual NodeRenderableInk * CreateTreeFromNodeToBlend(NodeRenderableInk * pNode,
00221                 CCAttrMap * pAttrMap) { return NULL; }
00222 
00223     void SetStartBlendGroupNode(BOOL bFlag=TRUE) { m_bBlendStartNode = bFlag; }
00224     void SetEndBlendGroupNode(BOOL bFlag=TRUE)   { m_bBlendEndNode   = bFlag; }
00225 
00226     BOOL IsStartBlendGroupNode() { return m_bBlendStartNode; }
00227     BOOL IsEndBlendGroupNode() { return m_bBlendEndNode; }
00228 
00229     void SetBlendCreatedByNode(NodeCompound * pNode) { m_pBlendCreatedByNode = pNode; }
00230     NodeCompound * GetBlendCreatedByNode() { return m_pBlendCreatedByNode; }
00231 
00232     // whether attributes assignments should be promoted to me, except for
00233     // the 'needs parent' nodes
00234     // ie if dragndrop of a colour happens to the original nodes, then the
00235     // attribute assignment is promoted to the controller node if this returns TRUE
00236     // but if the attribute is applied to a NeedsParent node, then it isn't
00237     virtual BOOL PromoteAttributeApplicationToMe(CCRuntimeClass *pAttrClass) const { return FALSE; }
00238 
00239     // Routines to get/set the names of groups
00240     virtual String_32& GetName(); 
00241     virtual void SetName(String_32& GroupName); 
00242 
00243     // Functions for converting nodes into other types
00244     virtual BOOL CanBecomeA(BecomeA* pBecomeA);
00245     virtual BOOL DoBecomeA(BecomeA* pBecomeA);
00246     virtual NodeGroup* BecomeAGroup(UndoableOperation* pUndoOp);
00247 
00248     virtual DocRect             GetChildBoundingRect(BOOL bIncludeAttrs = TRUE);
00249     virtual BOOL                HasEffectAttrs() const;
00250     virtual BOOL                ContainsEffects() const;
00251     virtual void                TransformEffectAttrs(TransformBase& Trans);
00252 
00253     // Karim MacDonald 25/05/2000
00254     // Extend functions.
00255     // Note that if a sub-class returns TRUE from IsTypeExtendible, it must
00256     // also provide complete implementations of ValidateExtend and Extend,
00257     // which should usually check/extend its children.
00258 public:
00259 //  virtual BOOL IsTypeExtendible() const { return TRUE; }
00260 //  virtual DocRect ValidateExtend(const ExtendParams& ExtParams);
00261 //  virtual void Extend(const ExtendParams& ExtParams);
00262 
00263     // virtual override of NodeRenderableBounded::GetExtendTargetBounds().
00264     virtual DocRect GetExtendTargetBounds(const ExtendParams& ExtParams);
00265 
00266     // DY get the ink node underneath a contour, bevel, shadow, or whatever, though
00267     // for this class it will return NULL.
00268     virtual NodeRenderableInk* GetInkNodeFromController() const;
00269 
00270 protected:
00271     // causes the children to regenerate themselves
00272     // virtual BOOL RegenChildren(UndoableOperation * pOp);
00273 
00274     // recursive function for RegenChildren
00275     // BOOL RegenerateNode(Node * pNode, UndoableOperation * pOp);
00276 
00277     double m_DPI;
00278 
00279     BOOL m_bPrinting;
00280 
00281     // informs all parent nodes that a regeneration is about to occur (through
00282     // the child change message) or has occured
00283     virtual void PreInformParentsOfRegenerate();
00284     virtual void PostInformParentsOfRegenerate();
00285 
00286     // blend variables to tell me whether I'm a start of a blend path group or
00287     // the end of a blend path group
00288     BOOL m_bBlendStartNode;
00289     BOOL m_bBlendEndNode;
00290 
00291     // finds the blend node associated with myself in the end blend tree
00292     NodeCompound* FindAssociatedBlendNode(BlendNodeParam * pParam);
00293 
00294     // the node which created this node when blending
00295     NodeCompound* m_pBlendCreatedByNode;
00296 
00297     // The name of the group
00298     String_32 CompoundName;
00299 
00300 // -----------------------------------------------------------------------------------------------
00301 protected:
00302     /* CGS (16/6/2000)
00303 
00304         When a blend exists between a couple of group blends and we perform convert to editable
00305         shapes on it ....
00306           
00307         If the internal (generated) compound nodes are shadowed, we MUST
00308         get our shadow to 'go' with the relevant intermediate compound node.  shadowThisNode
00309         allows us to do this.  DO NOT USE IT FOR ANYTHING ELSE !!!!
00310     */
00311     
00312     static NodeCompound* shadowThisNode;
00313     
00314     /* GCS (3/7/2000)
00315 
00316         Compounds that are generated as intermediate nodes need to be deleted - otherwise we
00317         waste vast amounts of memory!  Although shadows, bevels and countours all delete themselves,
00318         in the case that we have a shadowed bevel (or contour); then the shadow MUST delete the
00319         bevel (or contour) after it has finished using it.  shadowDeleteThis allows us to achieve
00320         this requirement.  DO NOT USE IT FOR ANYTHING ELSE !!!!
00321     */
00322     
00323     static NodeCompound* shadowDeleteThis;
00324 
00325     // CGS - support for the above NodeGroup pointers ....
00326 
00327     NodeCompound* GetShadowDeleteThisNode()             { return (shadowDeleteThis); }
00328     NodeCompound* GetShadowThisNode()                       { return (shadowThisNode); }
00329 
00330     void SetShadowThisNode(NodeCompound* thisNode)      { shadowThisNode = thisNode; } 
00331     void SetShadowDeleteThisNode(NodeCompound* thisNode)    { shadowDeleteThis = thisNode; }
00332 
00333     // CGS (20/6/2000)
00334     // when blending a grouped blend to another grouped blend .....
00335     // some nodes have BECOMEA_PASSBACK called on them.  Now, since I am creating a copy
00336     // of the relevant node (controllers and their children); I need to be able to delete
00337     // them.  The only problem is that if you delete them just after creating them (as I do
00338     // elsewhere, BlendAttributes () access violates!  To overcome this problem,
00339     // I have found it necessary to insert them into a list; and delete them all at the
00340     // very end.
00341     // CGS: this is also now TRUE for all blend rendering code (no matter how complex the blend)
00342     // do NOT use this member variable for anything else!
00343 
00344     static List* blndConsBecomeAShadows;    // list of shadow controllers that were generated when blending (internally via PASSBACK)
00345     static List* blndConsBecomeABevels;     // list of bevel controllers that were generated when blending (internally via PASSBACK)
00346     static List* blndConsBecomeAContours;   // list of contour controllers that were generated when blending (internally via PASSBACK)
00347 
00348     NodeBlend* blenderNode;                 // ptr to the node blend with which *this* node is associated with
00349                                             // this is required so that BecomeA lists are only cleared
00350                                             // for the relevant nodes (otherwise all manner of access
00351                                             // violations break out) ....  Take a look at NodeBlender::Deinit()
00352                                             // for an example of its usage.
00353 
00354     static BOOL isForPrinting;              // we need to flag nodes that are inserted when printing,
00355                                             // so that we may delete them without affecting others
00356 
00357 public:
00358 
00359     // CGS:  support functions for the above ....
00360 
00361     static BOOL AllocBlendConsList(ListType listType);
00362     static BOOL AllocatedBlendConsList (ListType listType);
00363 
00364     static BOOL BlendConsListInsert(ListType listType, Node* insertNode);
00365 
00366     static BOOL KillBlendConsListItem(ListType listType, NodeBlend* NodeBlend);
00367     
00368     static BOOL KillBlendConsList(ListType listType, BOOL killAll, BOOL isPrinting);
00369 
00370     static BOOL KillAllBlendBecomeAConsLists(BOOL killAll = FALSE, BOOL isPrinting = FALSE);
00371     static BOOL KillAllBlendBecomeAConsListItem(NodeBlend* associatedWith);
00372 
00373     static void SetIsForPrinting(BOOL newVal) { isForPrinting = newVal; }
00374 
00375     NodeBlend* GetBlenderNode() { return (blenderNode); }
00376     void SetBlenderNode(NodeBlend* blender) { blenderNode = blender; }
00377 
00378 private:
00379 
00380     static List* InitListPtr(ListType listType);
00381 
00382 #ifdef _DEBUG
00383 
00384 public:
00385 
00386     static INT32 shadowLastID;
00387     INT32 myShadowID;
00388     static INT32 bevelLastID;
00389     INT32 myBevelID;
00390     static INT32 contourLastID;
00391     INT32 myContourID;
00392 
00393     // for DoBecomeA stuff ....
00394 
00395     static INT32 shadowLastBecomeAID;
00396     INT32 myShadowBecomeAID;
00397     static INT32 bevelLastBecomeAID;
00398     INT32 myBevelBecomeAID;
00399     static INT32 contourLastBecomeAID;
00400     INT32 myContourBecomeAID;
00401 
00402 #endif
00403 
00404 };
00405 
00406 
00407 
00408 #endif

Generated on Sat Nov 10 03:46:00 2007 for Camelot by  doxygen 1.4.4