00001 // $Id: ngiter.h 751 2006-03-31 15:43: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 $Header: /Camelot/kernel/ngiter.h 2 8/11/99 12:06 Justinf $ 00100 Classes to iterate through the objects in the document and over Attribute gallery 00101 groups and items. 00102 */ 00103 00104 #ifndef NGITER_H 00105 #define NGITER_H 00106 00107 class Node; 00108 class UndoableOperation; 00109 class SGNameGroup; 00110 class SGNameItem; 00111 00112 00113 /*********************************************************************************************** 00114 > class CCAPI NodeScan 00115 00116 Author: Justin_Flude (Xara Group Ltd) <camelotdev@xara.com> 00117 Created: 27/7/99 00118 Purpose: Abstract base class for scans over sequences of nodes. 00119 SeeAlso: NameGallery; NodeScan::Source 00120 ***********************************************************************************************/ 00121 00122 class CCAPI NodeScan 00123 { 00124 public: 00125 /****************************************************************************************** 00126 > class CCAPI NodeScan::Source 00127 00128 Author: Justin_Flude (Xara Group Ltd) <camelotdev@xara.com> 00129 Created: 27/7/99 00130 Purpose: Abstract base class for interfaces to SelRanges, Document trees etc whose 00131 nodes can be scanned over. 00132 Notes: If your derived class defines data members then remember to define a copy 00133 constructor and consider concurrency issues! 00134 ******************************************************************************************/ 00135 class CCAPI Source 00136 { 00137 public: 00138 // Creation & destruction. 00139 virtual ~Source() { /* empty */ } 00140 virtual Node* GetFirst() = 0; 00141 virtual Node* GetNext(Node* pLastNode) = 0; 00142 }; 00143 00144 // Creation & destruction. 00145 NodeScan(Source* ps); 00146 virtual ~NodeScan(); 00147 00148 // Scan through the source's nodes. 00149 BOOL Scan(); 00150 00151 protected: 00152 // Called before, during and after the scan through the document's tree. 00153 virtual BOOL Pre(); 00154 virtual BOOL Do(Node* pNode) = 0; 00155 virtual BOOL Post(); 00156 00157 private: 00158 // Data. 00159 Source* m_pSource; // where to get the nodes to scan 00160 }; 00161 00162 00163 00164 /******************************************************************************************** 00165 > class CCAPI UndoableNodeScan : public NodeScan 00166 00167 Author: Justin_Flude (Xara Group Ltd) <camelotdev@xara.com> 00168 Created: 21/11/96 00169 Purpose: Base class for NodeScans which are used by UndoableOperations. 00170 ********************************************************************************************/ 00171 00172 class CCAPI UndoableNodeScan : public NodeScan 00173 { 00174 public: 00175 UndoableNodeScan(UndoableOperation* pOp, Source* ps); 00176 00177 protected: 00178 UndoableOperation* m_pOp; 00179 }; 00180 00181 00182 00183 /*********************************************************************************************** 00184 > class CCAPI DocTreeSource : public NodeScan::Source 00185 class CCAPI SelectDocSource : public DocTreeSource 00186 00187 Author: Justin_Flude (Xara Group Ltd) <camelotdev@xara.com> 00188 Created: 27/7/99 00189 Purpose: Concretisation of NodeScan::Source for all NodeRenderableInks in a 00190 document's object tree (generally), or in the 'selected' document's 00191 tree (specifically). 00192 ***********************************************************************************************/ 00193 00194 class CCAPI DocTreeSource : public NodeScan::Source 00195 { 00196 public: 00197 // Creation & destruction. 00198 DocTreeSource(BaseDocument* pDoc = 0); 00199 00200 protected: 00201 virtual Node* GetFirst(); 00202 virtual Node* GetNext(Node*); 00203 00204 BaseDocument* m_pDoc; // the document whose tree is to be scanned 00205 }; 00206 00207 00208 class CCAPI SelectDocSource : public DocTreeSource 00209 { 00210 protected: 00211 virtual Node* GetFirst(); 00212 }; 00213 00214 00215 00216 /*********************************************************************************************** 00217 > class CCAPI RangeSource : public NodeScan::Source 00218 class CCAPI SelectObjSource : public RangeSource 00219 00220 Author: Justin_Flude (Xara Group Ltd) <camelotdev@xara.com> 00221 Created: 27/7/99 00222 Purpose: Concretisation of NodeScan::Source for all NodeRenderableInks in a Range 00223 (generally), or in the Application's SelRange object (specifically). 00224 ***********************************************************************************************/ 00225 00226 class CCAPI RangeSource : public NodeScan::Source 00227 { 00228 public: 00229 // If pRange is supplied then use pRange, otherwise use Application::FindSelection. 00230 RangeSource(Range* pRange = 0); 00231 00232 protected: 00233 virtual Node* GetFirst(); 00234 virtual Node* GetNext(Node*); 00235 00236 Range* m_pRange; // the range to be scanned 00237 }; 00238 00239 00240 class CCAPI SelectObjSource : public RangeSource 00241 { 00242 protected: 00243 virtual Node* GetFirst(); 00244 }; 00245 00246 00247 00248 /*********************************************************************************************** 00249 > class CCAPI NotSelectSource : public SelectDocSource 00250 00251 Author: Justin_Flude (Xara Group Ltd) <camelotdev@xara.com> 00252 Created: 27/7/99 00253 Purpose: Concretisation of NodeScan::Source for all NodeRenderableInks NOT in the 00254 application's selection range. 00255 ***********************************************************************************************/ 00256 00257 class CCAPI NotSelectSource : public SelectDocSource 00258 { 00259 protected: 00260 virtual Node* GetFirst(); 00261 virtual Node* GetNext(Node*); 00262 }; 00263 00264 00265 00266 /*********************************************************************************************** 00267 > class CCAPI SingleNodeSource : public NodeScan::Source 00268 class CCAPI SetSentinelSource : public SingleNodeSource 00269 00270 Author: Justin_Flude (Xara Group Ltd) <camelotdev@xara.com> 00271 Created: 27/7/99 00272 Purpose: Concretisation of NodeScan::Source for a "scan" over a single node 00273 (generally), and over the 'selected' document's NodeSetSentinel sentinel 00274 (specifically). 00275 ***********************************************************************************************/ 00276 00277 class CCAPI SingleNodeSource : public NodeScan::Source 00278 { 00279 public: 00280 SingleNodeSource(Node* pNode = 0); 00281 00282 protected: 00283 virtual Node* GetFirst(); 00284 virtual Node* GetNext(Node*); 00285 00286 Node* m_pNode; 00287 }; 00288 00289 00290 class CCAPI SetSentinelSource : public SingleNodeSource 00291 { 00292 protected: 00293 virtual Node* GetFirst(); 00294 }; 00295 00296 00297 00298 /*********************************************************************************************** 00299 > extern SelectDocSource theSelectedDocument; 00300 extern SelectObjSource theSelectedObjects; 00301 extern NotSelectSource theUnselectedObjects; 00302 extern SetSentinelSource theSetSentinel; 00303 00304 Author: Justin_Flude (Xara Group Ltd) <camelotdev@xara.com> 00305 Created: 27/7/99 00306 Purpose: Predefined sources for NodeScans: the nodes in the tree of the 'selected' 00307 document; the nodes in the application's selection; the unselected nodes 00308 in the tree of the 'selected' document; the special NodeSetSentinel 00309 ***********************************************************************************************/ 00310 00311 extern SelectDocSource theSelectedDocument; 00312 extern SelectObjSource theSelectedObjects; 00313 extern NotSelectSource theUnselectedObjects; 00314 extern SetSentinelSource theSetSentinel; 00315 00316 00317 00318 /*********************************************************************************************** 00319 > class CCAPI NameGroupIter 00320 00321 Author: Justin_Flude (Xara Group Ltd) <camelotdev@xara.com> 00322 Created: 27/7/99 00323 Purpose: Base classes for iterations and searches over all groups and all items in 00324 the name gallery. 00325 ***********************************************************************************************/ 00326 00327 class CCAPI NameGroupIter 00328 { 00329 public: 00330 virtual ~NameGroupIter() { } 00331 // Calls Do() for each group in the name gallery. 00332 virtual SGNameGroup* ForEach(); 00333 00334 private: 00335 // Returns TRUE if sucessful and iteration should continue. 00336 virtual BOOL Do(SGNameGroup* pGroup) = 0; 00337 }; 00338 00339 00340 00341 /*********************************************************************************************** 00342 > class CCAPI NameItemIter 00343 00344 Author: Justin_Flude (Xara Group Ltd) <camelotdev@xara.com> 00345 Created: 27/7/99 00346 Purpose: Abstract base classes for iterations and searches over all groups and all 00347 items in the Name gallery. 00348 ***********************************************************************************************/ 00349 00350 class CCAPI NameItemIter 00351 { 00352 public: 00353 virtual ~NameItemIter() { } 00354 // Only iterate over particular items - just highlighted ones, or just those of 00355 // the 'Used Names' group. 00356 enum Mask { ALL_ITEMS, ALL_NAMES, HIGHLIGHTED_ITEMS, HIGHLIGHTED_NAMES }; 00357 NameItemIter(Mask mask = ALL_ITEMS); 00358 00359 // Calls Do() for each item in the name gallery. 00360 virtual SGNameItem* ForEach(); 00361 00362 protected: 00363 // Helper function for ForEach, above. 00364 SGNameItem* ForEachItem(SGNameGroup* pGroup); 00365 00366 private: 00367 // Returns TRUE if sucessful and iteration should continue. 00368 virtual BOOL Do(SGNameItem* pItem) = 0; 00369 Mask m_eMask; 00370 }; 00371 00372 00373 00374 /*********************************************************************************************** 00375 > class CCAPI NameIterOp : public NameItemIter 00376 00377 Author: Justin_Flude (Xara Group Ltd) <camelotdev@xara.com> 00378 Created: 27/7/99 00379 Purpose: Specialisation of base class to combine a node and an operation. 00380 ***********************************************************************************************/ 00381 00382 class CCAPI NameIterOp : public NameItemIter 00383 { 00384 public: 00385 NameIterOp(Node* pNode, UndoableOperation* pOp = 0, Mask mask = HIGHLIGHTED_NAMES); 00386 00387 protected: 00388 Node* m_pNode; 00389 UndoableOperation* m_pOp; 00390 }; 00391 00392 #endif /* !NGITER_H */