attraggl.h

Go to the documentation of this file.
00001 // $Id: attraggl.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 
00100 #ifndef INC_ATTRAGGL
00101 #define INC_ATTRAGGL
00102 
00103 
00104 
00105 class CommonAttrMultiSet;
00106 class NodeAttribute;
00107 class MultiCommonAttrItem;
00108 
00109 //#include <afxtempl.h>
00110 
00111 inline BOOL CompareElements(const StringBase** pElement1, const StringBase** pElement2)
00112 {
00113     const StringBase* const pString1 = *pElement1;
00114     const StringBase* const pString2 = *pElement2;
00115 
00116     return (*pString1 == *pString2);
00117 }
00118 
00119 // This function isn't needed on VC5 or later...
00120 //#if _MSC_VER < 1100
00121 /*inline UINT32 AFXAPI HashKey( const StringBase* pKey )
00122 {
00123     return HashKey((const TCHAR*)(*pKey));
00124 } */
00125 //#endif
00126 
00127 class CommonAttrMap : public CMap<const StringBase*, const StringBase*, MultiCommonAttrItem*, MultiCommonAttrItem*>
00128 {
00129 public:
00130     CommonAttrMap(INT32 nBlockSize = 10) : CMap<const StringBase*, const StringBase*, MultiCommonAttrItem*, MultiCommonAttrItem*>(nBlockSize) {}
00131 
00132 
00133 };
00134 
00135 
00136 class NodePointer : public ListItem
00137 {
00138     // Declare the class for memory tracking
00139     CC_DECLARE_MEMDUMP(NodePointer);
00140 public:
00141     NodePointer(NodeAttribute& AttributeNode, AttributeIdentifier AttrID) :
00142         m_AttrID(AttrID),
00143         m_AttributeNode(AttributeNode)
00144         {}
00145 
00146     AttributeIdentifier     GetAttrID() const       {   return m_AttrID;    }
00147     NodeAttribute&          GetNode() const         {   return m_AttributeNode; }
00148 
00149 private:
00150     AttributeIdentifier m_AttrID;
00151     NodeAttribute&      m_AttributeNode;
00152 };
00153 
00154 
00155 class CCUserAttrMap : public CMap<const StringBase*, const StringBase*, NodeAttribute*, NodeAttribute*>
00156 {
00157     typedef CMap<const StringBase*, const StringBase*, NodeAttribute*, NodeAttribute*> BaseMap;
00158 public:
00159     CCUserAttrMap(INT32 nBlockSize = 10) : 
00160         BaseMap(nBlockSize)
00161         {}
00162 
00163     virtual ~CCUserAttrMap();
00164         
00165     BOOL SetAt(const StringBase* key, NodeAttribute* pNewAttributeNode);
00166     void RemoveAll();
00167 
00168     NodePointer*    FindFirst() const;
00169     NodePointer*    FindNext(const NodePointer* const pPrevious) const;
00170 
00171 private:
00172     List    m_NodeAttributes;
00173 };
00174 
00175 
00176 extern String_8 NonConstNullString;
00177 /********************************************************************************************
00178 
00179 >   class RenderableNodeEnumerator : public CC_CLASS_MEMDUMP
00180 
00181     Author:     Colin_Barfoot (Xara Group Ltd) <camelotdev@xara.com>
00182     Created:    20/06/97
00183 
00184     Purpose:    Iterates through a series of NodeRenderable nodes
00185 
00186 ********************************************************************************************/
00187 class RenderableNodeEnumerator : public CC_CLASS_MEMDUMP
00188 {
00189     // Declare the class for memory tracking
00190     CC_DECLARE_MEMDUMP(RenderableNodeEnumerator);
00191 
00192 public:
00193     virtual ~RenderableNodeEnumerator() { }
00194     virtual NodeRenderable* FindFirst() const = 0;
00195     virtual NodeRenderable* FindNext(NodeRenderable* const pPrevious) const = 0;
00196 };
00197 
00198 
00199 
00200 /********************************************************************************************
00201 
00202 >   class RangeEnumerator : public RenderableNodeEnumerator
00203 
00204     Author:     Colin_Barfoot (Xara Group Ltd) <camelotdev@xara.com>
00205     Created:    20/06/97
00206 
00207     Purpose:    Iterates through a series of NodeRenderable nodes
00208 
00209 ********************************************************************************************/
00210 class RangeEnumerator : public RenderableNodeEnumerator
00211 {
00212     // Declare the class for memory tracking
00213     CC_DECLARE_MEMDUMP(RangeEnumerator);
00214 
00215 public:
00216     RangeEnumerator(Range* const pRange) : m_pRange(pRange) {}
00217 
00218     // Not sure how we get away with this...
00219     virtual NodeRenderable* FindFirst() const                                   {   return (NodeRenderable*)m_pRange->FindFirst();  }
00220     virtual NodeRenderable* FindNext(NodeRenderable* const pPrevious) const {   return (NodeRenderable*)m_pRange->FindNext((Node*)pPrevious);   }
00221 
00222 private:
00223     Range*  m_pRange;
00224 };
00225 
00226 class DocPseudoEnumerator : public RenderableNodeEnumerator
00227 {
00228     // Declare the class for memory tracking
00229     CC_DECLARE_MEMDUMP(DocPseudoEnumerator);
00230 
00231 public:
00232     DocPseudoEnumerator(Document* const pDocument) : m_pDocument(pDocument) {}
00233 
00234     // Not sure how we get away with this...
00235     virtual NodeRenderable* FindFirst() const;
00236     virtual NodeRenderable* FindNext(NodeRenderable* const pPrevious)    const  {   return NULL;    }
00237 
00238 private:
00239     Document*       m_pDocument;
00240 };
00241 
00242 
00243 /********************************************************************************************
00244 
00245 >   class AttributeAgglomerator : public CC_CLASS_MEMDUMP
00246 
00247     Author:     Colin_Barfoot (Xara Group Ltd) <camelotdev@xara.com>
00248     Created:    20/06/97
00249 
00250     Purpose:    An AttributeAgglomerator finds the Common Attributes among the nodes
00251                 provided by an RenderableNodeEnumerator.
00252                 This allows us to derive classes to retrieve more specialized attributes,
00253                 namely AttrUser's.
00254     Notes:      This code was copied from Range. It should either replace the code there
00255                 or be thrown out when plug-in attributes are supported.
00256 
00257 ********************************************************************************************/
00258 class AttributeAgglomerator : public CC_CLASS_MEMDUMP
00259 {
00260     CC_DECLARE_MEMDUMP(AttributeAgglomerator);
00261 
00262 public:
00263     virtual ~AttributeAgglomerator() { }
00264     BOOL FindCommonAttributes(  RenderableNodeEnumerator& Enumerator, 
00265                                 CommonAttrMultiSet* const pCommonAttributeSet);
00266 
00267     static const UINT32 MaxAttributes;
00268 
00269 protected:
00270     virtual AttributeIdentifier GetAttributeType(NodeAttribute* const pAttrib) const = 0;
00271     virtual BOOL FindAppliedAttributes(Node* const pNode, CCUserAttrMap* const pAttribMap) const;
00272 
00273 };
00274 
00275 
00276 
00277 /********************************************************************************************
00278 
00279 >   class UserAttributeAgglomerator : public AttributeAgglomerator
00280 
00281     Author:     Colin_Barfoot (Xara Group Ltd) <camelotdev@xara.com>
00282     Created:    20/06/97
00283 
00284     Purpose:    An AttributeAgglomerator finds the Common Attributes among the nodes
00285                 provided by an RenderableNodeEnumerator.
00286                 This allows us to derive classes to retrieve more specialized attributes,
00287                 namely AttrUser's.
00288 
00289 ********************************************************************************************/
00290 class UserAttributeAgglomerator : public AttributeAgglomerator
00291 {
00292     CC_DECLARE_MEMDUMP(UserAttributeAgglomerator);
00293 
00294 public:
00295 
00296 protected:
00297     virtual AttributeIdentifier GetAttributeType(NodeAttribute* const pAttrib) const;
00298 };
00299 
00300 
00301 
00302 /********************************************************************************************
00303 
00304 >   class AppliedAttribute : public VisibleListItem
00305 
00306     Author:     Colin_Barfoot (Xara Group Ltd) <camelotdev@xara.com>
00307     Created:    01/07/97
00308 
00309     Purpose:    At the moment it allows applied attributes to appear in a list, but will 
00310                 probably supersede the MultiCommonAttrItem class.
00311 
00312 ********************************************************************************************/
00313 class AppliedAttribute : public VisibleListItem
00314 {
00315     CC_DECLARE_MEMDUMP(AppliedAttribute);
00316 public:
00317 //  Don't forget to supply these
00318 //  virtual BOOL Display(DialogOp& Dialog) = 0;
00319 //  virtual void Hide() = 0;
00320 //  virtual StringBase& GetText(StringBase& Description) const = 0;
00321     virtual BOOL operator > (const VisibleListItem& OtherItem) const;
00322     virtual AttributeIdentifier GetAttrID() const = 0;
00323     virtual BOOL ApplyAttribute(Operation& OpToApplyWith) = 0;
00324     virtual VisibleAttribute* GetVisibleAttribute() = 0;
00325 };
00326 
00327 
00328 /********************************************************************************************
00329 
00330 >   class SingletonAppliedAttribute : public AppliedAttribute
00331 
00332     Author:     Colin_Barfoot (Xara Group Ltd) <camelotdev@xara.com>
00333     Created:    01/07/97
00334 
00335     Purpose:    Represents an applied attribute of which there is only one for the objects
00336                 given by the iterator.
00337 
00338 ********************************************************************************************/
00339 class SingletonAppliedAttribute : public AppliedAttribute
00340 {
00341     // Declare the class for memory tracking
00342     CC_DECLARE_MEMDUMP(SingletonAppliedAttribute);
00343 
00344 public:
00345     SingletonAppliedAttribute(NodeAttribute& TheAttribute);
00346     SingletonAppliedAttribute(VisibleAttribute& TheVisibleAttribute);
00347     SingletonAppliedAttribute(const SingletonAppliedAttribute& Other) : m_AttrID(NonConstNullString)
00348         {   TRACE( wxT("SingletonAppliedAttribute copy constructor not implemented\n") );   }
00349 
00350     virtual ~SingletonAppliedAttribute();
00351 
00352 // Implemented pure functions
00353 //  from UserInterface...
00354     virtual BOOL Display(DialogOp& Dialog);
00355 //  virtual BOOL Interact(DialogOp& Dialog);    // well it should be in UserInterface
00356     virtual void Hide();
00357 
00358 //  from VisibleListItem...
00359     virtual StringBase& GetText(StringBase& Description) const;
00360 
00361 //  from AppliedAttribute...
00362     virtual AttributeIdentifier GetAttrID() const               {   return m_AttrID;    }
00363     virtual BOOL ApplyAttribute(Operation& OpToApplyWith);
00364     virtual VisibleAttribute* GetVisibleAttribute() {   return m_pVisibleAttribute; }
00365 
00366 private:
00367     // should be a reference...
00368     VisibleAttribute*   m_pVisibleAttribute;
00369     String_128          m_AttrID;
00370     DialogOp*           m_pDialog;
00371 };
00372 
00373 
00374 /********************************************************************************************
00375 
00376 >   class CommonAppliedAttribute : public AppliedAttribute
00377 
00378     Author:     Colin_Barfoot (Xara Group Ltd) <camelotdev@xara.com>
00379     Created:    01/07/97
00380 
00381     Purpose:    Represents an applied attribute of which there is only one for the objects
00382                 given by the iterator.
00383 
00384 ********************************************************************************************/
00385 class CommonAppliedAttribute : public AppliedAttribute
00386 {
00387     // Declare the class for memory tracking
00388     CC_DECLARE_MEMDUMP(CommonAppliedAttribute);
00389 
00390 public:
00391     CommonAppliedAttribute(NodeAttribute& AttrInstance);
00392     virtual ~CommonAppliedAttribute();
00393     CommonAppliedAttribute(const CommonAppliedAttribute& Other) : m_AttrID(NullString)
00394         { TRACE( wxT("CommonAppliedAttribute copy constructor not implemented\n") ); }
00395 
00396 // Implemented pure functions
00397 //  from UserInterface...
00398     virtual BOOL Display(DialogOp& Dialog);
00399     virtual void Hide();
00400 
00401 //  from VisibleListItem...
00402     virtual StringBase& GetText(StringBase& Description) const;
00403 
00404 //  from AppliedAttribute...
00405     virtual AttributeIdentifier GetAttrID() const               {   return m_AttrID;    }
00406     virtual BOOL ApplyAttribute(Operation& OpToApplyWith);
00407     virtual VisibleAttribute* GetVisibleAttribute()             {   return m_pVisibleAttribute; }
00408 
00409 private:
00410     // should be a reference...
00411     VisibleAttribute*   m_pVisibleAttribute;
00412     AttributeIdentifier m_AttrID;
00413 };
00414 
00415 
00416 /********************************************************************************************
00417 
00418 >   class MultiAppliedAttribute : public AppliedAttribute
00419 
00420     Author:     Colin_Barfoot (Xara Group Ltd) <camelotdev@xara.com>
00421     Created:    01/07/97
00422 
00423     Purpose:    Represents an applied attribute of which there is only one for the objects
00424                 given by the iterator.
00425 
00426 ********************************************************************************************/
00427 class MultiAppliedAttribute : public AppliedAttribute
00428 {
00429     // Declare the class for memory tracking
00430     CC_DECLARE_MEMDUMP(MultiAppliedAttribute);
00431 
00432 public:
00433     MultiAppliedAttribute(NodeAttribute& AttrInstance);
00434 // Implemented pure functions
00435 //  from UserInterface...
00436     virtual BOOL Display(DialogOp& Dialog);
00437     virtual void Hide();
00438 
00439 //  from VisibleListItem...
00440     virtual StringBase& GetText(StringBase& Description) const;
00441 
00442 //  from AppliedAttribute...
00443     virtual AttributeIdentifier GetAttrID() const           {   return m_AttrID;    }
00444     virtual BOOL ApplyAttribute(Operation& OpToApplyWith)   {   return TRUE;    }   // DON'T DO IT!
00445     virtual VisibleAttribute* GetVisibleAttribute()         {   return NULL;    }
00446 
00447 protected:
00448     const StringBase& GetAttributeDescription() const;
00449 
00450 private:
00451     String_64           m_AttributeDescription;
00452     AttributeIdentifier m_AttrID;
00453 };
00454 
00455 
00456 /********************************************************************************************
00457 
00458 >   class MultiCommonAttrItem: public ListItem
00459 
00460     Author:     Simon_Maneggio (Xara Group Ltd) <camelotdev@xara.com>
00461     Created:    3/8/94
00462 
00463     Purpose:    This ListItem is used by Range::FindCommonAttributes.
00464 
00465 ********************************************************************************************/
00466 class MultiCommonAttrItem : public ListItem
00467 {
00468     // Declare the class for memory tracking
00469     CC_DECLARE_MEMDUMP(MultiCommonAttrItem);
00470  
00471 public:
00472     MultiCommonAttrItem(AttributeIdentifier AttrType, NodeAttribute* const pAttr = NULL);
00473     ~MultiCommonAttrItem();  
00474 
00475     void ClearResults();
00476 
00477     enum CAResult {     AA_INVALID = 0,     // indicates uninitialized data
00478                         AA_NONE = 1, 
00479                         AA_SINGLE,
00480                         AA_COMMON,
00481                         AA_MANY
00482                     };
00483 
00484     AttributeIdentifier         GetAttrID() const       {   return m_AttrType;  }
00485     const CAResult&             GetStatus() const       {   return m_Status;    }
00486     NodeAttribute*              GetNode() const         {   return m_pAttr; }
00487 
00488     void SetStatus(const CAResult& Status)              {   m_Status = Status;  }
00489     void SetNode(NodeAttribute* const pAttr)            {   m_pAttr = pAttr;    }
00490 
00491     AppliedAttribute* CreateVisibleAppliedAttribute() const;    // don't do it like this
00492 
00493 private:        
00494     CAResult                    m_Status;
00495     AttributeIdentifier         m_AttrType;     // The RuntimeClass of the attribute
00496     NodeAttribute*              m_pAttr;        // A pointer to an instance of an attribute with AttrType
00497                                                 // Runtime class - can be NULL
00498     BOOL                        m_AttrIsCopy;   // Is pAttr a pointer to an attribute, or a copy. If it is a 
00499                                                 // copy then it is the responsibility of the MultiCommonAttrItem's
00500                                                 // destructor to destroy it.
00501 };
00502 
00503 
00504 
00505 /********************************************************************************************
00506 
00507 >   class CommonAttrMultiSet : public CommonAttrMap
00508 
00509     Author:     Colin_Barfoot (Xara Group Ltd) <camelotdev@xara.com> (from Simon)
00510     Created:    13/9/95
00511 
00512     Purpose:    A CommonAttributeSet. See Range::FindCommonAttributes 
00513 
00514     SeeAlso:    MultiCommonAttrItem
00515 
00516 ********************************************************************************************/
00517 class CommonAttrMultiSet : public CommonAttrMap
00518 {
00519 public:
00520     virtual ~CommonAttrMultiSet();
00521 
00522     void ClearResults();
00523 
00524     // Methods for setting up the CommonAttrMultiSet prior to a call to FindCommonAttributes
00525     virtual BOOL AddTypeToSet(AttributeIdentifier AttrType, NodeAttribute* const pAttr);
00526 
00527     // Methods for accessing the CommonAttrMultiSet 
00528     MultiCommonAttrItem*    FindAttrItem(AttributeIdentifier AttrType);
00529     MultiCommonAttrItem*    FindFirst() const;
00530     MultiCommonAttrItem*    FindNext(const MultiCommonAttrItem* const pPrevious) const;
00531 
00532 protected:
00533 private:
00534     List    m_CommonAttrList;
00535 };
00536 
00537 
00538 #endif  // INC_ATTRAGGL

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