ink.h

Go to the documentation of this file.
00001 // $Id: ink.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 // class NodeRenderableInk
00100 
00101 #ifndef INC_INK
00102 #define INC_INK
00103 
00104 #include "node.h"
00105 #include "clikmods.h"
00106 #include "binds.h"
00107 #include "bitmap.h"
00108 
00109 class Spread;
00110 class RenderRegion;
00111 class BaseDocument;
00112 class Cursor;
00113 class ContextMenu;
00114 class CCAttrMap;
00115 class BlendNodeParam;
00116 class AttrFillGeometry;
00117 class AttrBrushType;
00118 class AttrStrokeType;
00119 
00120 /***********************************************************************************************
00121 
00122 >    Class NodeRenderableInk: public NodeRenderableBounded
00123 
00124      Author:       Simon_Maneggio (Xara Group Ltd) <camelotdev@xara.com>
00125      Created:      19/5/93
00126      Base Classes: NodeRenderable, Node, CCObject
00127      Purpose:      This abstract class describes a renderable ink node. A property of Ink nodes 
00128                    is that they should be rendered after their children have been rendered.   
00129                       
00130                    See the Node class for an important note about producing derived 
00131                    classes of Node.  
00132 
00133      SeeAlso:      NodeRenderable
00134      Errors:       -                   
00135                 
00136 ***********************************************************************************************/
00137 
00138 
00139 class NodeRenderableInk: public NodeRenderableBounded
00140 {
00141     CC_DECLARE_DYNAMIC( NodeRenderableInk ) 
00142 
00143 public:
00144 
00145     static BOOL Init();
00146 
00147     NodeRenderableInk(); 
00148 
00149     NodeRenderableInk(Node* ContextNode,  
00150                       AttachNodeDirection Direction,    
00151                       BOOL Locked=FALSE, 
00152                       BOOL Mangled=FALSE,  
00153                       BOOL Marked=FALSE, 
00154                       BOOL Selected=FALSE);
00155 
00156     virtual BOOL IsAnObject() const;        // yes, this is an object
00157     virtual BOOL IsSetCandidate() const;    // yes, this is a candidate for set membership
00158     virtual BOOL IsRenderedAsInk() const {return TRUE;}
00159 
00160     // virtual Functions to deal with bounding boxes
00161     //virtual void UpdateInkBoundingRect();
00162 
00163     virtual BOOL CanTransform();
00164 
00165     // Custom export rendering code.
00166     virtual BOOL ExportRender ( RenderRegion *pRender );
00167 
00168     // Virtual Selection functions
00169 //  virtual void RenderFillBlobs(RenderRegion* pRender);
00170     virtual void RenderAppliedFillBlobs(RenderRegion* pRender);
00171     virtual void RenderArtisticBlobs(RenderRegion* pRender);
00172     virtual void RenderEorDrag( RenderRegion* );
00173     virtual void RenderEffectBlobs(RenderRegion* pRender);
00174 
00175     // fn which recursively eor renders all the children of this node
00176     virtual void RenderEorDragChildren(RenderRegion * pRender);
00177 
00178     // DMc - whether the eor drag for all children is dealt with by this node,
00179     virtual BOOL ChildrenAreEorDragRenderedByMe() { return FALSE; }
00180 
00181     virtual void ClearSubSelection( BOOL ReDraw );
00182     virtual BOOL CanSelectAsCompoundParent();
00183     virtual BOOL CanSelectAsSimple();
00184     
00185     // Functions for responding to clicks etc
00186     virtual BOOL OnClick(DocCoord, ClickType, ClickModifiers, Spread*);
00187     virtual BOOL OnMouseMove(const DocCoord&, Spread*, ClickModifiers);
00188     virtual BOOL GetStatusInfo(String_256** ppStatusText, Cursor** ppStatusCursor);
00189     virtual BOOL OnBlobPopUp(Spread*, DocCoord, ContextMenu*);
00190     virtual BOOL OnNodePopUp(Spread*, DocCoord, ContextMenu*);
00191 
00192     // Other virtual functions
00193 
00194     // These stand for things you can do to the selection in SelectAllInRect.
00195     enum SelStateAction { CLEAR, SET, TOGGLE };
00196 
00197     // Selection methods
00198     static void DeselectAll(BOOL RenderBlobs = TRUE, BOOL InformImmediate = TRUE);
00199     virtual void SelectInRect(const DocRect& Rect, SelStateAction st);
00200 
00201     // This could be a method of layer but I think it's best to keep it with DeselectAll()
00202     static void DeselectAllOnLayer(Layer* Layer);
00203     static void SelectAllInRect( DocRect, Spread*, SelStateAction st = SET );
00204 
00205     // Invalidates the bounding rectangle of the node 
00206     void RedrawObject(); 
00207 
00208     //Attribute methods 
00209     void ApplyAttributeToObject(NodeAttribute* Attribute, BOOL Redraw);
00210     BOOL ApplyAttributes(CCAttrMap* pAttribMap,BOOL RequiredAttrsOnly = FALSE); // Note: Also normalises the attrs after application
00211 
00212     // Used to determine if the node requires an AttribClass attribute to render itself
00213     virtual BOOL RequiresAttrib(CCRuntimeClass* AttribClass, BOOL Search = FALSE);
00214     // This function is more accurate than the above, some nodes require only specific instances of a 
00215     // class.
00216     virtual BOOL RequiresAttrib(NodeAttribute* pAttrib, BOOL Search = FALSE);
00217     // This fn is not to be confused with RequiresAttrib it determines if an attribute of type 
00218     // AttrType can be directly applied to the object.
00219     virtual BOOL CanAttrBeAppliedToMe(CCRuntimeClass* AttrType);
00220     // Before applying an attribute to an object this function should be called to return
00221     // the actual object the attribute should be applied to.
00222     virtual NodeRenderableInk* GetObjectToApplyTo(CCRuntimeClass* AttrType);
00223     // Every Ink object has an associated current attribute group, If an attribute is applied to
00224     // the object, and it needs to become current then the attribute group specified will get updated.
00225     virtual CCRuntimeClass* GetCurrentAttribGroup(); 
00226 
00227     NodeAttribute* GetChildAttrOfType(CCRuntimeClass* ReqdAttrib);
00228     BOOL HasAttrTypesOn(NodeRenderableInk* Object);
00229     
00230     BOOL CopyChildrenAsShapes(Node* pDestin);
00231         
00232     // Version 2 file format functions
00233     virtual BOOL ReadPostChildrenWeb(BaseCamelotFilter* pFilter);
00234     virtual BOOL ReadPostChildrenNative(BaseCamelotFilter* pFilter);
00235 
00236     virtual BOOL WriteBeginChildRecordsWeb(BaseCamelotFilter* pFilter);
00237     virtual BOOL WriteBeginChildRecordsNative(BaseCamelotFilter* pFilter);
00238     virtual BOOL WriteEndChildRecordsWeb(BaseCamelotFilter* pFilter);
00239     virtual BOOL WriteEndChildRecordsNative(BaseCamelotFilter* pFilter);
00240 
00241     virtual BOOL WriteBoundsRecord(BaseCamelotFilter* pFilter);
00242     virtual BOOL WillWriteBounds(BaseCamelotFilter* pFilter);
00243 
00244     // Progressive rendering & the new file format
00245     virtual BOOL AreYouSafeToRender();
00246 
00247     // Find the first/next attribute from this object of the given run-time class (NB. not AttributeType),
00248     // or null if there isn't one.
00249 
00250     // return the applied brush attribute
00251     AttrBrushType* GetAppliedBrushAttribute();
00252 
00253     AttrStrokeType* GetActiveStroke();
00254         // check to see if we have a variable width stroke applied to us, and get the real path
00255     virtual NodePath* GetVariableWidthStrokePath();
00256     virtual NodePath* GetSmoothVariableWidthStrokePath();
00257 
00258     virtual BOOL GetAreaDetails(XLONG* pxlArea, XLONG* pXLPerimeter) {return FALSE;}
00259 
00260     virtual BOOL CanSupplyDirectBitmap() {return FALSE;}
00261     virtual BOOL GetDirectBitmap(RenderRegion* pRender, LPBITMAPINFO* plpInfo, LPBYTE* plpBits, DocRect* pRect, Matrix* pMat, double* pdRes) {return FALSE;}
00262     virtual BOOL RenderDirectBitmapState(RenderRegion* pRender) {return FALSE;}
00263 
00264 private:
00265     BOOL    SafeToRender;
00266 
00267 protected:
00268     // Function to help calculate the bounding rects of objects that contain a path
00269     BOOL CalculatePathBoundingRect(Path& BoundPath, BOOL DontUseAttrs, DocRect* pRect);
00270 
00271     virtual Node* SimpleCopy(void);
00272     
00274 //  Hit-testing data and functions.
00275 
00276 public:
00277     
00278     // perform simple hit-testing
00279     static NodeRenderableInk* FindSimpleAtPoint(Spread* pSpread, 
00280                                                 DocCoord dcPoint, 
00281                                                 Node* pHighNode = NULL,
00282                                                 Node** ppInterruptNode = NULL);
00283     // read the documents screen-colour at the supplied hit-test position
00284     static NodeRenderableInk* FindSimpleAtPointForColourPicker(Spread* pSpread, 
00285                                                                DocCoord dcPoint,
00286                                                                Pixel32bpp& Pix,
00287                                                                Node* pHighNode = NULL,
00288                                                                Node** ppInterruptNode = NULL);
00289     // read the documents screen-colour at the supplied hit-test position (but only for the
00290     // supplied node)
00291     static NodeRenderableInk* FindColourForNodeRenderableAtPoint (Spread* pSpread,
00292                                                                   DocCoord dcPoint,
00293                                                                   Pixel32bpp& Pix,
00294                                                                   Node* pThisNode,
00295                                                                   AttrFillGeometry* pThisFill);
00296     // perform compound hit testing
00297     static NodeRenderableInk* FindCompoundAtPoint(Spread* pSpread, DocCoord dcPoint, Node* pHighNode = NULL);
00298     
00299     // This finds a compound object, eg. a group, that contains the given simple object.
00300     static NodeRenderableInk* FindCompoundFromSimple(NodeRenderableInk* pSimpleNode,
00301                                                      Node* pSiblingNode = NULL);
00302 
00303     // This finds a group including then given node, or NULL if it isn't in a group.
00304 //  static NodeRenderableInk* FindHigherGroup(NodeRenderableInk* pStartNode);
00305     static NodeRenderableInk* FindInnerCompound(Node* pLowNode, Node* pHighNode);
00306 
00307     // Find which attributes are applied to a node...
00308     // ExcludeIndirectlyAppliedGLAs added by Ilan (17/5)
00309     BOOL FindAppliedAttributes(CCAttrMap* pAttribMap,
00310                                 INT32 nMax = 5000,
00311                                 INT32* nFound = NULL,
00312                                 BOOL ExcludeIndirectlyAppliedGLAs = FALSE,
00313                                 BOOL bStrictEffectStatus = TRUE) const;
00314 
00315     BOOL FindAppliedAttribute(CCRuntimeClass* AttribType, NodeAttribute** pAttrFound, BOOL bStrict = TRUE);
00316     NodeAttribute* FindAppliedAttribute(CCRuntimeClass* AttribType, BOOL bExcludeChildAttrs = FALSE, BOOL bStrict = TRUE);
00317 
00318 //  virtual BOOL IsValidEffectAttr(CCRuntimeClass* pAttrClass) const {return FALSE;}
00319     virtual BOOL IsValidEffectAttr(NodeAttribute* pAttr) const {return FALSE;}
00320 
00321     // This function deletes all child attributes from the node which have the same type and value 
00322     // as the parent/sibling applied attributes.
00323     void DeleteAppliedAttributes(); 
00324 
00326     // the object. 
00327     BOOL AddChildAttrTypesToSet(AttrTypeSet* pAttrTypeSet); 
00328 
00329 
00330     // This helper function allows the static attribute map, compiled during hit-testing,
00331     // to be reset...
00332     static void ClearAttribMap();
00333 
00334     // Allow nodes to modify the results of FindSimpleAtPoint
00335     virtual NodeRenderableInk* FindNodeAtPointHelper(const Spread* pSpread, const DocCoord dcPoint) {return this;}
00336 
00337 private:
00338 
00339     // These are private data and functions used by the hit-testing code.
00340     static BOOL bUseSmartClicks;
00341     static BOOL AverageHitColour;
00342 
00343     static CCAttrMap* pAttribMap;       // the attribute look-up table
00344     static INT32 nFoundAttributes;          // how many entries currently in the table
00345     static INT32 nMaxAttributes;                // the most number of entries in the table
00346 
00347     void RenderAppliedAttributes(RenderRegion* pRegion) const;
00348     void RenderAppliedClipAttributes(RenderRegion* pRender) const;
00349 
00350     static Node* FindFirstHitTest(Spread* pStartSpread,
00351                                   const DocRect& drClickRect,
00352                                   CCAttrMap* pAttribMap,
00353                                   BOOL bExcludeLayers,
00354                                   Node* pHighNode = NULL );
00355 
00356     static Node* FindNextHitTest(Node* pNode,
00357                                  const DocRect& drClickRect,
00358                                  CCAttrMap* pAttribMap,
00359                                  BOOL bExcludeLayers,
00360                                  BOOL bSkipChildren = FALSE);
00361     
00362     static BOOL HitTestChildren(Node* pNode,
00363                                 const DocRect& drClickRect,
00364                                 BOOL bExcludeLayers);
00365          
00366 
00368 // Attribute optimisation routines
00369 
00370 public:
00371 
00372     BOOL MakeAttributeComplete(Node* Root = NULL, 
00373                                 BOOL CheckForDuplicates = TRUE,     
00374                                 AttrTypeSet* pAffectedAttrTypes = NULL, 
00375                                 BOOL IncludeDefaults = FALSE,
00376                                 BOOL bIncludeEffectAttrs = FALSE);
00377 
00378     void NormaliseAttributes();   // Removes superfluous attributes
00379 
00380     BOOL FactorOutCommonChildAttributes(BOOL Global = FALSE, 
00381                                         AttrTypeSet* pAffectedAttrTypes = NULL);
00382 
00383     BOOL LocaliseCommonAttributes(BOOL CheckForDuplicates = FALSE, 
00384                                   BOOL Global = FALSE, 
00385                                   AttrTypeSet* pAffectedAttrTypes = NULL,
00386                                   BOOL RecursiveDownwards = FALSE);
00387 
00388 public:
00389     // these two are used to tell compound nodes (or anyone else for that matter)
00390     // that the blend step is beginning
00391     // tells nodes that the blend step is beginning
00392     virtual BOOL BeginBlendStep(BlendNodeParam * pParam) { return TRUE; }
00393 
00394     // tells nodes that the blend step has finished
00395     virtual BOOL EndBlendStep(BlendNodeParam * pParam) { return TRUE; }
00396 
00397 private:
00398     BOOL FactorOutCommonChildAttrHelper(BOOL Global, 
00399                                               AttrTypeSet* pAffectedAttrTypes);
00400 
00401     BOOL LocaliseCommonAttrHelper(BOOL CheckForDuplicates, 
00402                                   BOOL Global, 
00403                                   AttrTypeSet* pAffectedAttrTypes,
00404                                   BOOL RecursiveDownwards = FALSE);
00405                                 
00406 
00407     void DeleteLocalisedAttributes(BOOL Global = FALSE,
00408                                    AttrTypeSet* pAffectedAttrTypes = NULL);
00409 
00410     void DeleteFactoredOutAttribs(BOOL Global = FALSE,
00411                                   AttrTypeSet* pAffectedAttrTypes = NULL);
00412 
00413         /*
00414     // The following are sub-functions of MakeAttributeComplete
00415     BOOL FindRequiredAttribTypes(List* ReqdAttribListPtr); 
00416     BOOL FindRequiredAttribsTypesRec(Node* SubTree, 
00417                                      MarkedStack* AttribStackPtr, 
00418                                      List* ReqdAttribListPtr);
00419     */
00420     BOOL FindReqdAttribs(List* ReqdAttribList); 
00421     void RemoveSuperfluousAttribs(); 
00422 
00423     // fns for attribute optimisation called by FactorOutCommonChildAttributes()
00424     BOOL FindCommonAttributesToFactorOut(CommonAttrSet* CommonAttributeSet);
00425 
00426 public:
00427     virtual BOOL SetParentLayerAsEdited();
00428 
00429 public:
00430     virtual BOOL IsSeeThrough(BOOL CheckIndirectAttrs);
00431 }; 
00432 
00433 #endif  

Generated on Sat Nov 10 03:45:33 2007 for Camelot by  doxygen 1.4.4