becomea.h

Go to the documentation of this file.
00001 // $Id: becomea.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 // Defines a class that will become a parameter to the Node::DoBecomeA() function
00099 
00100 #ifndef INC_BECOMEA
00101 #define INC_BECOMEA
00102 
00103 class Node;
00104 class NodeRenderableInk;
00105 class UndoableOperation;
00106 class CCAttrMap;
00107 
00108 //-----------------
00109 
00110 enum BecomeAReason
00111 {
00112     BECOMEA_REPLACE,        // How to handle this reason in your DoBecomeA() function:
00113                             //
00114                             //      Make a new node of type GetClass();
00115                             //      Remove yourself from the tree  (in an undoable way)
00116                             //      Put the new node in your place (in an undoable way)
00117                             //
00118                             // GetUndoOp() should not return NULL. If it does, error!
00119                             //
00120                             // When trying to replace a node with one of the same type,
00121                             // DON'T DO ANYTHING!!
00122                             //
00123                             // E.g. when trying to replace a NodePath with a NodePath,
00124                             // there is nothing to do because it is pointless replacing
00125                             // your node with an exact copy of yourself in the tree.
00126 
00127 
00128     BECOMEA_PASSBACK,       // How to handle this reason in your DoBecomeA() function:
00129                             //
00130                             //      Make a new node of type GetClass()
00131                             //      Pass it on via PassBack()
00132                             //
00133                             // With this reason, ALWAYS create a new node.  If your node
00134                             // is one of the same type, use SimpleCopy() to create a copy
00135                             // of yourself, and pass the copy back via PassBack()
00136                             //
00137                             //  BOOL PassBack(NodeRenderableInk* pNewNode,NodeRenderableInk* pCreatedByNode)
00138                             //
00139                             // The node you've just created is the pNewNode param and a pointer to your 
00140                             // node (the 'this' pointer) is the pCreatedByNode param.
00141                             //
00142                             // Once the new node is passed back, it is no longer your concern, ie. you
00143                             // don't have to worry about deleting it at a later stage. This should all be
00144                             // done by the derived instance of the give BecomeA class.
00145                             //
00146                             // Remember that PassBack() returns a BOOL, so if FALSE is returned, you must
00147                             // error and recover as normal.
00148                             //
00149                             // It is possible for GetUndoOp() to return NULL with this reason
00150                             //
00151                             // Karim 12/06/2000
00152                             // Note to BecomeA implementors - realise that although it is forbidden
00153                             // for someone else to pass you a node linked into the main tree via
00154                             // PassBack(), it is *perfectly* fine for them to return you an isolated SUBTREE.
00155                             // Therefore, use code similar to the following when disposing of the returned
00156                             // node (assuming it's non-NULL!):
00157                             //                                      pNewNode->CascadeDelete();
00158                             //                                      delete pNewNode;
00159                             //                                      pNewNode = NULL;
00160 
00161     BECOMEA_TEST            // This is only used when calling CanBecomeA and is just a dummy
00162                             // value used where it's not appropriate to pretend to be a
00163                             // replace or passback. (BecomeA reasons are generally ignored
00164                             // by CanBecomeA functions.)
00165 };
00166 
00167 
00168 /********************************************************************************************
00169 
00170 >   class BecomeA : public CC_CLASS_MEMDUMP
00171 
00172     Author:     Mark_Neves (Xara Group Ltd) <camelotdev@xara.com>
00173     Created:    7/10/94
00174     Purpose:    Class that encapsulates the params needed by virtual Node::DoBecomeA()
00175 
00176 ********************************************************************************************/
00177 
00178 class BecomeA : public CC_CLASS_MEMDUMP
00179 {
00180 CC_DECLARE_MEMDUMP(BecomeA);
00181 public:
00182     BecomeA(BecomeAReason ThisReason,
00183             CCRuntimeClass* pClass,
00184             UndoableOperation* pOp = NULL,
00185             BOOL sel = TRUE,
00186             BOOL First = FALSE
00187             );
00188 
00189     virtual ~BecomeA() { }
00190 
00191     // Member variable access functions
00192     BecomeAReason       GetReason()     { return Reason; }
00193     CCRuntimeClass*     GetClass()      { return pClassToBecome; }
00194     UndoableOperation*  GetUndoOp()     { return pUndoOp; }         // Can return NULL
00195     BOOL                Reselect()      { return Select; }
00196     BOOL                IsFirstNode()   { return AmFirstNode; }
00197     BOOL                DoSilhouette()  { return fSilhouette; }
00198     void                SetDoSilhouette(BOOL bEnable) { fSilhouette = bEnable; }
00199     BOOL                DoShadowSilhouettes() { return fShadowSilhouettes; }
00200     void                SetDoShadowSilhouettes(BOOL bEnable) { fShadowSilhouettes = bEnable; }
00201 
00202     void SetInsertComplexBlendStepsAsPaths (BOOL val) { insertComplexBlendStepsAsPaths = val; }
00203     BOOL GetInsertComplexBlendStepsAsPaths () { return (insertComplexBlendStepsAsPaths); }
00204     
00205     // DMc inclusion so that node using this becomeA can make a record of itself inside
00206     // of the passback mechanism for nodes in which the passback is called on to use
00207     Node             *  GetCallNode()   { return pCallNode; }
00208     void                SetCallNode(Node * pNode)   { pCallNode = pNode; }
00209 
00210     // whether this is a become a from a blend or not
00211     virtual BOOL IsBlendBecomeA() { return FALSE; }
00212     // whether this is a become a from a compound blend or not
00213     virtual BOOL IsCompoundBlendBecomeA() { return FALSE; }
00214     // whether this is a become a from a combine or not
00215     virtual BOOL IsCombineBecomeA() { return FALSE; }
00216 
00217     virtual BOOL IsBrushBecomeAGroup() { return FALSE;}
00218 
00219     // This function should be called when Reason == BECOMEA_PASSBACK 
00220     // (see above for a description of this reason code)
00221     virtual BOOL PassBack(NodeRenderableInk* pNewNode,NodeRenderableInk* pCreatedByNode,CCAttrMap* pAttrMap=NULL);
00222 
00223     // Quick function to test the common case that pClassToBecome is a CC_RUNTIME_CLASS(NodePath)
00224     virtual BOOL BAPath() const;
00225 
00226     // Access functions for CanBecomeA counting
00227     virtual void AddCount(UINT32 iNum) {m_Count += iNum;}
00228     virtual UINT32 GetCount() const {return m_Count;}
00229     virtual void ResetCount() {m_Count = 0; m_bIsCounting = TRUE;}  // Call ResetCount to clear count and enable counting
00230     virtual BOOL IsCounting() const {return m_bIsCounting;}
00231 
00232     // Will the BecomeA move the results after they have been created or place them alongside their originating node?
00233     virtual BOOL ResultsStayInPlace() const {return m_bInPlace;}
00234     virtual void SetResultsStayInPlace(BOOL bInPlace) {m_bInPlace = bInPlace;}
00235 
00236     virtual BOOL IsSecondary() const {return m_bSecondary;}
00237     virtual void SetSecondary(BOOL bNewValue = TRUE) {m_bSecondary = bNewValue;}
00238 
00239     virtual BOOL OnlyNeedPaths() const {return m_bPathsOnly;}       // Don't need fill attributes of effects
00240     virtual void SetPathsOnly(BOOL bNewValue = TRUE) {m_bPathsOnly = bNewValue;}
00241 
00242 private:
00243     BecomeAReason           Reason;
00244     CCRuntimeClass*         pClassToBecome;
00245     UndoableOperation*      pUndoOp;
00246     BOOL                    Select;
00247     BOOL                    AmFirstNode;
00248     Node                    *pCallNode;
00249     BOOL                    m_bIsCounting;
00250     BOOL                    m_bBecomeANodePath;
00251     BOOL                    m_bInPlace;
00252     BOOL                    m_bSecondary;           // Set when path processor should not delete original
00253     BOOL                    m_bPathsOnly;
00254 
00255     // Karim 14/06/2000
00256     // a flag used for PASSBACK BecomeA's, denoting whether the target node should merely
00257     // pass back enough information to determine its outline (including line width).
00258     // this is useful for ops like contouring and bevelling, which do not necessarily need
00259     // full path information, just enough to determine the silhouette of the shape.
00260 protected:
00261     BOOL                    fSilhouette;
00262     BOOL                    fShadowSilhouettes;
00263     BOOL                    insertComplexBlendStepsAsPaths;         // CGS (23/10/2000)
00264     UINT32                  m_Count;
00265 
00266     // in-order for the slicing of compound blends to work, compound nodes MUST be inserted
00267     // into the camelot tree as paths - and NOT as complete compounds (e.g.  NodeBevelController .. NodeBevel .. etc.)
00268     // setting insertComplexBlendStepsAsPaths to TRUE allows this to happen.
00269     // The member variable could be used for controlling other such operations in the future
00270 };
00271 
00272 
00273 /***********************************************************************************************
00274 
00275 >   class CopyBecomeA: public BecomeA
00276 
00277     Author:     Mike_Kenny (Xara Group Ltd) <camelotdev@xara.com>
00278     Created:    09/02/95
00279     Purpose:    This is the BecomeA class that is passed to other nodes when we need to make
00280                 'pathified' copy of a subtree. The effect is to create a bunch of nodes
00281                 which copy identically the specified tree.
00282 
00283 ***********************************************************************************************/
00284 
00285 class CopyBecomeA : public BecomeA
00286 {
00287     CC_DECLARE_MEMDUMP(CopyBecomeA);
00288 
00289     public:
00290         CopyBecomeA(BecomeAReason Reason,
00291                     CCRuntimeClass* pClass,
00292                     UndoableOperation* pOp) : BecomeA(Reason,pClass,pOp) {pContextNode=NULL;}
00293 
00294         // This function should be called when Reason == BECOMEA_PASSBACK 
00295         virtual BOOL PassBack(NodeRenderableInk* pNewNode,
00296                               NodeRenderableInk* pCreatedByNode,
00297                               CCAttrMap* pAttrMap);
00298 
00299         void SetContextNode(Node* pNode) { pContextNode = pNode; }
00300 
00301     private:
00302         // Where to hang the node.
00303         Node*   pContextNode;
00304 
00305 };
00306 
00307 #endif  // INC_BECOMEA
00308 
00309 

Generated on Sat Nov 10 03:44:19 2007 for Camelot by  doxygen 1.4.4