clipattr.cpp

Go to the documentation of this file.
00001 // $Id: clipattr.cpp 1361 2006-06-25 16:43:38Z 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 // Implementation of ClipRegionAttribute.
00100 //
00101 
00102 #include "camtypes.h"   // pre-compiled header
00103 #include "clipattr.h"   // our own header file
00104 #include "grndrgn.h"    // for GRenderRegion.
00105 //#include "mario.h"            // _R(IDE_NOMORE_MEMORY)
00106 #include "blendatt.h"       // BlendAttrParam
00107 
00108 DECLARE_SOURCE("$Revision: 1361 $")
00109 
00110 // runtime class creation stuff.
00111 CC_IMPLEMENT_DYNCREATE(ClipRegionAttribute, AttributeValue)
00112 CC_IMPLEMENT_DYNAMIC(AttrClipView, NodeAttribute)
00113 
00114 // Declare smart memory handling in Debug builds
00115 #define new CAM_DEBUG_NEW
00116 
00117 
00118 
00119 /********************************************************************************************
00120 
00121 >   ClipRegionAttribute::ClipRegionAttribute()
00122 
00123     Author:     Karim_MacDonald (Xara Group Ltd) <camelotdev@xara.com>
00124     Created:    20 March 2000
00125     Inputs:     
00126     Outputs:    
00127     Returns:    
00128     Purpose:    
00129     Errors:     
00130     See also:   
00131 
00132 ********************************************************************************************/
00133 ClipRegionAttribute::ClipRegionAttribute()
00134 {
00135     m_pClipPath = NULL;
00136     m_bResponsibleForGrouping = FALSE;
00137 }
00138 
00139 
00140 
00141 /********************************************************************************************
00142 
00143 >   ClipRegionAttribute::~ClipRegionAttribute()
00144 
00145     Author:     Karim_MacDonald (Xara Group Ltd) <camelotdev@xara.com>
00146     Created:    20 March 2000
00147     Inputs:     
00148     Outputs:    
00149     Returns:    
00150     Purpose:    
00151     Errors:     
00152     See also:   
00153 
00154 ********************************************************************************************/
00155 ClipRegionAttribute::~ClipRegionAttribute()
00156 {
00157     if (m_pClipPath != NULL)
00158         m_pClipPath = NULL;
00159 }
00160 
00161 
00162 
00163 /********************************************************************************************
00164 
00165 >   virtual void ClipRegionAttribute::Render(RenderRegion* pRender, BOOL Temp = FALSE)
00166 
00167     Author:     Karim_MacDonald (Xara Group Ltd) <camelotdev@xara.com>
00168     Created:    20 March 2000
00169     Inputs:     
00170     Outputs:    
00171     Returns:    
00172     Purpose:    
00173     Errors:     
00174     See also:   
00175 
00176 ********************************************************************************************/
00177 void ClipRegionAttribute::Render(RenderRegion* pRender, BOOL Temp)
00178 {
00179 // DEBUG:
00180 //  TRACEUSER( "Karim", _T("ClipRegionAttribute::Render; 0x%x with path 0x%x\n"), (DWORD)this,
00181 //                                                                          (DWORD)m_pClipPath);
00182 //  TRACEUSER( "Karim", _T("pClipAttr 0x%x Render()'ed by RR 0x%x\n"),
00183 //                                  (DWORD)this, (DWORD)pRender);
00184     pRender->SetClipRegion(this, Temp);
00185 }
00186 
00187 
00188 
00189 /********************************************************************************************
00190 
00191 >   virtual void ClipRegionAttribute::Restore(RenderRegion* pRender, BOOL Temp)
00192 
00193     Author:     Karim_MacDonald (Xara Group Ltd) <camelotdev@xara.com>
00194     Created:    20 March 2000
00195     Inputs:     
00196     Outputs:    
00197     Returns:    
00198     Purpose:    
00199     Errors:     
00200     See also:   
00201 
00202 ********************************************************************************************/
00203 void ClipRegionAttribute::Restore(RenderRegion* pRender, BOOL Temp)
00204 {
00205 // DEBUG:
00206 //  TRACEUSER( "Karim", _T("ClipRegionAttribute::Restore; 0x%x with path 0x%x\n"), (DWORD)this,
00207 //                                                                          (DWORD)m_pClipPath);
00208 //  TRACEUSER( "Karim", _T("pClipAttr 0x%x Restore()'ed by RR 0x%x\n"),
00209 //                                  (DWORD)this, (DWORD)pRender);
00210     pRender->RestoreClipRegion(this, Temp);
00211 }
00212 
00213 
00214 
00215 /********************************************************************************************
00216 
00217 >   virtual void ClipRegionAttribute::GoingOutOfScope(RenderRegion* pRender)
00218 
00219     Author:     Karim_MacDonald (Xara Group Ltd) <camelotdev@xara.com>
00220     Created:    20 March 2000
00221     Inputs:     
00222     Outputs:    
00223     Returns:    
00224     Purpose:    
00225     Errors:     
00226     See also:   
00227 
00228 ********************************************************************************************/
00229 void ClipRegionAttribute::GoingOutOfScope(RenderRegion* pRender)
00230 {
00231 // DEBUG:
00232 //  TRACEUSER( "MarkH", _T("ClipRegionAttribute::GoingOutOfScope; 0x%x with path 0x%x\n"), (DWORD)this,
00233 //                                                                          (DWORD)m_pClipPath);
00234 }
00235 
00236 
00237 
00238 /********************************************************************************************
00239 
00240 >   virtual void ClipRegionAttribute::SimpleCopy(AttributeValue* pSource)
00241 
00242     Author:     Karim_MacDonald (Xara Group Ltd) <camelotdev@xara.com>
00243     Created:    20 March 2000
00244     Inputs:     pSource     the ClipRegionAttribute to copy.
00245     Outputs:    This ClipRegionAttribute becomes a copy of pSource.
00246 
00247     Purpose:    Make this attribute into a straight copy of the given attribute.
00248 
00249     Notes:      Note that NO error checking is done in this routine (bad?), so MAKE SURE
00250                 that the pointer you pass in as pSource is a VALID ClipRegionAttribute.
00251 
00252 ********************************************************************************************/
00253 void ClipRegionAttribute::SimpleCopy(AttributeValue* pSource)
00254 {
00255 // DEBUG:
00256 //  TRACEUSER( "Karim", _T("ClipRegionAttribute::SimpleCopy; 0x%x with path 0x%x\n"), (DWORD)this,
00257 //                                                                          (DWORD)m_pClipPath);
00258     m_pClipPath = ((ClipRegionAttribute*)pSource)->m_pClipPath;
00259 }
00260 
00261 
00262 
00263 /********************************************************************************************
00264 
00265 >   NodeAttribute* AttributeValue::MakeNode()
00266 
00267     Author:     Karim_MacDonald (Xara Group Ltd) <camelotdev@xara.com>
00268     Created:    12 April 2000
00269     Returns:    NULL always.
00270     Purpose:    This method is here so that an AttributeValue can build and return a 
00271                 corresponding NodeAttribute, for insertion into the tree. We don't do
00272                 this, as we're not linked with NodeAttributes at all.
00273 
00274 ********************************************************************************************/
00275 NodeAttribute* ClipRegionAttribute::MakeNode()
00276 {
00277     return NULL;
00278 }
00279 
00280 
00281 
00282 /********************************************************************************************
00283 
00284 >   virtual BOOL ClipRegionAttribute::IsDifferent(AttributeValue* pOther)
00285 
00286     Author:     Karim_MacDonald (Xara Group Ltd) <camelotdev@xara.com>
00287     Created:    20 March 2000
00288     Inputs:     
00289     Outputs:    
00290     Returns:    
00291     Purpose:    
00292     Errors:     
00293     See also:   
00294 
00295 ********************************************************************************************/
00296 BOOL ClipRegionAttribute::IsDifferent(AttributeValue* pOther)
00297 {
00298 // DEBUG:
00299 //  TRACEUSER( "Karim", _T("ClipRegionAttribute::IsDifferent; we are 0x%x\n"), (DWORD)this);
00300     ERROR2IF(   GetRuntimeClass() != pOther->GetRuntimeClass(), TRUE,
00301                "Attribute difference comparison must be between same types" );
00302     return (m_pClipPath != ((ClipRegionAttribute*)pOther)->GetClipPath());
00303 }
00304 
00305 
00306 
00307 /********************************************************************************************
00308 
00309 >   static BOOL ClipRegionAttribute::Init()
00310 
00311     Author:     Karim_MacDonald (Xara Group Ltd) <camelotdev@xara.com>
00312     Created:    20 March 2000
00313     Inputs:     
00314     Outputs:    
00315     Returns:    
00316     Purpose:    
00317     Errors:     
00318     See also:   
00319 
00320 ********************************************************************************************/
00321 BOOL ClipRegionAttribute::Init()
00322 {
00323     ClipRegionAttribute* pAttrVal = NULL;
00324     pAttrVal = new ClipRegionAttribute;
00325     if (pAttrVal == NULL)
00326         return FALSE;
00327 
00328     UINT32 ID = AttributeManager::RegisterDefaultAttribute(CC_RUNTIME_CLASS(NodeRenderableInk),
00329                                                          pAttrVal);
00330 
00331     if (ID == ATTR_BAD_ID)
00332         return FALSE;
00333 
00334     ERROR3IF(ID != ATTR_CLIPREGION, "Incorrect ID for attribute!");
00335     return TRUE;
00336 }
00337 
00339 AttrClipView::AttrClipView()
00340 {
00341     m_DoRender = TRUE;
00342     Value.SetResponsibleForGrouping (TRUE);
00343 }
00344 
00345 AttrClipView::AttrClipView(Node* ContextNode, AttachNodeDirection Direction,
00346                             BOOL Locked, BOOL Mangled, BOOL Marked, BOOL Selected) : 
00347                             NodeAttribute(ContextNode, Direction, Locked, Mangled, Marked, Selected)
00348 {
00349     m_DoRender = TRUE;
00350     Value.SetResponsibleForGrouping (TRUE);
00351 }
00352 
00353 AttrClipView::~AttrClipView()
00354 {
00355 }
00356 
00357 void AttrClipView::Render( RenderRegion* pRender )
00358 {
00359     // check the pointer and also make sure that we`re allowed to render
00360     if (!pRender || !m_DoRender)
00361         return;
00362 
00363     // Don`t need to render when hit testing
00364     if(!pRender->IsHitDetect())
00365         Value.Render(pRender);
00366 }
00367 
00368 #ifdef _DEBUG
00369 void AttrClipView::GetDebugDetails(StringBase* Str)
00370 {
00371     // Get our base class debug info.
00372     NodeRenderable::GetDebugDetails(Str);
00373 
00374     // Output the data for our clipping path.
00375     Path* pClipPath = Value.GetClipPath();
00376 
00377     if (pClipPath == NULL)
00378     {
00379         (*Str) += TEXT( "\r\nNo Clipping Path Data\r\n" );
00380     }
00381     else
00382     {
00383         (*Str) += TEXT( "\r\nClipping Path Data\r\n" );
00384         pClipPath->GetDebugDetails(Str);
00385     }
00386 }
00387 #endif
00388 
00389 Node* AttrClipView::SimpleCopy()
00390 {
00391     AttrClipView* pAttr = new AttrClipView();
00392     ERRORIF(pAttr==NULL, _R(IDE_NOMORE_MEMORY),NULL);
00393 
00394     CopyNodeContents(pAttr);
00395     return pAttr;
00396 }
00397 
00398 
00399 
00400 /***********************************************************************************************
00401 >   void AttrClipView::PolyCopyNodeContents(NodeRenderable* pNodeCopy)
00402 
00403     Author:     Phil_Martin (Xara Group Ltd) <camelotdev@xara.com>
00404     Created:    18/12/2003
00405     Outputs:    -
00406     Purpose:    Polymorphically copies the contents of this node to another
00407     Errors:     An assertion failure will occur if NodeCopy is NULL
00408     Scope:      protected
00409                                      
00410 ***********************************************************************************************/
00411 
00412 void AttrClipView::PolyCopyNodeContents(NodeRenderable* pNodeCopy)
00413 {
00414     ENSURE(pNodeCopy, "Trying to copy a node's contents into a NULL node");
00415     ENSURE(IS_A(pNodeCopy, AttrClipView), "PolyCopyNodeContents given wrong dest node type");
00416 
00417     if (IS_A(pNodeCopy, AttrClipView))
00418         CopyNodeContents((AttrClipView*)pNodeCopy);
00419 }
00420 
00421 
00422 
00423 void AttrClipView::CopyNodeContents(NodeAttribute *pCopy)
00424 {
00425     NodeAttribute::CopyNodeContents(pCopy);
00426     ((AttrClipView*)pCopy)->Value.SimpleCopy( &Value );
00427 }
00428 
00429 INT32 AttrClipView::operator==(const NodeAttribute& NodeAttrib)
00430 {
00431     Path* pComparePath = ((ClipRegionAttribute*)&NodeAttrib)->GetClipPath();
00432     Path* pThisPath = Value.GetClipPath();
00433 
00434     if(pComparePath && pThisPath)
00435     {
00436         return pThisPath->ComparePathToPath(pComparePath);
00437     }
00438 
00439     return -1;
00440 }
00441 
00442 void AttrClipView::Transform(TransformBase& Trans)
00443 {
00444 //  static const FIXED16 One(1.0);
00445 
00446 //  FIXED16 ScaleFactor = Trans.GetScaleFactor();
00447 }
00448 
00449 BOOL AttrClipView::Blend(BlendAttrParam* pBlendParam)
00450 {
00451     // Don`t want to blend this attribute at the mo!
00452     return FALSE;
00453 }
00454 
00455 BOOL AttrClipView::ContainsAttributeValue(AttributeValue* pVal)
00456 {
00457     if(!pVal->IS_KIND_OF(ClipRegionAttribute))
00458     {
00459         ENSURE(FALSE,"Strange attr value comparison test requested");
00460         return FALSE;
00461     }
00462 
00463     return (pVal == &Value);
00464 }
00465 
00466 BOOL AttrClipView::WritePreChildrenWeb(BaseCamelotFilter* pFilter)
00467 {
00468     return TRUE;
00469 }
00470 
00471 BOOL AttrClipView::WritePreChildrenNative(BaseCamelotFilter* pFilter)
00472 {
00473     return TRUE;
00474 }

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