range.h

Go to the documentation of this file.
00001 // $Id: range.h 1252 2006-06-05 14:59:29Z phil $
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 class Range */      
00100      
00101 /*
00102 */
00103 
00104 
00105 #ifndef INC_RANGE
00106 #define INC_RANGE
00107 
00108 #include "docrect.h"
00109 #include "pump.h"
00110 
00111 class NodeAttribute;
00112 class BaseDocument;
00113 class ObjChangeParam;
00114 class ObjectSet;
00115 class CommonAttributeItem;
00116 class CCAttrMap;
00117 class TransformBase;
00118 class KernelBitmap;
00119 class KernelBitmapRef;
00120 class NodeBitmap;
00121 class AttrFillGeometry;
00122 class EffectsStack;
00123 class ListRange;
00124 class Layer;
00125 
00126 // Define this if you want Phil's new SelRange area and perimeter features
00127 //#define SELECTION_AREA_FEATURE
00128 
00129 // Macros for scanning ranges of nodes...
00130 //
00131 
00132 /********************************************************************************************
00133 
00134 >   void SCANRANGE(Range *pRange, NodeMethod func)
00135 
00136     Author:     Phil_Martin (Xara Group Ltd) <camelotdev@xara.com>
00137 +   Created:    ?
00138     Purpose:    MACRO
00139                 Applies the given method to every node in the given Range.
00140                 i.e.
00141                 MonoOn
00142                     for (every item 'Node' in pRange)
00143                         Node->\bfunc\b0;
00144                 MonoOff
00145                 
00146 ********************************************************************************************/
00147 
00148 
00149 #define SCANRANGE(pRange,func) {\
00150                                 Node* pNode = pRange->FindFirst();\
00151                                 while (pNode)\
00152                                     {\
00153                                         pNode->func;\
00154                                         pNode = pRange->FindNext(pNode);\
00155                                     }\
00156                                 }
00157 
00158 
00159 /********************************************************************************************
00160 
00161 >   void SCANRANGEFORCLASS(Range *pRange, NodeMethod func, RunTimeClass RunTimeClass)
00162 
00163     Author:     Jason_Williams (Xara Group Ltd) <camelotdev@xara.com>
00164     Created:    04/03/94
00165     Purpose:    MACRO
00166                 Applies the given method to every node of type 'RunTimeClass' in
00167                 the given Range, i.e.
00168                 MonoOn
00169                     for (every item 'Node' in pRange)
00170                         if (Node->IsKindOf(CC_RUNTIME_CLASS(\bRunTimeClass\b0)))
00171                             Node->\bfunc\b0;
00172                 MonoOff
00173                 
00174 ********************************************************************************************/
00175 
00176 #define SCANRANGEFORCLASS(pRange, func, RuntimeClass)                       \
00177                 {                                                           \
00178                     Node *Node = pRange->FindFirst();                       \
00179                     while (Node)                                            \
00180                     {                                                       \
00181                         if (Node->IsKindOf(CC_RUNTIME_CLASS(RuntimeClass))) \
00182                             ((RuntimeClass *)Node)->func;                   \
00183                         Node = pRange->FindNext(Node);                      \
00184                     }                                                       \
00185                 }
00186 
00187 
00188 
00189 /********************************************************************************************
00190 
00191 >   void SCANSELECTION(NodeMethod func)
00192 
00193     Author:     Phil_Martin (Xara Group Ltd) <camelotdev@xara.com>
00194     Created:    ?
00195     Purpose:    MACRO
00196                 Applies the given method to every node in the Selection
00197                 i.e.
00198                 MonoOn
00199                     for (every item 'Node' in the Selection)
00200                         Node->\bfunc\b0;
00201                 MonoOff
00202                 
00203 ********************************************************************************************/
00204 
00205 #define SCANSELECTION(func) {\
00206                             SelRange* pSel = GetApplication()->FindSelection();\
00207                             Node* pNode = pSel->FindFirst();\
00208                             while (pNode)\
00209                                 {\
00210                                     pNode->func;\
00211                                     pNode = pSel->FindNext(pNode);\
00212                                 }\
00213                             }
00214 
00215 
00216 // The RangeControl type is required by Node's range functions. It is used to define the 
00217 // nodes which are members of a range.  
00218 //
00219 struct CCAPI RangeControl
00220 {
00221     RangeControl(BOOL Sel = FALSE,
00222                          BOOL Unsel = FALSE,
00223                          BOOL Cross = FALSE,
00224                          BOOL IgLock = FALSE,
00225                          BOOL Rendr = FALSE,
00226                          BOOL IgInvisible = FALSE,
00227                          BOOL SibsOnly = FALSE,
00228                          BOOL PromoteToParent = FALSE);     // Default constructor
00229 
00230     BOOL    Selected    :1;         // Selected nodes are included in the range
00231     BOOL    Unselected  :1;         // Unselected nodes are included in the range
00232     BOOL    CrossLayer  :1;         // Range can cross layers
00233     BOOL    IgnoreLockedLayers:1;   // Range will not enter locked layers
00234     BOOL    IgnoreNoneRenderable:1; // Dont include nodes whose NeedsToRender is false
00235     BOOL    IgnoreInvisibleLayers:1;// Range will not include invisible layers
00236     BOOL    SiblingsOnly:1;         // Only siblings from the first node are examined
00237     BOOL    PromoteToParent:1;      // Promotes nodes to the nodes with ShouldITransformWithChildren()
00238                                     // set to TRUE. Allows controller nodes to insert themselves
00239                                     // into the selection if a transformation on their children
00240                                     // needs to be applied through them.
00241 }; 
00242 
00243 
00244 // The description format type is used to specify the format of the description generated
00245 // by the describe range function. 
00246 
00247 enum DescriptionFormat {MENU, STATUS_BAR}; 
00248 
00249 
00250             
00251 class Node;     
00252 
00253 
00254 /********************************************************************************************
00255 
00256 > struct XOROutlineInfoStr
00257 
00258     Author:     Jason_Williams (Xara Group Ltd) <camelotdev@xara.com>
00259 
00260     Purpose:    Contains information used by the XOR Outline rendering functions in the
00261                 Range. THis includes a pointer to the "Prime Object" (which is the
00262                 object that the user clicked on to start their drag), a rectangle
00263                 which is used when comparing object sizes to determine how significant
00264                 they are in the current drag (more significant objects are drawn first)
00265                 and a couple of flags indicating if the significance region is based
00266                 on the entire screen size or not, and whether the information is
00267                 currently cached correctly.
00268 
00269 ********************************************************************************************/
00270 
00271 typedef struct
00272 {
00273     Node    *PrimeObject;                   // The first object to draw (the one Mr. user clicked)
00274     DocRect SigRegion;                      // Region on which significance calculations are based
00275     BOOL    SigRegionIsScreen;              // The above region was whole visible screen area
00276     BOOL    Cached;                         // TRUE if the above info has been cached
00277 } XOROutlineInfoStr;
00278 
00279 
00280 
00281 /********************************************************************************************
00282 
00283 >   class Range : public CCObject
00284 
00285     Author:     Simon_Maneggio (Xara Group Ltd) <camelotdev@xara.com>
00286     Created:    25/6/93
00287     Purpose:    This class represents a range of sibling nodes with a specified selected
00288                 status. The range is specified by supplying a First and Last node (where
00289                 Last must be a right sibling of First), and range control flags 
00290                 which specify which nodes from First to Last inclusive, are to be
00291                 included in the range. There are two range control flags, Selected
00292                 and Unselected. When Selected is TRUE all selected nodes are included in the 
00293                 range, when Unselected is TRUE all unselected nodes are included in the range, 
00294                 and when both flags are TRUE all nodes from First to Last are included. 
00295                 
00296                 As an example consider the following sibling node list in a document tree 
00297                 (where (S) indicates that the node has selected status). 
00298                 
00299                 N1(S)->N2->N3(S)->N4->N5->N6(S)               
00300                 
00301                 If First = N1, Last = N6, RangeControl.Selected = TRUE, and 
00302                 RangeControl.Unselected = FALSE, then nodes N1, N3 and N6 will be included 
00303                 in the range.
00304                 
00305                 The new CrossLayer flag enables the range to cross from one layer to the
00306                 next in the tree. This only works if the range exists at the level which
00307                 the user can directly edit - i.e. in the sibling lsist of layers.
00308                 
00309 ********************************************************************************************/
00310 class CommonAttrSet;
00311 class Range: public CCObject
00312 {  
00313 public: 
00314     CC_DECLARE_DYNAMIC( Range )  
00315     Range();                                   // Creates a NULL range 
00316     virtual ~Range();
00317 
00318     Range(Node*First, Node*Last, RangeControl RangeControlFlgs);    
00319     Range(Range& Range);    
00320     Range& operator=(Range& Range);     
00321     BOOL operator==(const Range&) const;
00322     BOOL operator!=(const Range&) const;
00323 
00324     void SetRangeControl(RangeControl RangeControlFlgs); 
00325     virtual Node* FindFirst(BOOL AndChildren = FALSE);
00326     virtual Node* FindLast();
00327     virtual Node* FindNext(Node* Previous, BOOL AndChildren = FALSE);
00328     virtual Node* FindPrev(Node* pNode, BOOL AndChildren = FALSE);
00329     virtual void  Update(BOOL TellWorld = FALSE);
00330     virtual void  FreshenCache() {};
00331 
00332     RangeControl GetRangeControlFlags() const { return RangeControlFlags; }
00333 
00334     BOOL ForceRenderEORAll() const { return TRUE; }
00335 
00336     UINT32 Count();
00337     BOOL Contains(Node* pNode, BOOL bAndChildren = FALSE);
00338     BOOL ContainsSelectInside();
00339 
00340     BOOL ConsistsOf(CCRuntimeClass* pccrtSearch, BOOL fIncludeDerivedClasses=TRUE);
00341     BOOL IsEmpty();
00342 
00343     List* MakeListOfNodes(BOOL AndChildren = FALSE);
00344 
00345     void UpdateParentBoundsOfSelection(BOOL AndChildren = FALSE);
00346     BOOL MakeAttributeComplete( BOOL CheckForDuplicates = TRUE, 
00347                                 BOOL AndChildren = FALSE,
00348                                 BOOL IgnoreComplex = FALSE);
00349     void NormaliseAttributes(BOOL AndChildren = FALSE,
00350                              BOOL IgnoreComplex = FALSE);
00351 
00352     BOOL CopyComponentDataToDoc(BaseDocument* pSrcDoc,
00353                                 BaseDocument* pDestDoc,
00354                                 BOOL AndChildren = FALSE);
00355     
00356     // Helpful functions to XOR-redraw the selection, given a matrix by which 
00357     // objects are to be transformed (used by scale, rotate, selector, etc
00358     // tools as shared drag-redraw code).
00359     // See selector and rotate tools for examples of use
00360 
00361     void    ResetXOROutlineRenderer(BOOL FlushTheCache = TRUE);
00362 
00363     void    RenderXOROutlinesOn(DocRect *ClipRect, Spread *pSpread,
00364                                 Matrix *Transform, Node *ClickedObject = NULL);
00365     void    RenderXOROutlinesOff(DocRect *ClipRect, Spread *pSpread, Matrix *Transform);
00366 
00367     void    RenderXOROutlinesToCatchUp(DocRect *ClipRect, Spread *pSpread, Matrix *Transform);
00368 
00369     Node    *NodeToRender;                  // The node that we are up to
00370                                             // (for rendering more significant objects first)
00371     
00372     virtual DocRect GetBoundingRect();
00373 
00374     // DMc gets the bounding rect to render when eor dragging
00375     virtual DocRect GetBoundingRectForEorDragging();
00376 
00377     // Func to call AllowOp() on all nodes in the range.
00378     virtual BOOL AllowOp(ObjChangeParam* pParam,BOOL SetOpPermissionState = TRUE,
00379                                                 BOOL DoPreTriggerEdit = TRUE);
00380 
00381     // This function returns a set of the compound parent nodes of every item in the range 
00382     BOOL GetCompoundObjectSet(ObjectSet* pCompoundObjectSet, BOOL ExcludeTextObjects = FALSE); 
00383     // This fn is for BODGE purposes
00384     BOOL AddTextStoryCompoundsForDel(ObjectSet* pCompoundObjectSet);
00385 
00386     // CommonAttribResult is returned by Range::FindCommonAttribute()
00387     enum CommonAttribResult { ATTR_COMMON, ATTR_NONE, ATTR_MANY };
00388 
00389     // For finding a common attributes in the range. 
00390     Range::CommonAttribResult FindCommonAttribute(CCRuntimeClass* AttribClass, 
00391                                                   NodeAttribute** pAttribute,
00392                                                   BOOL bRangeIsEffectsLevel = FALSE);
00393 
00394     BOOL FindCommonAttributes(CommonAttrSet* CommonAttributeSet, BOOL CompoundAccuracy = FALSE);
00395 
00396     Range::CommonAttribResult FindCommonAttributeType(CCRuntimeClass* AttribType, 
00397                                                             CCRuntimeClass** pCommonType,
00398                                                             BOOL ForceAttribType = FALSE,
00399                                                                BOOL bRangeIsEffectsLevel = FALSE);
00400 
00401     Range::CommonAttribResult FindCommonNonOptimisingAttr(  CCRuntimeClass* pAttribClass,
00402                                                             NodeAttribute** ppAttr );
00403 
00404     // Find a bitmap in this range
00405     BOOL FindBitmap(KernelBitmap** ppFoundBitmap = NULL,
00406                     KernelBitmapRef** ppFoundBitmapRef = NULL,
00407                     NodeBitmap** ppFoundNode = NULL,
00408                     AttrFillGeometry** ppFoundFillAttribute = NULL);
00409 
00410     // This function gets called to inform the range that attributes applied to objects in 
00411     // the range have changed. It deletes the CommonAttrCache if one exists.
00412     virtual void AttrsHaveChanged(); 
00413          
00414     virtual void SetRenderable(BOOL bNewVis = FALSE);
00415     virtual Range* CloneNodes(UINT32 timeLimit, BOOL bCloneOnTop = FALSE, BOOL bLightweight = FALSE, Layer* pDestLayer = NULL);
00416     virtual void DeleteNodes();
00417     virtual void ForceRedrawView(DocView* pDocView, BOOL bReleaseCache = FALSE, BOOL bUseBlobRects = FALSE, BOOL bReleaseParentsOnly = FALSE);
00418     virtual BOOL TransformNodes(TransformBase* Trans);
00419     virtual void SetDraggedNodes(BOOL bNewState = FALSE);
00420     virtual void CopyNodesContents(Range* pDestRange, BOOL bSetDragged = FALSE, BOOL bSetRenderable = FALSE);
00421 
00422     virtual BOOL SetPromoteToParent(BOOL bNewValue) {BOOL b = RangeControlFlags.PromoteToParent; RangeControlFlags.PromoteToParent = bNewValue; return b;}
00423 
00424 protected:
00425     // This fn will return a pointer to the common attribute cache. If it does not exist then
00426     // one will be created
00427     CommonAttrSet* GetCommonAttrCache(); 
00428 
00429     // The common attribute cache. This list will only ever exist
00430     // if the FindCommonAttribute, or FindCommonAttributes functions
00431     // are called on the range. The list contains CommonAttributeItems. 
00432     CommonAttrSet* pCommonAttribCache; 
00433 
00434 
00435     BOOL    FindNextXOROutlineNode(Node **OriginalNode, DocRect *pClipRect);
00436     BOOL    CacheXOROutlineInfo(Spread *pSpread, Node *ClickedObject = NULL);
00437 
00438 protected:  
00439     RangeControl RangeControlFlags; 
00440 
00441     Node* FirstNode; 
00442     Node* LastNode; 
00443 
00444     virtual Node* SmartFindNext(Node* pContext, BOOL AndChildren = FALSE, BOOL FindFirst = FALSE) const;
00445     virtual BOOL InRange(Node* pNode, BOOL AndChildren) const;
00446     
00447     INT32   NumObjectsDrawn;                // A count of the number of objects rendered so far
00448     INT32       RenderingPass;                  // Which pass the rendering is up to
00449 
00450     // Cache of information for XOROutline renderer functions...
00451     XOROutlineInfoStr XORInfo;              // (See above for defn of this struct)
00452 
00453 };
00454 
00455 
00456 
00457 
00458 /********************************************************************************************
00459 
00460 >   class NodeListItem : public ListItem
00461 
00462     Author:     Jim_Lynn (Xara Group Ltd) <camelotdev@xara.com>
00463     Created:    22/7/94
00464     Purpose:    Stores a pointer to a Node. Used to build a list of nodes in the current range.
00465                 The actual node can be accessed through the public member variable pNode.
00466     SeeAlso:    Range::MakeListOfNodes
00467 
00468 ********************************************************************************************/
00469 
00470 class NodeListItem : public ListItem
00471 {
00472 public:
00473     CC_DECLARE_DYNAMIC( NodeListItem )
00474     NodeListItem();                 // will contain a NULL pointer
00475     NodeListItem(Node* WhichNode);  // initialise pNode to be WhichNode
00476     ~NodeListItem() {}              // Nothing to destruct
00477     
00478     Node* pNode;                    // pointer to a node
00479 };
00480 
00481 
00482 
00483 
00484 /********************************************************************************************
00485 
00486 >   class SelRangeMessageHandler : public MessageHandler
00487 
00488     Author:     Jason_Williams (Xara Group Ltd) <camelotdev@xara.com>
00489     Created:    07/04/94
00490     Purpose:    Intercepts messages for the SelRange.
00491                 (Basically sits there and flushes the Selection's information cache
00492                 whenever it thinks the selection cache has become invalid)
00493                 
00494 ********************************************************************************************/
00495 
00496 class SelRangeMessageHandler : public MessageHandler
00497 {
00498 public:
00499     CC_DECLARE_DYNAMIC( SelRangeMessageHandler ) 
00500     SelRangeMessageHandler();               // Constructor
00501 
00502 protected:
00503     MsgResult Message(Msg* Msg);            // Overridden message reciever
00504 };
00505 
00506 
00507 
00508 
00509 /********************************************************************************************
00510 
00511 >   class SelRange : public Range
00512 
00513     Author:     Phil_Martin (Xara Group Ltd) <camelotdev@xara.com> & Jason
00514     Created:    28/11/94 (Date this comment added!!! Actually written long before this)
00515     Purpose:    This class represents a range of selected nodes directly under the
00516                 Selection Surface.
00517                 The Selection Surface is the highest surface in the tree at which the user
00518                 can select nodes. It is usually the child list of Layers but the user can
00519                 push the Selection Surface lower, into groups, using Select Inside.
00520 
00521                 The SelRange also offers a set of cached information pertinent to
00522                 the selection, such as the bounds, number of objects included, etc.
00523                 This cache generally makes access to such information much more efficient
00524                 than a brute force treesearch.
00525 
00526 ********************************************************************************************/
00527 
00528 class SelRange: public Range
00529 {
00530     CC_DECLARE_DYNAMIC( SelRange )  
00531     friend class SelRangeMessageHandler; 
00532 
00533 public:
00534     SelRange();
00535     ~SelRange();
00536     
00537     // DMc
00538     SelRange(SelRange &From);
00539 
00540     static BOOL DeclarePrefs();
00541     void FreshenCache();
00542 
00543 // New functions specifically for the selection range object...
00544     virtual void Update(BOOL TellWorld = FALSE, Node *SelectedNode = NULL);
00545                     // Inform a SelRange object that the selection has changed (FLUSHES the cache)
00546 
00547     void UpdateBounds(); // This fn get's called when the range's bounds have been changed
00548 
00549     virtual void BroadcastAnyPendingMessages(void);
00550                     // Ensures that any pending SelChangingMsg broadcasts are sent
00551 
00552     virtual void AttrsHaveChanged(); // This function gets called whenever attributes are applied to the 
00553                                     // range. It invalidates the common attribute cache.
00554 
00555 private:
00556     void FreshenBoundsCache();
00557 
00558 
00559 public:
00560     virtual DocRect GetBoundingRect(BOOL bPromoteToControllers = FALSE);        // Get bounds of the entire selection
00561     DocRect GetBlobBoundingRect();          // Get bounds, including selection blobs
00562     virtual DocRect GetBoundsWithoutAttrs(void);    // Get bounds excluding line widths and other attrs
00563 #ifdef SELECTION_AREA_FEATURE
00564     virtual BOOL GetAreaDetails(XLONG* pxlArea, XLONG* pxlPerim);
00565     virtual BOOL GetAreaDetailsWhileIdle(XLONG* pxlArea, XLONG* pxlPerim);
00566 #endif
00567 
00568     Node*   FindLast();                     // Find the last item in the range
00569 
00570 // Overridden functions inherited from Range...
00571     void    SetRangeControl(RangeControl RangeControlFlgs); 
00572     Node*   FindFirst(BOOL AndChildren = FALSE);                // Find first object in the selection
00573     Node*   FindNext(Node* Previous, BOOL AndChildren = FALSE); // Find the next object in the selection
00574     UINT32  Count();                                            // How many primary objects are in the selection
00575 
00576     // Find a node in the selection of a given type (returns TRUE if found)
00577     BOOL  FindObject(CCRuntimeClass* p, Node** pOutput = NULL);
00578     Node* FindFirstObject(CCRuntimeClass* p);
00579     Node* FindNextObject(CCRuntimeClass* p, Node* Previous);
00580     Node* FindFirstDerivedObject(CCRuntimeClass* p);
00581     Node* FindNextDerivedObject(CCRuntimeClass* p, Node* Previous);
00582 
00583 public:
00584     String_256 Describe(DescriptionFormat Format);
00585 
00586        
00587 private:
00588     String_256 LayerDescription(DescriptionFormat Format);
00589     String_64 ObjectDescription(DescriptionFormat Format);
00590 
00591     void SelChangedCommit(); 
00592 
00593 public:
00594     // This function gets called at the end of each operation, and other places where the selection
00595     // may have changed, it should not get called in response to Selection changed messages because
00596     // it is quite slow.
00597     void    DescribeSelectionInStatusBar(); 
00598 
00599     // A general fn to convert a singular to a plural (for English at least)
00600     static  String_256 Pluralise(String_256 Noun);
00601 
00602 
00603     BOOL    IsCached()  { return Cached; }
00604 
00605 
00606     // Determine the last node that the SelRange can remember having been selected.
00607     // This is only a short-term memory - it may well return NULL
00608     Node *GetLastSelectedNode(void);
00609 
00610     // Ensure that the given node is not cached in our 'pLastSelectednode' member variable,
00611     // as it is being destructed, so it is no longer safe to keep this pointer
00612     // Called by Node::~Node() - shouldn't really be called by anyone else
00613     inline void ClearLastSelectedNodeIfItIs(Node *TheNodeToCheck);
00614 
00615     void SetGag(BOOL NewState);
00616     BOOL IsSelRangeGagged();
00617 
00618     BOOL MakePartialSelectionWhole(BOOL TellWorld = TRUE, BOOL bTextOnly = FALSE, BOOL bPathInText = FALSE);
00619 
00620     EffectsStack*   GetEffectsStack(BOOL bGetCopy = FALSE, BOOL bEscapeDerived = TRUE);
00621     ListRange*      GetTopClassRange(CCRuntimeClass* pClass, BOOL bClassOnly = TRUE, BOOL bIgnorePassThroughEffects = FALSE, Node** ppMasterNode = NULL, INT32* piStackPos = NULL);
00622 
00623 private:
00624     Document *ScopeDocument;                // Points at the document we have cached this
00625                                             // information for.
00626 
00627     BOOL    Cached;                         // TRUE when Range is directly usable.
00628                                             // FALSE when the tree has to be scanned
00629 
00630     BOOL    InformedSelChanged;             // Has the sel changed message been broadcast
00631 
00632     BOOL    IsGagged;                       // Is the SelRange gagged from sending
00633                                             //  SelChanged messages
00634 
00635     BOOL    CachedBounds;                   // Set to FALSE in UpdateBounds function
00636                                             // used to indicate when the bounds of the 
00637                                             // selection are/are not cached
00638 
00639     DocRect CachedBBox;                     // Cache for the bounding box of the selection
00640                                             // Only valid when (Cached==TRUE && CachedCount>0)
00641 
00642     DocRect CachedBlobBBox;                 // As above, but includes selection blobs
00643                                             // Only valid when (Cached==TRUE && CachedCount>0)
00644 
00645     BOOL    CachedBoundsNoAttrs;            // BBox cache for non-attribute bounds, and
00646     DocRect CachedBBoxNoAttrs;              // its associated cached/not-cached flag
00647 
00648     INT32   CachedCount;                    //  >0 : Cached number of objects in range
00649                                             //       This value is INVALID if Cached == FALSE
00650                                             // ==0 : Number of objects unknown (uncached)
00651                                             //       or number of objects is 0 (See Cached flag)
00652                                             //  <0 : Contains count of number of objects
00653                                             //       so far encountered during a FindNext()
00654                                             //       range scan. At the end of such a scan,
00655                                             //       the correct count will have been cached,
00656                                             //       so long as the search was sequential.
00657                                             // Thus MUST be accessed through Count() function
00658 
00659     Node    *pLastSelectedNode;             // NULL, or points at the last node which was made
00660                                             // selected (usually the last object user clicked)
00661 
00662     Document *pLastSelectedDoc;             // The document (if any) in which the
00663                                             // LastSelectedNode resides.
00664 
00665     Node    *LastFindNextNode;              // Memory of last 'Previous' node passed to
00666                                             // FindNext - used to cache a count if possible
00667                                             // during a FindNext scan of the tree.
00668 
00669     SelRangeMessageHandler* MessageHandler; // Object to intercept messages and flush our cache
00670                                             // if the selection has been changed
00671 
00672     EffectsStack*   m_pEffectsStack;        // Cached effect stack
00673 
00674     ListRange*      m_pEffectClassRange;    // Cached effect level (may not match a level in the effect stack)
00675                                             // This is stored in SelRange context so that it shares
00676                                             // the valid lifetime of SelRange and can be re-used by callers
00677                                             // instead of having to be rebuilt whenever it's needed
00678     BOOL            m_bEffectClassNodesOnly;// Record state of bClass flag along with m_pEffectClassRange
00679                                             // so that m_pEffectClassRange is only re-used when bClass is the same
00680 
00681     Node*               m_pAreaNode;        // Current context of idle area computer
00682 };
00683 
00684 
00685 
00686 /******************************************************************************************
00687 
00688 >   inline void SelRange::ClearLastSelectedNodeIfItIs(Node *TheNodeToCheck)
00689 
00690      Author:    Jason_Williams (Xara Group Ltd) <camelotdev@xara.com>
00691      Created:   4/1/95
00692 
00693      Inputs:    TheNodeToCheck - A pointer to a node being destructed.
00694 
00695      Purpose:   Ensures that the SelRange does not retain a pointer to a node
00696                 (in pLastSelectedNode) which has been destructed.
00697                 Called by Node::~Node() - not to be called by anyone else
00698 
00699      SeeAlso:   SelRange::GetLastSelectedNode; Node::~Node
00700 
00701 ******************************************************************************************/
00702 
00703 inline void SelRange::ClearLastSelectedNodeIfItIs(Node *TheNodeToCheck)
00704 {
00705     if (TheNodeToCheck == pLastSelectedNode)
00706         pLastSelectedNode = NULL;
00707 }
00708 
00709 
00710 
00711 /********************************************************************************************
00712 
00713 >   class CommonAttrSet: public List
00714 
00715     Author:     Simon_Maneggio (Xara Group Ltd) <camelotdev@xara.com>
00716     Created:    13/9/95
00717     Purpose:    A CommonAttributeSet. See Range::FindCommonAttributes 
00718     SeeAlso:    Range::FindCommonAttributes
00719     SeeAlso:    CommonAttributeItem
00720 
00721 ********************************************************************************************/
00722 class NodeRenderableInk;
00723 class CommonAttrSet: public List
00724 {
00725 public:
00726     CommonAttrSet() { };                        // Constructs an empty set
00727     virtual ~CommonAttrSet() { DeleteAll(); };  // Delete all items in the set before we leave
00728     
00729     // Methods for setting up the CommonAttrSet prior to a call to FindCommonAttributes
00730     BOOL AddTypeToSet(CCRuntimeClass* AttrType);
00731     BOOL AddAllTypesToSet();
00732 
00733     // Methods for accessing the CommonAttrSet 
00734     CommonAttributeItem* FindAttrItem(CCRuntimeClass* AttrType);
00735     BOOL FindAttrDetails(CCRuntimeClass* AttrType, 
00736                       NodeAttribute** pAttr, 
00737                       Range::CommonAttribResult* Status);
00738 
00739     BOOL IsAnyItemCommon(); 
00740     void ClearResults();
00741 
00742     INT32 UpdateKnownValues(CommonAttrSet* pCache);
00743     
00744     enum ObjectAttrUsage { REQUIRED,             // The attribute is required by at least one child object
00745                                                  // but does not appear as a child. => Default attr is 
00746                                                  // common
00747                            FOUND,                // The attribute is required by at least one child object
00748                                                  // and has been found as a child. => Default attr is not common 
00749                            NOT_REQUIRED };       // Attribute is not required by any child.
00750 
00751     // Special fn used by FindCommonAttributes to determine if a default attribute is common to a compound
00752     // object.                      
00753     BOOL BuildAttrDetailsMap(NodeRenderableInk* CompoundObject, 
00754                              INT32 FirstN,
00755                              CCAttrMap* pAppliedAttrMap, 
00756                              CMapPtrToWord* pCompoundAttrMap); // Maps an attribute type to an ObjectAttrUsage value
00757 };
00758 
00759 
00760 
00761 
00762 /********************************************************************************************
00763 
00764 >   class ListRange : public Range
00765 
00766     Author:     Phil_Martin (Xara Group Ltd) <camelotdev@xara.com>
00767     Created:    11/12/2003
00768     Purpose:    This class represents a list of explicitly declared nodes (rather than
00769                 the implicitly chosen nodes controlled by RangeControl flags).
00770 
00771 ********************************************************************************************/
00772 
00773 class ListRange: public Range
00774 {
00775     CC_DECLARE_DYNAMIC(ListRange)
00776 
00777 public:
00778     ListRange();
00779     ListRange(const List& srcList);
00780     ListRange(const ListRange& srcRange);
00781     ListRange(const ListRange* pSrcRange);
00782     ~ListRange();
00783 
00784     virtual Node* FindFirst(BOOL AndChildren = FALSE);
00785     virtual Node* FindLast();
00786     virtual Node* FindNext(Node* Previous, BOOL AndChildren = FALSE);
00787     virtual Node* FindPrev(Node* pNode, BOOL AndChildren = FALSE);
00788 
00789     virtual void AddNode(Node* pNode);
00790     virtual Node* RemoveNode(Node* pNode);
00791     virtual void Clear();
00792     virtual BOOL MatchesSelectionEffectLevel(INT32 iStackPos);
00793 
00794 protected:  
00795     virtual BOOL InRange(Node* pNode, BOOL AndChildren) const;
00796     
00797 private:
00798     List nodelist;
00799     NodeListItem*   pLastReturnedItem;
00800     
00801 };
00802 
00803 
00804 
00805 
00806 #endif
00807 

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