ophist.h

Go to the documentation of this file.
00001 // $Id: ophist.h 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 
00099 // Declaration of the following classes
00100 /*
00101     OperationHistory : The operation history used to store undoable operations
00102     OpUndo           : The undo operation                                    
00103     OpRedo           : The redo operation
00104     
00105     UndoColAction    : BlobbyOp undo action
00106     RedoColAction    : BlobbyOp redo action
00107 */  
00108 
00109 
00110 
00111 /*
00112 */        
00113 
00114 #ifndef INC_OPHIST
00115 #define INC_OPHIST
00116     
00117 //#include "list.h" - in camtypes.h [AUTOMATICALLY REMOVED]
00118 //#include "undoop.h" - in camtypes.h [AUTOMATICALLY REMOVED]
00119 //#include "opdesc.h"    - in camtypes.h [AUTOMATICALLY REMOVED]
00120 
00121 #define OPTOKEN_UNDO _T("Undo")
00122 #define OPTOKEN_REDO _T("Redo")
00123 #define OPTOKEN_BLOBBY _T("Blobby")
00124 
00125 
00126 /********************************************************************************************
00127 
00128 >   class OperationHistory : public CCObject
00129 
00130     Author:     Simon_Maneggio (Xara Group Ltd) <camelotdev@xara.com>
00131     Created:    6/7/93
00132     Purpose:    This class represents the operation history for a camelot document. It is a
00133                 repository for all undoable operations performed in Camelot. It stores 
00134                 operations in chronological order and provides methods to undo and redo 
00135                 them. 
00136                 
00137     SeeAlso:    -
00138 
00139 ********************************************************************************************/
00140 
00141 class CCAPI OperationHistory: public CCObject
00142 {
00143     CC_DECLARE_MEMDUMP( OperationHistory )        
00144      
00145     friend class ActionList;        // It is neccesary for the ActionList and Action classes to be 
00146     friend class Action;            // friends of the OperationHistory class, as they both need to call 
00147                                     // the IncCurrentSize and DecCurrentSize methods. No one else should 
00148                                     // be allowed access to these methods as they are extremely dangerous.  
00149 
00150     friend class Operation;         // It is neccesary for the Operation class to be a friend of the 
00151                                     // OperationHistory class because it needs to call the Add method 
00152                                     // of the Operation history. This is another method which falls 
00153                                     // in the extremely dangerous category. 
00154 
00155     friend class OpDeleteBitmap;    // These classes need to scan all the document operation 
00156     friend class GlobalBitmapList;  // histories, looking for Bitmap References.
00157     
00158 public:                              
00159     // Constructors
00160     OperationHistory();             
00161     OperationHistory(UINT32 MaximumSize);   
00162                    
00163     // Destructor
00164     ~OperationHistory(); 
00165                  
00166     // Methods for managing the size of the operation history  
00167            
00168     BOOL SetNewMaxSize(UINT32 NewMaxSize); 
00169     UINT32 GetSize(); 
00170     UINT32 GetMaxSize();     
00171     BOOL ReduceSize(UINT32 MaxSize, BOOL ExcludeLastUndo, BOOL DeleteWhatYouCan = FALSE);   
00172     UINT32 GetNumUndoSteps();
00173     UINT32 GetNumRedoSteps();
00174     BOOL IsReduced();
00175         
00176     // Methods used to Undo/Redo operations
00177     BOOL UndoPrev(); 
00178     BOOL RedoNext(); 
00179     BOOL CanUndo();
00180     BOOL CanRedo();   
00181     
00182     // These methods will identify the name of the particular operation being undone
00183     // or redone
00184     void GetUndoOpName(String_256* OpName);
00185     void GetRedoOpName(String_256* OpName);
00186 
00187     // -------------------------------------------------------------------------------------
00188     // The following functions are useful for operation merging
00189 
00190     Operation* FindLastOp(); 
00191 
00192     // This function finds the operation which was performed prior to the last operation.
00193     Operation* FindPrevToLastOp(); 
00194 
00195     // One of these function should get called after the last operation performed has been merged with
00196     // the previous operation which has been performed.
00197     void DeleteLastOp(BOOL ReduceOpHistSize = TRUE); 
00198     void DeletePrevToLastOp(BOOL ReduceOpHistSize = TRUE);
00199 
00200     // function for dumping the operation history to the debugger
00201     void DumpAll();
00202     void DumpLast();
00203 
00204     // -------------------------------------------------------------------------------------
00205 
00206 #ifdef _DEBUG
00207     void DebugSizeCheck();
00208 #endif
00209     void DeleteUndoableOps(); 
00210     void DeleteRedoableOps(); 
00211 private:            
00212 
00213     // methods called by the ActionList and Action classes
00214     void IncSize(UINT32 SizeIncrement);  
00215     void DecSize(UINT32 SizeDecrement);            
00216     
00217     // Add should be called by the operation's End method and no where else.
00218     void Add(ListItem* Operation); 
00219       
00220     UINT32 MaxSize;           // The maximum size of the operation history (bytes)
00221     UINT32 CurrentSize;       // The current size of the operation history (bytes)
00222     List OpHistoryList;      // List holding past and future operations    
00223      
00224     ListItem* NowPtr;        // Pointer to the last operation in the OpHistoryList which has 
00225                              // been performed and not undone. The operation to which the NowPtr 
00226                              // points, and all previous operations are undoable (They have 
00227                              // actions on their undo action lists). All operations in the 
00228                              // OpHistoryList after the NowPtr are redoable (They have actions 
00229                              // on their redo action lists). When the NowPtr is NULL then no 
00230                              // undo operations exist in the operation history, in this situation
00231                              // if any redo operations exist then the first will be found at the 
00232                              // head of the OpHistoryList.  
00233     BOOL Reduced;            // Set to true if records have been discarded due to lack of memory
00234 };                
00235 
00236 /********************************************************************************************
00237 
00238 >   class OpUndo : public Operation
00239 
00240     Author:     Phil_Martin (Xara Group Ltd) <camelotdev@xara.com>
00241     Created:    9/7/93
00242     Purpose:    This class represents the Undo operation.
00243     SeeAlso:    OpRedo
00244 
00245 ********************************************************************************************/
00246 
00247 class CCAPI OpUndo: public Operation
00248 {         
00249 
00250     CC_DECLARE_DYNCREATE( OpUndo )    
00251 
00252 public:
00253     OpUndo();                               // Constructor
00254 
00255     static BOOL     Init();                 // Register an OpDescriptor
00256                                             // Read the state of an operation
00257     static OpState  GetState(String_256*, OpDescriptor*);       
00258 
00259     void            Do(OpDescriptor*);      // "Do" function    
00260 };
00261 
00262 
00263 /********************************************************************************************
00264 
00265 >   class OpRedo : public Operation
00266 
00267     Author:     Phil_Martin (Xara Group Ltd) <camelotdev@xara.com>
00268     Created:    9/7/93
00269     Purpose:    This class represents the Redo operation.
00270     SeeAlso:    OpRedo
00271 
00272 ********************************************************************************************/
00273 
00274 class CCAPI OpRedo: public Operation
00275 {                           
00276 
00277     CC_DECLARE_DYNCREATE( OpRedo )    
00278     
00279 public:
00280                     OpRedo();               // Constructor
00281 
00282     static BOOL     Init();                 // Register an OpDescriptor
00283                                             // Read the state of an operation
00284     static OpState  GetState(String_256*, OpDescriptor*);       
00285 
00286     void            Do(OpDescriptor*);      // "Do" function
00287 
00288 };
00289 
00290 
00291 /********************************************************************************************/
00292 //
00293 
00294 #endif

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