ndclpcnt.h

Go to the documentation of this file.
00001 // $Id: ndclpcnt.h 1282 2006-06-09 09:46:49Z alex $
00002 /* @@tag:xara-cn@@ DO NOT MODIFY THIS LINE
00003 ================================XARAHEADERSTART===========================
00004  
00005                Xara LX, a vector drawing and manipulation program.
00006                     Copyright (C) 1993-2006 Xara Group Ltd.
00007        Copyright on certain contributions may be held in joint with their
00008               respective authors. See AUTHORS file for details.
00009 
00010 LICENSE TO USE AND MODIFY SOFTWARE
00011 ----------------------------------
00012 
00013 This file is part of Xara LX.
00014 
00015 Xara LX is free software; you can redistribute it and/or modify it
00016 under the terms of the GNU General Public License version 2 as published
00017 by the Free Software Foundation.
00018 
00019 Xara LX and its component source files are distributed in the hope
00020 that it will be useful, but WITHOUT ANY WARRANTY; without even the
00021 implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
00022 See the GNU General Public License for more details.
00023 
00024 You should have received a copy of the GNU General Public License along
00025 with Xara LX (see the file GPL in the root directory of the
00026 distribution); if not, write to the Free Software Foundation, Inc., 51
00027 Franklin St, Fifth Floor, Boston, MA  02110-1301 USA
00028 
00029 
00030 ADDITIONAL RIGHTS
00031 -----------------
00032 
00033 Conditional upon your continuing compliance with the GNU General Public
00034 License described above, Xara Group Ltd grants to you certain additional
00035 rights. 
00036 
00037 The additional rights are to use, modify, and distribute the software
00038 together with the wxWidgets library, the wxXtra library, and the "CDraw"
00039 library and any other such library that any version of Xara LX relased
00040 by Xara Group Ltd requires in order to compile and execute, including
00041 the static linking of that library to XaraLX. In the case of the
00042 "CDraw" library, you may satisfy obligation under the GNU General Public
00043 License to provide source code by providing a binary copy of the library
00044 concerned and a copy of the license accompanying it.
00045 
00046 Nothing in this section restricts any of the rights you have under
00047 the GNU General Public License.
00048 
00049 
00050 SCOPE OF LICENSE
00051 ----------------
00052 
00053 This license applies to this program (XaraLX) and its constituent source
00054 files only, and does not necessarily apply to other Xara products which may
00055 in part share the same code base, and are subject to their own licensing
00056 terms.
00057 
00058 This license does not apply to files in the wxXtra directory, which
00059 are built into a separate library, and are subject to the wxWindows
00060 license contained within that directory in the file "WXXTRA-LICENSE".
00061 
00062 This license does not apply to the binary libraries (if any) within
00063 the "libs" directory, which are subject to a separate license contained
00064 within that directory in the file "LIBS-LICENSE".
00065 
00066 
00067 ARRANGEMENTS FOR CONTRIBUTION OF MODIFICATIONS
00068 ----------------------------------------------
00069 
00070 Subject to the terms of the GNU Public License (see above), you are
00071 free to do whatever you like with your modifications. However, you may
00072 (at your option) wish contribute them to Xara's source tree. You can
00073 find details of how to do this at:
00074   http://www.xaraxtreme.org/developers/
00075 
00076 Prior to contributing your modifications, you will need to complete our
00077 contributor agreement. This can be found at:
00078   http://www.xaraxtreme.org/developers/contribute/
00079 
00080 Please note that Xara will not accept modifications which modify any of
00081 the text between the start and end of this header (marked
00082 XARAHEADERSTART and XARAHEADEREND).
00083 
00084 
00085 MARKS
00086 -----
00087 
00088 Xara, Xara LX, Xara X, Xara X/Xtreme, Xara Xtreme, the Xtreme and Xara
00089 designs are registered or unregistered trademarks, design-marks, and/or
00090 service marks of Xara Group Ltd. All rights in these marks are reserved.
00091 
00092 
00093       Xara Group Ltd, Gaddesden Place, Hemel Hempstead, HP2 6EX, UK.
00094                         http://www.xara.com/
00095 
00096 =================================XARAHEADEREND============================
00097  */
00098 //
00099 // Declaration of NodeClipViewController.
00100 //
00101 
00102 #ifndef INC_NDCLPCNT
00103 #define INC_NDCLPCNT
00104 
00105 //#include "group.h"        // derivation from NodeGroup - in camtypes.h [AUTOMATICALLY REMOVED]
00106 //#include "cxfrech.h"  // derivation from CamelotRecordHandler - in camtypes.h [AUTOMATICALLY REMOVED]
00107 
00108 #include "opclip.h"     // for reference to OpApplyClipView
00109 
00110 class NodeClipView;
00111 class ExtendParams;
00112 class CXaraFileRecord;
00113 
00114 /********************************************************************************************
00115 
00116 >   class NodeClipViewController : public NodeGroup
00117 
00118     Author:     Karim_MacDonald (Xara Group Ltd) <camelotdev@xara.com>
00119     Created:    27/01/2000
00120     Purpose:    ClipView controller node.
00121                 This is the node which does all the hard work with respect to clipview 
00122                 functionality. Initially at least, it is really a more-or-less normal group, 
00123                 with special rendering qualities. The bottom-most (in a z-order sense) 
00124                 NodeRenderableInk in the group is rendered, then its path is used to create a 
00125                 clipping region, into which all other members of the group are rendered.
00126 
00127     Notes:      This is how you create a ClipView group in the tree:
00128 
00129                     1.  Set up the tree structure (ignoring attributes):
00130 
00131                             NCVC
00132                              |
00133                              |--{ Keyhole }--{ NCV }--{ Clipped Node N1 }--{ N2 }-- - etc.
00134 
00135                     2.  Call the NCVC's UpdateKeyholePath() method.
00136                         This method should really be public, but is not, to emphasize that
00137                         you shouldn't just call it from anywhere, as it also marks the cached
00138                         keyhole path as valid. To invalidate the cache (you shouldn't usually
00139                         need to), you must call MarkKeyholeValid(), or if you need update on
00140                         undo/redo, invoke an UpdateCachedKeyholePathAction.
00141 
00142                     3.  Call the NCVC's InvalidateBoundingRect() method.
00143     See also:   
00144 
00145 ********************************************************************************************/
00146 class NodeClipViewController : public NodeGroup
00147 {
00148 // Give my name out in memory dumps.
00149 CC_DECLARE_DYNCREATE(NodeClipViewController);
00150 
00151 // methods and classes which need to be able to invoke UpdateKeyholePath().
00152 friend class NodeClipView;
00153 friend void OpApplyClipView::Do(OpDescriptor* pOpDesc);
00154 friend class UpdateCachedKeyholePathAction;
00155 
00156 public:
00157     // construction/destruction and initialisation.
00158     NodeClipViewController();
00159     NodeClipViewController( Node* pContextNode,
00160                             AttachNodeDirection Direction,
00161                             BOOL Locked     = FALSE,
00162                             BOOL Mangled    = FALSE,
00163                             BOOL Marked     = FALSE,
00164                             BOOL Selected   = FALSE );
00165     ~NodeClipViewController();
00166 
00167     // debug-tree details - only required in non-release builds.
00168     virtual void GetDebugDetails(StringBase* pStr);
00169 
00170     // virtual ID function.
00171     virtual BOOL IsANodeClipViewController() const { return TRUE; }
00172 
00173     // bounding information.
00174     virtual DocRect GetBoundingRect(BOOL DontUseAttrs = FALSE, BOOL HitTest = FALSE);
00175     virtual DocRect GetBlobBoundingRect();
00176     virtual DocRect GetEorDragBoundingRect();
00177 
00178     // render this node.
00179     virtual SubtreeRenderState RenderSubtree(RenderRegion* pRender, Node** ppNextNode = NULL, BOOL bClip = TRUE);
00180     virtual void RenderEorDrag( RenderRegion* pRender );
00181     virtual void RenderEorDragSelectedChildren(Node* pParent, RenderRegion* pRender);
00182     virtual BOOL ChildrenAreEorDragRenderedByMe();
00183 
00184     // our blob-rendering methods.
00185     virtual void RenderTinyBlobs(RenderRegion* pRender);
00186     virtual void RenderToolObjectBlobs(RenderRegion* pRender);
00187 
00188     // Virtual rendering functions   (added 8th November 2000 - ChrisG)    
00189     virtual void PreExportRender( RenderRegion* pRender ); 
00190     virtual BOOL ExportRender( RenderRegion* pRender ); 
00191 
00192 protected:
00193     virtual void RenderClipViewBlobs(RenderRegion* pRegion);
00194 
00195 public:
00196     // deals with mouse clicks on this node.
00197     virtual BOOL OnClick(   DocCoord dcClickPos, ClickType cType,
00198                             ClickModifiers cMods, Spread* pSpread );
00199 protected:
00200     // handlers for the various types of clicks which a NodeClipViewController can receive.
00201     virtual BOOL HandleKeyholeBlobClick(ClickType cType);
00202     virtual BOOL HandleContentsBlobClick(ClickType cType);
00203 
00204 public:
00205     // used to convert to paths - see mkshapes.cpp.
00206     virtual BOOL CanBecomeA(BecomeA* pBecomeA);
00207     virtual BOOL DoBecomeA(BecomeA* pBecomeA);
00208     virtual NodeGroup* BecomeAGroup(UndoableOperation* pUndoOp);
00209     virtual BOOL GroupCanTransformCached(TransformBase& Trans) const {return TRUE;}
00210 
00211 private:
00212     // helper methods for DoBecomeA.
00213     BOOL KeyholeDoBecomeA(BecomeA* pBecomeA);
00214     BOOL MakeShapeAndLine(NodePath* pNodePath, BecomeA* pBecomeA, BOOL bClipToKeyhole);
00215     BOOL InsertClippedNode( NodePath* pNewNode, NodePath* pDestNode,
00216                             AttachNodeDirection Direction,
00217                             UndoableOperation* pUndoOp,
00218                             BOOL bClipToKeyhole );
00219     BOOL PassBackClippedNode(NodePath* pNewNode, BecomeA* pBecomeA, BOOL bClipToKeyhole);
00220     BOOL InkHasClearLineColour(NodeRenderableInk* pInkNode);
00221     BOOL RemoveInkLineWidth(NodeRenderableInk* pInk);
00222     BOOL CopyInkFillColourFromLine(NodeRenderableInk* pInk);
00223     BOOL CopyInkTransparencyFromLine(NodeRenderableInk* pInk);
00224 
00225     // methods for keeping our cached keyhole path up to date.
00226     // please only use these inline validation methods to set/check keyhole validity.
00227     BOOL UpdateKeyholePath();
00228     BOOL IsKeyholeValid()     const { return m_fKeyholeValid; }
00229     void MarkKeyholeValid()     { m_fKeyholeValid = TRUE;  }
00230     void MarkKeyholeInvalid()   { m_fKeyholeValid = FALSE; }
00231 
00232 public:
00233     // return the required path flatness for ClipView groups.
00234     static INT32 EstimatePathFlatness();
00235 
00236     // AllowOp / OnChildChange function pair.
00237     // Called on this node in response to any operation which may affect the node.
00238     virtual BOOL AllowOp(ObjChangeParam *pParam, BOOL SetOpPermissionState = TRUE,
00239                                                  BOOL DoPreTriggerEdit = TRUE);
00240     virtual ChangeCode OnChildChange(ObjChangeParam* pParam);
00241 
00242     // return a description, for use in menus, infobar etc.
00243     virtual String Describe(BOOL Plural, BOOL Verbose);
00244     virtual UINT32 GetNodeSize() const;
00245 
00246     // transform this node.
00247     void Transform(TransformBase &Trans);
00248 
00249     // Version 2 file format functions
00250     virtual BOOL WritePreChildrenWeb(BaseCamelotFilter* pFilter);
00251     virtual BOOL WritePreChildrenNative(BaseCamelotFilter* pFilter);
00252 
00253     // called on nodes after a document is imported.
00254     virtual BOOL PostImport();
00255 
00256     // whether this node is a controller node or not.
00257     // AFAIK this method is used solely by OpEditBlendEndObject for update,
00258     // when moving one of the end-objects of a blend-ona-path which lies within
00259     // a controller structure. Strikes me as a tad silly...
00260     virtual BOOL IsController() { return TRUE; }
00261 
00262     // retrieves this node's associated NodeClipView child.
00263     // returns NULL if there is no associated NodeClipView.
00264     NodeClipView* GetClipView(BOOL ReportErrors = TRUE);
00265 
00266 
00267     // get a pointer to the cached InkPath of this node's keyhole.
00268     Path* GetKeyholePath() { return &m_KeyholePath; }
00269 
00270     // test whether a particular ink-node is a keyhole node for this NCVC.
00271     BOOL OwnsAsKeyholeNode(const Node* pTestNode);
00272 
00273     // some constants we require for half-decent path clipping.
00274     static const INT32 CLIPVIEW_TOLERANCE;
00275     static const INT32 CLIPVIEW_SOURCEFLATNESS;
00276     static const INT32 CLIPVIEW_CLIPFLATNESS;
00277 
00278     virtual void PolyCopyNodeContents(NodeRenderable* pNodeCopy);
00279 
00280 protected:
00281     // copy methods. (Q: is there a reason why CopyNodeContents() is not virtual?)
00282     // Phil 19/12/2003 A: Yes. Because it takes a typed input parameter
00283     //                      However, I have just added PolyCopyNodeContents which takes a NodeRenderable*
00284     virtual Node* SimpleCopy();
00285     void CopyNodeContents(NodeClipViewController* pNodeCopy);
00286 
00288 //
00289 // Member variables
00290 //
00291 
00292 private:
00293     // our cached keyhole path, and whether it is valid or not.
00294     Path m_KeyholePath;
00295     BOOL m_fKeyholeValid;
00296 
00297     // the bounding rectangles of our ClipView-group blobs.
00298     DocRect m_drKeyholeBlobRect;
00299     DocRect m_drContentsBlobRect;
00300 };
00301 
00302 
00303 
00304 //-------------------------------------------------------------------------------------------
00305 //-------------------------------------------------------------------------------------------
00306 //-------------------------------------------------------------------------------------------
00307 //-------------------------------------------------------------------------------------------
00308 
00309 
00310 
00311 /********************************************************************************************
00312 
00313 >   class ClipViewRecordHandler : public CamelotRecordHandler
00314 
00315     Author:     Karim_MacDonald (Xara Group Ltd) <camelotdev@xara.com>
00316     Created:    28/01/2000
00317     Purpose:    Handles the reading of all ClipView records.
00318     See also:   
00319 
00320 ********************************************************************************************/
00321 class ClipViewRecordHandler : public CamelotRecordHandler
00322 {
00323 // Give my name out in memory dumps
00324 CC_DECLARE_DYNCREATE(ClipViewRecordHandler)
00325 
00326 public:
00327     // functions that must be implemented.
00328     ClipViewRecordHandler();
00329     ~ClipViewRecordHandler();
00330     virtual UINT32* GetTagList();
00331     virtual BOOL    HandleRecord(CXaraFileRecord* pCXaraFileRecord);
00332 };
00333 
00334 
00335 
00336 //-------------------------------------------------------------------------------------------
00337 //-------------------------------------------------------------------------------------------
00338 //-------------------------------------------------------------------------------------------
00339 //-------------------------------------------------------------------------------------------
00340 
00341 
00342 
00343 /********************************************************************************************
00344 
00345 >   class UpdateCachedKeyholePathAction : public Action
00346 
00347     Author:     Karim_MacDonald (Xara Group Ltd) <camelotdev@xara.com>
00348     Created:    20 March 2000
00349     Purpose:    Cause a NodeClipViewController node to update it cached keyhole path when
00350                 an operation is undone or redone.
00351     Notes:      Invoking this action via its Init() method has no _direct_ effect, save to
00352                 set the action to trigger on undo/redo.
00353 
00354 ********************************************************************************************/
00355 class UpdateCachedKeyholePathAction : public Action
00356 {
00357 // dynamic class creation.
00358 CC_DECLARE_DYNCREATE(UpdateCachedKeyholePathAction)
00359 
00360 public:
00361     // required Action methods.
00362     UpdateCachedKeyholePathAction();
00363     ~UpdateCachedKeyholePathAction();
00364     static ActionCode Init( UndoableOperation* pUndoOp,
00365                             ActionList* pActionList,
00366                             NodeClipViewController* pUpdateNCVC );
00367     virtual ActionCode Execute();
00368 
00369 private:
00370     // initialise our own information.
00371     void SetNCVCToUpdate(NodeClipViewController* pNCVC);
00372 
00373     // member variables.
00374     NodeClipViewController* m_pNCVC;
00375 };
00376 
00377 
00378 
00379 #endif  // INC_NDCLPCNT
00380 

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