objchge.cpp

Go to the documentation of this file.
00001 // $Id: objchge.cpp 1282 2006-06-09 09:46:49Z 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 // This file contains code to handle ObjChange parameter classes.
00099 // An ObjChange parameter is used to pass to a parent node informing
00100 // it that a child has changed.
00101 
00102 /*
00103 */
00104 
00105 #include "camtypes.h"
00106 //#include "resource.h"
00107 #include "objchge.h"
00108 //#include "errors.h" - in camtypes.h [AUTOMATICALLY REMOVED]
00109 //#include "paths.h" - in camtypes.h [AUTOMATICALLY REMOVED]
00110 //#include "undoop.h" - in camtypes.h [AUTOMATICALLY REMOVED]
00111 //#include "spread.h" - in camtypes.h [AUTOMATICALLY REMOVED]
00112 
00113 DECLARE_SOURCE("$Revision: 1282 $");
00114 
00115 CC_IMPLEMENT_DYNAMIC(ObjChangeParam, CCObject)
00116 CC_IMPLEMENT_DYNAMIC(ObjChangePathEdit, ObjChangeParam)
00117 CC_IMPLEMENT_DYNAMIC(ObjChangeParamWithToken, ObjChangeParam)
00118 
00119 // Declare smart memory handling in Debug builds
00120 #define new CAM_DEBUG_NEW
00121 
00122 
00123 /********************************************************************************************
00124 
00125 >   ObjChangeFlags::ObjChangeFlags( BOOL Delete         = FALSE,
00126                                     BOOL Replace        = FALSE,
00127                                     BOOL Move           = FALSE,
00128                                     BOOL Attr           = FALSE,
00129                                     BOOL MultiReplace   = FALSE,
00130                                     BOOL Transform      = FALSE,
00131                                     BOOL Copy           = FALSE,
00132                                     BOOL Regen          = FALSE);
00133 
00134     Author:     Mike_Kenny (Xara Group Ltd) <camelotdev@xara.com>
00135     Created:    09/01/95
00136     Purpose:    constructor for ObjChange flags class
00137 
00138 ********************************************************************************************/
00139 
00140 ObjChangeFlags::ObjChangeFlags( BOOL Delete,
00141                                 BOOL Replace,
00142                                 BOOL Move,
00143                                 BOOL Attrib,
00144                                 BOOL MultiReplace,
00145                                 BOOL Transform,
00146                                 BOOL Copy,
00147                                 BOOL Regen)
00148 {
00149     DeleteNode          = Delete;
00150     ReplaceNode         = Replace;
00151     MoveNode            = Move;
00152     Attribute           = Attrib;
00153     MultiReplaceNode    = MultiReplace;
00154     TransformNode       = Transform;
00155     CopyNode            = Copy;
00156     RegenerateNode      = Regen;
00157 }
00158 
00159 
00160 /********************************************************************************************
00161 
00162 >  ObjChangeMask::ObjChangeMask()
00163 
00164     Author:     Mike_Kenny (Xara Group Ltd) <camelotdev@xara.com>
00165     Created:    11/01/95
00166     Purpose:    constructor for ObjChangeMask. This sets the various maskable changes to
00167                 false, ie they will not be sent during and interactive change.
00168 
00169 ********************************************************************************************/
00170 
00171 ObjChangeMask::ObjChangeMask()
00172 {
00173     // set all flags to false;
00174     EorBlobs = FALSE;
00175     Finished = FALSE;
00176 }
00177 
00178 /********************************************************************************************
00179 
00180 >  void ObjChangeMask::ClaimAll()
00181 
00182     Author:     Mike_Kenny (Xara Group Ltd) <camelotdev@xara.com>
00183     Created:    11/01/95
00184     Purpose:    A quick way of setting all the mask bits to true, for a particular
00185                 ObjChangeMask. This starts forcing all ObjChange messages for a particular
00186                 op to be sent.
00187 
00188 ********************************************************************************************/
00189 
00190 void ObjChangeMask::ClaimAll()
00191 {
00192     // set all flags to false;
00193     EorBlobs = TRUE;
00194     Finished = TRUE;
00195 }
00196 
00197 /********************************************************************************************
00198 
00199 >  void ObjChangeMask::CorrectMask()
00200 
00201     Author:     Mike_Kenny (Xara Group Ltd) <camelotdev@xara.com>
00202     Created:    11/01/95
00203     Purpose:    Checks the ObjChangeMask settings and corrects them where necessary.
00204                 It thus ensures object change messages are not called out of sequence or
00205                 or missed out when necessary.
00206 
00207 ********************************************************************************************/
00208 
00209 void ObjChangeMask::CorrectMask()
00210 {
00211     // does nothing at present
00212 }
00213 
00214 
00215 /********************************************************************************************
00216 
00217 >   ObjChangeParam::ObjChangeParam()
00218 
00219     Author:     Mike_Kenny (Xara Group Ltd) <camelotdev@xara.com>
00220     Created:    09/01/95
00221     Purpose:    Constructor for the ObjChangeParam class
00222 
00223 ********************************************************************************************/
00224 
00225 ObjChangeParam::ObjChangeParam()
00226 {
00227     ChangeType          = OBJCHANGE_UNDEFINED;
00228     pChangeOp           = NULL;
00229     pChangeNode         = NULL; 
00230     DenialReason        = 0;
00231     ChangeDirection     = OBJCHANGE_CALLEDBYOP;
00232     m_pCallingChild     = NULL;
00233     m_bRetainCachedData = FALSE;
00234 }
00235 
00236 
00237 /********************************************************************************************
00238 
00239 >   ObjChangeParam::ObjChangeParam( ObjChangeType cType,
00240                                     ObjChangeFlags cFlags,
00241                                     Node* cNode,
00242                                     UndoableOperation* cOp,
00243                                     ObjChangeDirection direction=OBJCHANGE_CALLEDBYOP,
00244                                     Node* pCallingChild = NULL)
00245 
00246     Author:     Mark_Neves (Xara Group Ltd) <camelotdev@xara.com>
00247     Created:    7/2/95
00248     Inputs:     cType   = a change type
00249                 cFlags  = change flags
00250                 cNode   = a pointer to the node thats changing
00251                 cOp     = a pointer to the current operation (NULL if the change is occuring
00252                           in a none undoable way)
00253                 direction = direction in which the AllowOp is being called
00254                 pCallingChild = the node calling the AllowOp, if OBJCHANGE_CALLEDBYCHILD set.
00255     Purpose:    Initialises an ObjChange parameter block.
00256 
00257 ********************************************************************************************/
00258 
00259 ObjChangeParam::ObjChangeParam( ObjChangeType cType,
00260                                 ObjChangeFlags cFlags,
00261                                 Node* cNode,
00262                                 UndoableOperation* cOp,
00263                                 ObjChangeDirection direction,
00264                                 Node* pCallingChild)
00265 {
00266     DenialReason = 0;
00267     Define(cType,cFlags,cNode,cOp,direction,pCallingChild);
00268 }
00269 
00270 
00271 
00272 /********************************************************************************************
00273 
00274 >   ObjChangeParam::~ObjChangeParam()
00275 
00276     Author:     Mike_Kenny (Xara Group Ltd) <camelotdev@xara.com>
00277     Created:    09/01/95
00278     Purpose:    Destructor for the ObjChangeParam class
00279 
00280 ********************************************************************************************/
00281 
00282 ObjChangeParam::~ObjChangeParam()
00283 {
00284 }
00285 
00286 
00287 /********************************************************************************************
00288 
00289 >   void ObjChangeParam::Define(ObjChangeType cType,
00290                                 ObjChangeFlags cFlags,
00291                                 Node* cNode,
00292                                 UndoableOperation* cOp,
00293                                 ObjChangeDirection direction=OBJCHANGE_CALLEDBYOP,
00294                                 pCallingChild = NULL)
00295 
00296     Author:     Mike_Kenny (Xara Group Ltd) <camelotdev@xara.com>
00297     Created:    09/01/95
00298     Inputs:     cType   = a change type
00299                 cFlags  = change flags
00300                 cNode   = a pointer to the node thats changing
00301                 cOp     = a pointer to the current operation (NULL if the change is occuring
00302                           in a none undoable way)
00303                 direction = direction in which AllowOp is called
00304                 pCallingChild = the node calling the AllowOp, if OBJCHANGE_CALLEDBYCHILD set.
00305     Returns:    -
00306     Purpose:    Initialises an ObjChange parameter block.
00307 
00308 ********************************************************************************************/
00309 
00310 void ObjChangeParam::Define(ObjChangeType cType,
00311                             ObjChangeFlags cFlags,
00312                             Node* cNode,
00313                             UndoableOperation* cOp,
00314                             ObjChangeDirection direction,
00315                             Node* pCallingChild)
00316 {
00317     ERROR3IF(cType==OBJCHANGE_UNDEFINED,"ObjChangeParam::Define() called with an illegal change type");
00318     //ERROR3IF(cNode==NULL,"ObjChangeParam::Define() called with a null child node pointer");
00319 
00320     // Now set the internal variables
00321     ChangeType          = cType;
00322     ChangeFlags         = cFlags;
00323     pChangeOp           = cOp;
00324     pChangeNode         = cNode;
00325     ChangeDirection     = direction;
00326     m_pCallingChild     = pCallingChild;
00327     m_bRetainCachedData = FALSE;
00328 }
00329 
00330 
00331 /********************************************************************************************
00332 
00333 >   ObjChangePathEdit::ObjChangePathEdit()
00334 
00335     Author:     Mike_Kenny (Xara Group Ltd) <camelotdev@xara.com>
00336     Created:    09/01/95
00337     Purpose:    Constructor for the ObjChangePathEdit class
00338 
00339 ********************************************************************************************/
00340 
00341 ObjChangePathEdit::ObjChangePathEdit() : ObjChangeParam()
00342 {
00343     pChangePath = NULL;
00344     pChangeSpread = NULL;
00345 }
00346 
00347 
00348 /********************************************************************************************
00349 
00350 >   ObjChangePathEdit::~ObjChangePathEdit()
00351 
00352     Author:     Mike_Kenny (Xara Group Ltd) <camelotdev@xara.com>
00353     Created:    09/01/95
00354     Purpose:    Destructor for the ObjChangePathEdit class
00355 
00356 ********************************************************************************************/
00357 
00358 ObjChangePathEdit::~ObjChangePathEdit()
00359 {
00360 }
00361 
00362 /********************************************************************************************
00363 
00364 >   void ObjChangePathEdit::Define( ObjChangeType cType,
00365                                     ObjChangeFlags cFlags,
00366                                     Node* cNode,
00367                                     UndoableOperation* cOp
00368                                     Path* cPath
00369                                     Spread* cSpread)
00370 
00371     Author:     Mike_Kenny (Xara Group Ltd) <camelotdev@xara.com>
00372     Created:    09/01/95
00373     Inputs:     cType   = a change type
00374                 cFlags  = change flags
00375                 cNode   = a pointer to the node thats changing
00376                 cOp     = a pointer to the current operation 
00377                           (NULL if the change is occuring in a none undoable way)
00378                 cPath   = a pointer to the current version of the path
00379                           (can be NULL for all but PRE and POSTCHANGE parameters)
00380                 cSpread = a pointer to a spread
00381                           (can be NULL for all but PRE and POSTCHANGE parameters)
00382 
00383     Returns:    -
00384     Purpose:    Initialises an ObjChangePathEdit parameter block.
00385 
00386 ********************************************************************************************/
00387 
00388 void ObjChangePathEdit::Define( ObjChangeType cType,
00389                                 ObjChangeFlags cFlags,
00390                                 Node* cNode,
00391                                 UndoableOperation* cOp,
00392                                 Path* cPath,
00393                                 Spread* cSpread)
00394 {
00395     ERROR3IF(cPath==NULL,"ObjChangePathEdit::Define() called with a null edit path");
00396     ERROR3IF(cSpread==NULL,"ObjChangePathEdit::Define() called with a null edit Spread");
00397 
00398     ObjChangeParam::Define(cType,cFlags,cNode,cOp);
00399 
00400     // Now set the internal variables
00401     pChangePath = cPath;
00402     pChangeSpread = cSpread;
00403 }
00404 
00405 
00406 
00407 /********************************************************************************************
00408 
00409 >   ChangeCode ObjChangePathEdit::Define(Node* cNode,
00410                                          UndoableOperation* cOp
00411                                          Path* cPath
00412                                          Spread* cSpread
00413                                          BOOL All)
00414 
00415     Author:     Mike_Kenny (Xara Group Ltd) <camelotdev@xara.com>
00416     Created:    12/01/95
00417     Inputs:     cNode   = a pointer to the node thats changing
00418                 cOp     = a pointer to the current operation 
00419                           (NULL if the change is occuring in a none undoable way)
00420                 cPath   = a pointer to the current version of the path
00421                           (can be NULL for all but PRE and POSTCHANGE parameters)
00422                 cSpread = a pointer to a spread
00423                           (can be NULL for all but PRE and POSTCHANGE parameters)
00424                 All     = a bool, used to send the message to all of cNodes parents
00425                           if TRUE or just its immediate parent if FALSE;
00426     Returns:    ChangeCode
00427     Purpose:    Initialises an ObjChangePathEdit parameter block with a ChangeStarting
00428                 message.
00429 
00430 ********************************************************************************************/
00431 
00432 ChangeCode ObjChangePathEdit::ObjChangeStarting(Node* cNode,
00433                                                 UndoableOperation* cOp,
00434                                                 Path* cPath,
00435                                                 Spread* cSpread,
00436                                                 BOOL All)
00437 {
00438     // Create some change flags
00439     ObjChangeFlags ChgeFlags;
00440     // Now define the change block                 
00441     Define(OBJCHANGE_STARTING,ChgeFlags,cNode,cOp,cPath,cSpread);
00442     // Send the message to the nodes parents
00443     ChangeCode Chge = cNode->WarnParentOfChange(this,All);
00444     // Correct the message mask returned
00445     ChangeMask.CorrectMask();
00446 
00447     return Chge;
00448 }
00449 
00450 
00451 
00452 /********************************************************************************************
00453 
00454 >   ChangeCode ObjChangePathEdit::RenderCurrentBlobs(Node* cNode,
00455                                                      UndoableOperation* cOp,
00456                                                      Path* cPath,
00457                                                      Spread* cSpread,
00458                                                      BOOL All)
00459 
00460     Author:     Mike_Kenny (Xara Group Ltd) <camelotdev@xara.com>
00461     Created:    12/01/95
00462     Inputs:     See ObjChangeStarting
00463 
00464 ********************************************************************************************/
00465 
00466 ChangeCode ObjChangePathEdit::RenderCurrentBlobs(Node* cNode,
00467                                                  UndoableOperation* cOp,
00468                                                  Path* cPath,
00469                                                  Spread* cSpread,
00470                                                  BOOL All)
00471 {
00472     // Create some change flags
00473     ObjChangeFlags ChgeFlags;
00474     // Now define the change block                 
00475     Define(OBJCHANGE_RENDERCURRENTBLOBS,ChgeFlags,cNode,cOp,cPath,cSpread);
00476     return (cNode->WarnParentOfChange(this,All));
00477 }
00478 
00479 
00480 
00481 /********************************************************************************************
00482 
00483 >   ChangeCode ObjChangePathEdit::RenderChangedBlobs(Node* cNode,
00484                                                      UndoableOperation* cOp,
00485                                                      Path* cPath,
00486                                                      Spread* cSpread,
00487                                                      BOOL All)
00488 
00489     Author:     Mike_Kenny (Xara Group Ltd) <camelotdev@xara.com>
00490     Created:    12/01/95
00491     Inputs:     See ObjChangeStarting
00492 
00493 ********************************************************************************************/
00494 
00495 ChangeCode ObjChangePathEdit::RenderChangedBlobs(Node* cNode,
00496                                                  UndoableOperation* cOp,
00497                                                  Path* cPath,
00498                                                  Spread* cSpread,
00499                                                  BOOL All)
00500 {
00501     // Create some change flags
00502     ObjChangeFlags ChgeFlags;
00503     // Now define the change block                 
00504     Define(OBJCHANGE_RENDERCHANGEDBLOBS,ChgeFlags,cNode,cOp,cPath,cSpread);
00505     return (cNode->WarnParentOfChange(this,All));
00506 }
00507 
00508 
00509 
00510 /********************************************************************************************
00511 
00512 >   ChangeCode ObjChangePathEdit::ObjChangeFinished(Node* cNode,
00513                                                     UndoableOperation* cOp,
00514                                                     Path* cPath,
00515                                                     Spread* cSpread,
00516                                                     BOOL All)
00517 
00518     Author:     Mike_Kenny (Xara Group Ltd) <camelotdev@xara.com>
00519     Created:    12/01/95
00520     Inputs:     See ObjChangeStarting
00521 
00522 ********************************************************************************************/
00523 
00524 ChangeCode ObjChangePathEdit::ObjChangeFinished(Node* cNode,
00525                                                 UndoableOperation* cOp,
00526                                                 Path* cPath,
00527                                                 Spread* cSpread,
00528                                                 BOOL All)
00529 {
00530     // Create some change flags
00531     ObjChangeFlags ChgeFlags;
00532     // Now define the change block                 
00533     Define(OBJCHANGE_FINISHED,ChgeFlags,cNode,cOp,cPath,cSpread);
00534     return (cNode->WarnParentOfChange(this,All));
00535 }
00536 
00537 
00538 
00539 /********************************************************************************************
00540 
00541 >   ChangeCode ObjChangePathEdit::ObjChangeFailed(  Node* cNode,
00542                                                     UndoableOperation* cOp,
00543                                                     Path* cPath,
00544                                                     Spread* cSpread,
00545                                                     BOOL All)
00546 
00547     Author:     Mike_Kenny (Xara Group Ltd) <camelotdev@xara.com>
00548     Created:    12/01/95
00549     Inputs:     See ObjChangeStarting
00550     Purpose:    Send the parents of cNode an OBJCHANGE_FAILED message.
00551 
00552 ********************************************************************************************/
00553 
00554 ChangeCode ObjChangePathEdit::ObjChangeFailed(  Node* cNode,
00555                                                 UndoableOperation* cOp,
00556                                                 Path* cPath,
00557                                                 Spread* cSpread,
00558                                                 BOOL All)
00559 {
00560     // Create some change flags
00561     ObjChangeFlags ChgeFlags;
00562     // Now define the change block                 
00563     Define(OBJCHANGE_FAILED,ChgeFlags,cNode,cOp,cPath,cSpread);
00564     return (cNode->WarnParentOfChange(this,All));
00565 }
00566 
00567 
00570 
00571 
00572 /********************************************************************************************
00573 
00574 >   ObjChangeParamWithToken::ObjChangeParamWithToken()
00575 
00576     Author:     Peter_Arnold (Xara Group Ltd) <camelotdev@xara.com>
00577     Created:    06/03/95
00578     Purpose:    Constructor for the ObjChangeParamWithToken class.  This is almost idential
00579                 to ObjChangeParam, except that it always has an OpToken of the operation
00580                 that will be applied.  The pointer to the operation may still be NULL.
00581                 This gives you a way of seeing what the operation will be before it starts.
00582                 Most usefully in an operations GetState.
00583 
00584 ********************************************************************************************/
00585 
00586 ObjChangeParamWithToken::ObjChangeParamWithToken(   ObjChangeType cType,
00587                                                     ObjChangeFlags cFlags,
00588                                                     Node* cNode,
00589                                                     UndoableOperation* cOp,
00590                                                     String* pToken)
00591                         : ObjChangeParam(   cType,
00592                                             cFlags,
00593                                             cNode,
00594                                             cOp)
00595 {
00596     OperationToken = *pToken;
00597 }
00598 
00599 
00600 
00601 /********************************************************************************************
00602 
00603 >   ObjChangeParamWithToken::~ObjChangeParamWithToken()
00604 
00605     Author:     Peter_Arnold (Xara Group Ltd) <camelotdev@xara.com>
00606     Created:    06/03/95
00607     Purpose:    Destructor for the ObjChangeParamWithToken class
00608 
00609 ********************************************************************************************/
00610 
00611 ObjChangeParamWithToken::~ObjChangeParamWithToken()
00612 {
00613 }

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