attrbev.cpp

Go to the documentation of this file.
00001 // $Id: attrbev.cpp 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 /*
00100 */
00101     
00102 #include "camtypes.h"                          
00103 #include "attrbev.h"
00104 //#include "errors.h" - in camtypes.h [AUTOMATICALLY REMOVED]
00105 //#include "mario.h"
00106 //#include "simon.h"
00107 //#include "tim.h"
00108 //#include "will.h"
00109 //#include "attrmgr.h" - in camtypes.h [AUTOMATICALLY REMOVED]
00110 //#include "tranform.h" - in camtypes.h [AUTOMATICALLY REMOVED]
00111 #include "blobs.h"
00112 //#include "app.h" - in camtypes.h [AUTOMATICALLY REMOVED]
00113 //#include "fixed16.h" - in camtypes.h [AUTOMATICALLY REMOVED]
00114 #include "blendatt.h"
00115 #include "nodepath.h"
00116 //#include "ink.h" - in camtypes.h [AUTOMATICALLY REMOVED]
00117 #include "attrmap.h"
00118 //#include "camfiltr.h" - in camtypes.h [AUTOMATICALLY REMOVED]
00119 #include "cxftags.h"
00120 //#include "cxfdefs.h" - in camtypes.h [AUTOMATICALLY REMOVED]
00121 #include "rechattr.h"   // Record handling classes for attributes
00122 //#include "cxfrec.h" - in camtypes.h [AUTOMATICALLY REMOVED]
00123 #include "cxfdash.h"    // Default dash pattern references
00124 #include "cxfarrow.h"   // Default arrow head/tail references
00125 #include "cxfcols.h"    // REF_DEFAULTCOLOUR_TRANSPARENT ...
00126 //#include "bevres.h"
00127 #include "ppbevel.h"
00128 #include "cxftags.h"
00129 //#include "cxfdefs.h" - in camtypes.h [AUTOMATICALLY REMOVED]
00130 #include "nbevcont.h"
00131 //#include "view.h" - in camtypes.h [AUTOMATICALLY REMOVED]
00132 //#include "docview.h" - in camtypes.h [AUTOMATICALLY REMOVED]
00133 #include "beveler.h"
00134 //#include "biasgain.h" - in camtypes.h [AUTOMATICALLY REMOVED]
00135 
00136 DECLARE_SOURCE("$Revision: 1282 $");
00137 
00138 CC_IMPLEMENT_DYNCREATE(AttrBevel,   NodeAttribute)
00139 CC_IMPLEMENT_DYNCREATE(AttrBevelIndent, AttrBevel)
00140 CC_IMPLEMENT_DYNCREATE(BevelAttributeValueIndent,   AttributeValue)
00141 CC_IMPLEMENT_DYNCREATE(AttrBevelLightAngle, AttrBevel)
00142 CC_IMPLEMENT_DYNCREATE(BevelAttributeValueLightAngle,   AttributeValue)
00143 CC_IMPLEMENT_DYNCREATE(AttrBevelContrast,   AttrBevel)
00144 CC_IMPLEMENT_DYNCREATE(BevelAttributeValueContrast, AttributeValue)
00145 CC_IMPLEMENT_DYNCREATE(AttrBevelType,   AttrBevel)
00146 CC_IMPLEMENT_DYNCREATE(BevelAttributeValueType, AttributeValue)
00147 CC_IMPLEMENT_DYNCREATE(AttrBevelLightTilt,  AttrBevel)
00148 CC_IMPLEMENT_DYNCREATE(BevelAttributeValueLightTilt,    AttributeValue)
00149 
00150 
00151 
00152 // Declare smart memory handling in Debug builds
00153 #define new CAM_DEBUG_NEW
00154 
00155 /********************************************************************************************
00156 
00157 >   AttrBevel::AttrBevelIndent(Node* ContextNode,  
00158                     AttachNodeDirection Direction,  
00159                     BOOL Locked, 
00160                     BOOL Mangled,  
00161                     BOOL Marked, 
00162                     BOOL Selected    
00163             ): NodeAttribute(ContextNode, Direction, Locked, Mangled, Marked, Selected, TRUE)  
00164 
00165     Author:     David_McClarnon (Xara Group Ltd) <camelotdev@xara.com>
00166     Created:    21/11/99
00167     Inputs:     -
00168     Outputs:    -
00169     Returns:    -
00170     Purpose:    Bevel attribute constructor
00171     Errors:     -
00172     SeeAlso:    -
00173 
00174 ********************************************************************************************/
00175 AttrBevel::AttrBevel(Node* ContextNode,  
00176                     AttachNodeDirection Direction,  
00177                     BOOL Locked, 
00178                     BOOL Mangled,  
00179                     BOOL Marked, 
00180                     BOOL Selected    
00181             ): NodeAttribute(ContextNode, Direction, Locked, Mangled, Marked, Selected)  
00182 {
00183     
00184 }
00185 
00186 /********************************************************************************************
00187 
00188 >   AttrBevel::AttrBevel()
00189 
00190     Author:     David_McClarnon (Xara Group Ltd) <camelotdev@xara.com>
00191     Created:    21/11/99
00192     Inputs:     -
00193     Outputs:    -
00194     Returns:    -
00195     Purpose:    Bevel attribute constructor
00196     Errors:     -
00197     SeeAlso:    -
00198 
00199 ********************************************************************************************/
00200 AttrBevel::AttrBevel()
00201 {
00202 }
00203 
00204 /********************************************************************************************
00205 
00206 >   AttrBevelIndent::AttrBevelIndent(Node* ContextNode,  
00207                     AttachNodeDirection Direction,  
00208                     BOOL Locked, 
00209                     BOOL Mangled,  
00210                     BOOL Marked, 
00211                     BOOL Selected    
00212             ): NodeAttribute(ContextNode, Direction, Locked, Mangled, Marked, Selected, TRUE)  
00213 
00214     Author:     Will_Cowling (Xara Group Ltd) <camelotdev@xara.com>
00215     Created:    21/6/93
00216     Inputs:     -
00217     Outputs:    -
00218     Returns:    -
00219     Purpose:    Creates a bValue Attribute
00220     Errors:     -
00221     SeeAlso:    -
00222 
00223 ********************************************************************************************/
00224 
00225 AttrBevelIndent::AttrBevelIndent(Node* ContextNode,  
00226                     AttachNodeDirection Direction,  
00227                     BOOL Locked, 
00228                     BOOL Mangled,  
00229                     BOOL Marked, 
00230                     BOOL Selected    
00231             ): AttrBevel(ContextNode, Direction, Locked, Mangled, Marked, Selected)  
00232 {                         
00233 } 
00234 
00235 /********************************************************************************************
00236 
00237 >   AttrBevelIndent::AttrBevelIndent()
00238 
00239     Author:     Will_Cowling (Xara Group Ltd) <camelotdev@xara.com>
00240     Created:    21/6/93
00241     Inputs:     -
00242     Outputs:    -
00243     Returns:    -
00244     Purpose:    Default constructor for Line Width Attribute class
00245     Errors:     -
00246     SeeAlso:    -
00247 
00248 ********************************************************************************************/
00249 
00250 AttrBevelIndent::AttrBevelIndent()
00251 {
00252 }
00253 
00254 /********************************************************************************************
00255 
00256 >   void AttrBevelIndent::Render( RenderRegion* pRender)
00257 
00258     Author:     Will_Cowling (Xara Group Ltd) <camelotdev@xara.com>
00259     Created:    21/6/93
00260     Inputs:     -
00261     Outputs:    -
00262     Returns:    -
00263     Purpose:    'Renders' a Line Width attribute.
00264     Errors:     -
00265     SeeAlso:    -
00266 
00267 ********************************************************************************************/
00268 
00269 void AttrBevelIndent::Render( RenderRegion* pRender)
00270 {
00271 }
00272 
00273 /********************************************************************************************
00274 
00275 >   void AttrBevelIndent::Transform( TransformBase& Trans )
00276 
00277     Author:     Will_Cowling (Xara Group Ltd) <camelotdev@xara.com>
00278     Created:    1/8/94
00279     Inputs:     Trans - the transform object to apply to this attribute.
00280     Purpose:    Scale the Line Width.
00281     SeeAlso:    NodeRenderable::Transform
00282 
00283 ********************************************************************************************/
00284 
00285 void AttrBevelIndent::Transform( TransformBase& Trans )
00286 {
00287     INT32 OldIndent = Value.m_Indent;
00288     
00289     // Find out the equivalent scale factor
00290     FIXED16 ScaleFactor = Trans.GetScalar();
00291 
00292     // no scaling then lets leave
00293     if (ScaleFactor.MakeDouble() == 1.0)
00294         return;
00295 
00296     // And scale the line width
00297     Value.m_Indent= labs( INT32(ScaleFactor.MakeDouble() * ((double)Value.m_Indent)) );
00298 
00299     // MRH - 3/7/00 - Added a quick check to see if the indent is greater than the slider limit.
00300     // If so then reset the value to the limit! ERROR3 For Debugging - can be taken out if anouying!
00301     if (Value.m_Indent > 250000)
00302     {
00303         ERROR3("Bevel Indent > Max Value! Setting to Max Value!");
00304         Value.m_Indent = 250000;
00305     }
00306 
00307     if (OldIndent < 0)
00308     {
00309         Value.m_Indent = -Value.m_Indent;
00310     }
00311 }
00312 
00313 /***********************************************************************************************
00314 > Node* AttrBevelIndent::SimpleCopy() 
00315 
00316     Author:     Will_Cowling (Xara Group Ltd) <camelotdev@xara.com>
00317     Created:    21/6/93
00318     
00319     Inputs:         - 
00320     Outputs:     
00321     Returns:    A copy of the node, or NULL if memory runs out 
00322          
00323     Purpose:    This method returns a shallow copy of the node with all Node pointers NULL. 
00324                 The function is virtual, and must be defined for all derived classes.  
00325 
00326     Errors:     If memory runs out when trying to copy, then ERROR is called with an out of memory
00327                 error and the function returns NULL. 
00328     
00329     Scope:      protected       
00330 ***********************************************************************************************/
00331      
00332 Node* AttrBevelIndent::SimpleCopy()
00333 {
00334     AttrBevelIndent* NodeCopy = new AttrBevelIndent();
00335     ERRORIF(NodeCopy == NULL, _R(IDE_NOMORE_MEMORY), NULL); 
00336     CopyNodeContents(NodeCopy);
00337     NodeCopy->Value.m_Indent = Value.m_Indent;
00338     return NodeCopy;
00339 } 
00340 
00341 /********************************************************************************************
00342 
00343 >   INT32 AttrBevelIndent::operator==(const NodeAttribute& Attrib)
00344 
00345     Author:     Simon_Maneggio (Xara Group Ltd) <camelotdev@xara.com>
00346     Created:    9/2/94
00347     Inputs:     Atrib:  The attribute to compare, which must be an AttrBevelIndent 
00348     Outputs:    -
00349     Returns:    -
00350     Purpose:    A virtual comparison operator. See NodeAttribute::operator== for 
00351                 a description of why it's required. 
00352  
00353     Errors:     An ENSURE failure will occur if Attrib does not have a AttrBevelIndent 
00354                 runtime class.
00355                  
00356     SeeAlso:    NodeAttribute::operator==
00357 
00358 ********************************************************************************************/
00359 
00360 INT32 AttrBevelIndent::operator==(const NodeAttribute& Attrib)
00361 {
00362     ENSURE(Attrib.IsKindOf(CC_RUNTIME_CLASS(AttrBevelIndent)), 
00363         "Trying to compare two objects with different types"); 
00364     AttrBevelIndent * Attr = (AttrBevelIndent *) &Attrib;
00365     return (Attr->Value.m_Indent == Value.m_Indent); 
00366 } 
00367 
00368 
00369 /********************************************************************************************
00370 
00371 >   virtual UINT32 AttrBevelIndent::GetAttrNameID(void)  
00372 
00373     Author:     Simon_Maneggio (Xara Group Ltd) <camelotdev@xara.com>
00374     Created:    22/2/94
00375     Inputs:     -
00376     Outputs:    -
00377     Returns:    Attribute description ID
00378     Purpose:    Returns back a string resource ID describing the attribute
00379 
00380     Errors:     -
00381     SeeAlso:    -
00382 
00383 ********************************************************************************************/
00384 
00385 UINT32 AttrBevelIndent::GetAttrNameID(void)  
00386 {
00387     return (_R(IDS_BEVEL_INDENT_ID)); 
00388 }               
00389                  
00390 
00391 /***********************************************************************************************
00392 > ` void AttrBevel::CopyNodeContents( AttrBevelIndent* NodeCopy)
00393 
00394     Author:     Simon_Maneggio (Xara Group Ltd) <camelotdev@xara.com>
00395     Created:    28/4/93
00396     
00397     Inputs:           
00398     Outputs:    A copy of this node
00399     Returns:    -
00400          
00401     Purpose:    This method copies the node's contents to the node pointed to by NodeCopy.
00402               
00403     Errors:     An assertion failure will occur if NodeCopy is NULL
00404     
00405     Scope:      protected
00406                                      
00407 ***********************************************************************************************/
00408 
00409 void AttrBevelIndent::CopyNodeContents( AttrBevelIndent* NodeCopy)
00410 {
00411     NodeAttribute::CopyNodeContents( NodeCopy );
00412 
00413     NodeCopy->Value = Value;
00414 } 
00415 
00416 /***********************************************************************************************
00417 >   void NodeRenderableBounded::PolyCopyNodeContents(NodeRenderable* pNodeCopy)
00418 
00419     Author:     Phil_Martin (Xara Group Ltd) <camelotdev@xara.com>
00420     Created:    18/12/2003
00421     Outputs:    -
00422     Purpose:    Polymorphically copies the contents of this node to another
00423     Errors:     An assertion failure will occur if NodeCopy is NULL
00424     Scope:      protected
00425                                      
00426 ***********************************************************************************************/
00427 
00428 void AttrBevelIndent::PolyCopyNodeContents(NodeRenderable* pNodeCopy)
00429 {
00430     ENSURE(pNodeCopy, "Trying to copy a node's contents into a NULL node");
00431     ENSURE(IS_A(pNodeCopy, AttrBevelIndent), "PolyCopyNodeContents given wrong dest node type");
00432 
00433     if (IS_A(pNodeCopy, AttrBevelIndent))
00434         CopyNodeContents((AttrBevelIndent*)pNodeCopy);
00435 }
00436 
00437 
00438 
00439 /***********************************************************************************************
00440 
00441 >   void AttrBevelIndent::ShowDebugTreeDetails() const
00442 
00443     Author:     Will_Cowling (Xara Group Ltd) <camelotdev@xara.com>
00444     Created:    21/6/93
00445     Purpose:    Displays debugging info of the tree
00446 
00447 ***********************************************************************************************/
00448 
00449 void AttrBevelIndent::ShowDebugTreeDetails() const
00450 {
00451     // Display a bit of debugging info
00452     // For now, we will just call the base class version
00453 #ifdef _DEBUG
00454     NodeAttribute::ShowDebugTreeDetails();  
00455 #endif
00456 }
00457 
00458 
00459 void AttrBevelIndent::GetDebugDetails(StringBase* Str)
00460 {
00461 #ifdef _DEBUG
00462     NodeAttribute::GetDebugDetails( Str );
00463 
00464     String_256 TempStr;
00465     TempStr._MakeMsg( TEXT("\r\nValue=#1%d\r\n"), Value.m_Indent );
00466     (*Str) += TempStr;
00467 #else
00468     if (Str)
00469     {
00470         *Str = wxT("");
00471     }
00472 #endif
00473 }
00474 
00475 
00476 
00477 /********************************************************************************************
00478 
00479 >   virtual UINT32 AttrBevelIndent::GetNodeSize() const
00480 
00481     Author:     Simon_Maneggio (Xara Group Ltd) <camelotdev@xara.com>
00482     Created:    6/10/93
00483     Inputs:     -
00484     Outputs:    -
00485     Returns:    The size of the node in bytes
00486     Purpose:    For finding the size of the node 
00487                 
00488     SeeAlso:    Node::GetSubtreeSize
00489 
00490 ********************************************************************************************/
00491 
00492 UINT32 AttrBevelIndent::GetNodeSize() const 
00493 {     
00494     return (sizeof(AttrBevelIndent)); 
00495 }  
00496 
00497 /********************************************************************************************
00498 
00499 >   BOOL AttrBevelIndent::Blend(BlendAttrParam* pBlendParam)
00500 
00501     Author:     David_McClarnon (Xara Group Ltd) <camelotdev@xara.com>
00502     Created:    12/12/99
00503     Inputs:     The blend attribute param
00504     Purpose:    Blends this indent to another
00505     SeeAlso:    
00506 
00507 ********************************************************************************************/
00508 BOOL AttrBevelIndent::Blend(BlendAttrParam* pBlendParam)
00509 {
00510     AttrBevelIndent * pBlendedAttr = NULL;
00511 
00512     // assign the other attribute we're looking at
00513     AttrBevelIndent * pOtherAttr = (AttrBevelIndent *)pBlendParam->GetOtherAttr();
00514 
00515     // split at the half way mark
00516     if (pBlendParam->GetBlendRatio() <= 0.5)
00517     {
00518         pBlendedAttr = (AttrBevelIndent *)SimpleCopy();
00519     }
00520     else
00521     {
00522         pBlendedAttr = (AttrBevelIndent *)pOtherAttr->SimpleCopy();
00523     }
00524 
00525     // set the blended attribute
00526     pBlendParam->SetBlendedAttr(pBlendedAttr);
00527 
00528     if (!pBlendedAttr)
00529         return FALSE;
00530 
00531     double Indent1          = Value.m_Indent;
00532     double Indent2          = pOtherAttr->Value.m_Indent;
00533     double NewIndent        = ((Indent2 - Indent1) * pBlendParam->GetBlendRatio()) + Indent1;
00534 
00535     // set the blended attribute's values
00536     pBlendedAttr->Value.m_Indent = (MILLIPOINT)NewIndent;
00537     
00538     return TRUE;
00539 }
00540 
00541 
00542 
00543 /********************************************************************************************
00544 
00545   > virtual BOOL AttrBevelIndent::WritePreChildrenWeb(BaseCamelotFilter* pFilter)
00546 
00547     Author:     Mark_Neves (Xara Group Ltd) <camelotdev@xara.com>
00548     Created:    30/5/96
00549     Inputs:     pFilter = ptr to the filter
00550     Returns:    TRUE if record is written, FALSE if not
00551     Purpose:    Writes the line width record to the filter
00552     SeeAlso:    -
00553 
00554 ********************************************************************************************/
00555 
00556 BOOL AttrBevelIndent::WritePreChildrenWeb(BaseCamelotFilter* pFilter)
00557 {
00558     return TRUE;
00559 }
00560 
00561 //--------------------------------------------------------------
00562 // See AttrBevelIndent::WritePreChildrenWeb(BaseCamelotFilter* pFilter)
00563 //
00564 BOOL AttrBevelIndent::WritePreChildrenNative(BaseCamelotFilter* pFilter)
00565 {
00566 #ifdef DO_EXPORT
00567     return WritePreChildrenWeb(pFilter);
00568 #else
00569     return FALSE;
00570 #endif
00571 }
00572 
00574 // the actual attribute
00575 
00576 BevelAttributeValueIndent::BevelAttributeValueIndent()
00577 {
00578 //  m_Indent = -3000;
00579     m_Indent = 0;
00580 }
00581 
00582 /********************************************************************************************
00583 
00584 >   void BevelAttributeValueIndent::Render(RenderRegion *pRegion)
00585 
00586     Author:     Tim_Browse (Xara Group Ltd) <camelotdev@xara.com>
00587     Created:    03/02/94
00588     Inputs:     pRegion - the render region to render this attribute into.
00589     Purpose:    Sets the line width attribute for the given render region. i.e. all
00590                 lines drawn will now be drawn with this line width.
00591     SeeAlso:    BevelAttributeValueIndent; RenderStack; AttributeValue; NodeAttribute;
00592                 BevelAttributeValueIndent::Restore; BevelAttributeValueIndent::SimpleCopy;
00593                 AttributeValue::Render; AttributeValue::Restore; AttributeValue::SimpleCopy
00594 
00595 ********************************************************************************************/
00596 
00597 void BevelAttributeValueIndent::Render(RenderRegion *pRegion, BOOL Temp)
00598 {
00599 }
00600 
00601 /********************************************************************************************
00602 
00603 >   void BevelAttributeValueIndent::Restore(RenderRegion *pRegion, BOOL Temp)
00604 
00605     Author:     Tim_Browse (Xara Group Ltd) <camelotdev@xara.com>
00606     Created:    03/02/94
00607     Inputs:     pRegion - the render region to restore the attribute into.
00608                 Temp    - TRUE if this is a temporary attribute, FALSE if it is
00609                           permanent (e.g. it's in a document tree).
00610     Purpose:    Restores the line width attribute for the given render region. i.e. all
00611                 lines drawn will now be drawn with this line width.
00612     SeeAlso:    BevelAttributeValueIndent; RenderStack; AttributeValue; NodeAttribute;
00613                 BevelAttributeValueIndent::Render; BevelAttributeValueIndent::SimpleCopy;
00614                 AttributeValue::Render; AttributeValue::Restore; AttributeValue::SimpleCopy
00615 
00616 ********************************************************************************************/
00617 
00618 void BevelAttributeValueIndent::Restore(RenderRegion *pRegion, BOOL Temp)
00619 {
00620 }
00621 
00622 /********************************************************************************************
00623 
00624 >   void BevelAttributeValueIndent::SimpleCopy(AttributeValue *pValue)
00625 
00626     Author:     Tim_Browse (Xara Group Ltd) <camelotdev@xara.com>
00627     Created:    03/02/94
00628     Inputs:     pAttr - pointer to the AttributeValue to copy.
00629     Purpose:    See AttributeValue::SimpleCopy
00630     SeeAlso:    BevelAttributeValueIndent; RenderStack; AttributeValue; NodeAttribute;
00631                 BevelAttributeValueIndent::Render; BevelAttributeValueIndent::Restore;
00632                 AttributeValue::Render; AttributeValue::Restore; AttributeValue::SimpleCopy
00633 
00634 ********************************************************************************************/
00635 
00636 void BevelAttributeValueIndent::SimpleCopy(AttributeValue *pValue)
00637 {
00638     m_Indent = ((BevelAttributeValueIndent *) pValue)->m_Indent;
00639 }
00640 
00641 /********************************************************************************************
00642 
00643 >   BOOL BevelAttributeValueIndent::Init()
00644 
00645     Author:     Tim_Browse (Xara Group Ltd) <camelotdev@xara.com>
00646     Created:    11/04/94
00647     Returns:    TRUE - initialised ok; FALSE if not.
00648     Purpose:    Registers line width attribute, and provides a default attribute to give
00649                 0.25pt lines.
00650     Errors:     Out of memory.
00651     SeeAlso:    AttributeManager
00652 
00653 ********************************************************************************************/
00654 
00655 BOOL BevelAttributeValueIndent::Init()
00656 {
00657     BevelAttributeValueIndent *pAttr = new BevelAttributeValueIndent;
00658     if (pAttr == NULL)
00659         return FALSE;
00660 
00661     UINT32 ID = AttributeManager::RegisterDefaultAttribute(CC_RUNTIME_CLASS(NodeRenderableInk), 
00662                                                          pAttr);
00663     if (ID == ATTR_BAD_ID)
00664         return FALSE;
00665     ENSURE(ID == ATTR_BEVELINDENT, "Incorrect ID for attribute!");
00666     return TRUE;
00667 }
00668 
00669 /********************************************************************************************
00670 
00671 >   NodeAttribute *BevelAttributeValueIndent::MakeNode()
00672 
00673     Author:     Tim_Browse (Xara Group Ltd) <camelotdev@xara.com>
00674     Created:    11/04/94
00675     Returns:    Pointer to the new node, or NULL if out of memory.
00676     Purpose:    Make a AttrbValue node from this line width attribute.
00677     Errors:     Out of memory
00678     SeeAlso:    AttributeValue::MakeNode
00679 
00680 ********************************************************************************************/
00681 
00682 NodeAttribute *BevelAttributeValueIndent::MakeNode()
00683 {
00684     // Create new attribute node
00685     AttrBevelIndent *pAttr = new AttrBevelIndent();
00686 
00687     // Copy attribute value into the new node.
00688     pAttr->Value.SimpleCopy(this);
00689 
00690     // Return the new node
00691     return pAttr;
00692 }
00693 
00694 /********************************************************************************************
00695 
00696 >   BOOL BevelAttributeValueIndent::IsDifferent(AttributeValue *pAttr)
00697 
00698     Author:     Tim_Browse (Xara Group Ltd) <camelotdev@xara.com>
00699     Created:    12/04/94
00700     Purpose:    See base class version.
00701     Errors:     The two attributes are not of the same type.
00702     SeeAlso:    AttributeValue::IsDifferent
00703 
00704 ********************************************************************************************/
00705 
00706 BOOL BevelAttributeValueIndent::IsDifferent(AttributeValue *pAttr)
00707 {
00708     ENSURE(GetRuntimeClass() == pAttr->GetRuntimeClass(), 
00709            "Different attribute types in AttributeValue::IsDifferent()");
00710     return ((BevelAttributeValueIndent *) pAttr)->m_Indent != m_Indent;
00711 }
00712 
00713 /********************************************************************************************
00714 
00715 >   AttrBevelContrast::AttrBevelContrast(Node* ContextNode,  
00716                     AttachNodeDirection Direction,  
00717                     BOOL Locked, 
00718                     BOOL Mangled,  
00719                     BOOL Marked, 
00720                     BOOL Selected    
00721             ): NodeAttribute(ContextNode, Direction, Locked, Mangled, Marked, Selected, TRUE)  
00722 
00723     Author:     Will_Cowling (Xara Group Ltd) <camelotdev@xara.com>
00724     Created:    21/6/93
00725     Inputs:     -
00726     Outputs:    -
00727     Returns:    -
00728     Purpose:    Creates a bValue Attribute
00729     Errors:     -
00730     SeeAlso:    -
00731 
00732 ********************************************************************************************/
00733 
00734 AttrBevelContrast::AttrBevelContrast(Node* ContextNode,  
00735                     AttachNodeDirection Direction,  
00736                     BOOL Locked, 
00737                     BOOL Mangled,  
00738                     BOOL Marked, 
00739                     BOOL Selected    
00740             ): AttrBevel(ContextNode, Direction, Locked, Mangled, Marked, Selected)  
00741 {                         
00742 } 
00743 
00744 /********************************************************************************************
00745 
00746 >   AttrBevelContrast::AttrBevelContrast()
00747 
00748     Author:     Will_Cowling (Xara Group Ltd) <camelotdev@xara.com>
00749     Created:    21/6/93
00750     Inputs:     -
00751     Outputs:    -
00752     Returns:    -
00753     Purpose:    Default constructor for Line Width Attribute class
00754     Errors:     -
00755     SeeAlso:    -
00756 
00757 ********************************************************************************************/
00758 
00759 AttrBevelContrast::AttrBevelContrast()
00760 {
00761 }
00762 
00763 
00764 /********************************************************************************************
00765 
00766 >   void AttrBevelContrast::Render( RenderRegion* pRender)
00767 
00768     Author:     Will_Cowling (Xara Group Ltd) <camelotdev@xara.com>
00769     Created:    21/6/93
00770     Inputs:     -
00771     Outputs:    -
00772     Returns:    -
00773     Purpose:    'Renders' a Line Width attribute.
00774     Errors:     -
00775     SeeAlso:    -
00776 
00777 ********************************************************************************************/
00778 
00779 void AttrBevelContrast::Render( RenderRegion* pRender)
00780 {
00781 }
00782 
00783 /********************************************************************************************
00784 
00785 >   void AttrBevelContrast::Transform( TransformBase& Trans )
00786 
00787     Author:     Will_Cowling (Xara Group Ltd) <camelotdev@xara.com>
00788     Created:    1/8/94
00789     Inputs:     Trans - the transform object to apply to this attribute.
00790     Purpose:    Scale the Line Width.
00791     SeeAlso:    NodeRenderable::Transform
00792 
00793 ********************************************************************************************/
00794 
00795 void AttrBevelContrast::Transform( TransformBase& Trans )
00796 {
00797     
00798 }
00799 
00800 /***********************************************************************************************
00801 > Node* AttrBevelContrast::SimpleCopy() 
00802 
00803     Author:     Will_Cowling (Xara Group Ltd) <camelotdev@xara.com>
00804     Created:    21/6/93
00805     
00806     Inputs:         - 
00807     Outputs:     
00808     Returns:    A copy of the node, or NULL if memory runs out 
00809          
00810     Purpose:    This method returns a shallow copy of the node with all Node pointers NULL. 
00811                 The function is virtual, and must be defined for all derived classes.  
00812 
00813     Errors:     If memory runs out when trying to copy, then ERROR is called with an out of memory
00814                 error and the function returns NULL. 
00815     
00816     Scope:      protected       
00817 ***********************************************************************************************/
00818      
00819 Node* AttrBevelContrast::SimpleCopy()
00820 {
00821     AttrBevelContrast* NodeCopy = new AttrBevelContrast();
00822     ERRORIF(NodeCopy == NULL, _R(IDE_NOMORE_MEMORY), NULL); 
00823     CopyNodeContents(NodeCopy);
00824     NodeCopy->Value.m_Contrast = Value.m_Contrast;
00825     return NodeCopy;
00826 } 
00827 
00828 /********************************************************************************************
00829 
00830 >   INT32 AttrBevelContrast::operator==(const NodeAttribute& Attrib)
00831 
00832     Author:     Simon_Maneggio (Xara Group Ltd) <camelotdev@xara.com>
00833     Created:    9/2/94
00834     Inputs:     Atrib:  The attribute to compare, which must be an AttrBevelContrast 
00835     Outputs:    -
00836     Returns:    -
00837     Purpose:    A virtual comparison operator. See NodeAttribute::operator== for 
00838                 a description of why it's required. 
00839  
00840     Errors:     An ENSURE failure will occur if Attrib does not have a AttrBevelContrast 
00841                 runtime class.
00842                  
00843     SeeAlso:    NodeAttribute::operator==
00844 
00845 ********************************************************************************************/
00846 
00847 INT32 AttrBevelContrast::operator==(const NodeAttribute& Attrib)
00848 {
00849     ENSURE(Attrib.IsKindOf(CC_RUNTIME_CLASS(AttrBevelContrast)), 
00850         "Trying to compare two objects with different types"); 
00851     AttrBevelContrast * Attr = (AttrBevelContrast *) &Attrib;
00852     return (Attr->Value.m_Contrast == Value.m_Contrast); 
00853 } 
00854 
00855 
00856 /********************************************************************************************
00857 
00858 >   virtual UINT32 AttrBevelContrast::GetAttrNameID(void)  
00859 
00860     Author:     Simon_Maneggio (Xara Group Ltd) <camelotdev@xara.com>
00861     Created:    22/2/94
00862     Inputs:     -
00863     Outputs:    -
00864     Returns:    Attribute description ID
00865     Purpose:    Returns back a string resource ID describing the attribute
00866 
00867     Errors:     -
00868     SeeAlso:    -
00869 
00870 ********************************************************************************************/
00871 
00872 UINT32 AttrBevelContrast::GetAttrNameID(void)  
00873 {
00874     return (_R(IDS_BEVEL_CONTRAST_ID)); 
00875 }               
00876                  
00877 
00878 /***********************************************************************************************
00879 > ` void AttrBevel::CopyNodeContents( AttrBevelContrast* NodeCopy)
00880 
00881     Author:     Simon_Maneggio (Xara Group Ltd) <camelotdev@xara.com>
00882     Created:    28/4/93
00883     
00884     Inputs:           
00885     Outputs:    A copy of this node
00886     Returns:    -
00887          
00888     Purpose:    This method copies the node's contents to the node pointed to by NodeCopy.
00889               
00890     Errors:     An assertion failure will occur if NodeCopy is NULL
00891     
00892     Scope:      protected
00893                                      
00894 ***********************************************************************************************/
00895 
00896 void AttrBevelContrast::CopyNodeContents( AttrBevelContrast* NodeCopy)
00897 {
00898     NodeAttribute::CopyNodeContents( NodeCopy );
00899 
00900     NodeCopy->Value = Value;
00901 } 
00902 
00903 /***********************************************************************************************
00904 >   void AttrBevelContrast::PolyCopyNodeContents(NodeRenderable* pNodeCopy)
00905 
00906     Author:     Phil_Martin (Xara Group Ltd) <camelotdev@xara.com>
00907     Created:    18/12/2003
00908     Outputs:    -
00909     Purpose:    Polymorphically copies the contents of this node to another
00910     Errors:     An assertion failure will occur if NodeCopy is NULL
00911     Scope:      protected
00912                                      
00913 ***********************************************************************************************/
00914 
00915 void AttrBevelContrast::PolyCopyNodeContents(NodeRenderable* pNodeCopy)
00916 {
00917     ENSURE(pNodeCopy, "Trying to copy a node's contents into a NULL node");
00918     ENSURE(IS_A(pNodeCopy, AttrBevelContrast), "PolyCopyNodeContents given wrong dest node type");
00919 
00920     if (IS_A(pNodeCopy, AttrBevelContrast))
00921         CopyNodeContents((AttrBevelContrast*)pNodeCopy);
00922 }
00923 
00924 
00925 
00926 /********************************************************************************************
00927 
00928 >   BOOL AttrBevelContrast::Blend(BlendAttrParam* pBlendParam)
00929 
00930     Author:     David_McClarnon (Xara Group Ltd) <camelotdev@xara.com>
00931     Created:    12/12/99
00932     Inputs:     The blend attribute param
00933     Purpose:    Blends this light angle to another
00934     SeeAlso:    
00935 
00936 ********************************************************************************************/
00937 BOOL AttrBevelContrast::Blend(BlendAttrParam* pBlendParam)
00938 {
00939     ERROR2IF(pBlendParam == NULL,FALSE,"pBlendParam == NULL");
00940     ERROR3IF(!(pBlendParam->GetOtherAttr()->IS_KIND_OF(AttrBevelContrast)),
00941         "Blend attribute isn't a bevel contrast attribute");
00942 
00943     AttrBevelContrast * pBlendedAttr = NULL;
00944 
00945     // assign the other attribute we're looking at
00946     AttrBevelContrast * pOtherAttr = (AttrBevelContrast *)pBlendParam->GetOtherAttr();
00947 
00948     // split at the half way mark
00949     if (pBlendParam->GetBlendRatio() <= 0.5)
00950     {
00951         pBlendedAttr = (AttrBevelContrast *)SimpleCopy();
00952     }
00953     else
00954     {
00955         pBlendedAttr = (AttrBevelContrast *)pOtherAttr->SimpleCopy();
00956     }
00957 
00958     // set the blended attribute
00959     pBlendParam->SetBlendedAttr(pBlendedAttr);
00960     
00961     if (!pBlendedAttr)
00962         return FALSE;
00963 
00964     double Contrast1        = Value.m_Contrast;
00965     double Contrast2        = pOtherAttr->Value.m_Contrast;
00966     double NewContrast      = ((Contrast2 - Contrast1) * pBlendParam->GetBlendRatio()) +
00967                                 Contrast1;
00968 
00969     // set the blended attribute's values
00970     pBlendedAttr->Value.m_Contrast = (INT32)NewContrast;
00971 
00972     return TRUE;
00973 }
00974 
00975 
00976 /***********************************************************************************************
00977 
00978 >   void AttrBevelContrast::ShowDebugTreeDetails() const
00979 
00980     Author:     Will_Cowling (Xara Group Ltd) <camelotdev@xara.com>
00981     Created:    21/6/93
00982     Purpose:    Displays debugging info of the tree
00983 
00984 ***********************************************************************************************/
00985 
00986 void AttrBevelContrast::ShowDebugTreeDetails() const
00987 {
00988     // Display a bit of debugging info
00989     // For now, we will just call the base class version
00990 #ifdef _DEBUG
00991     NodeAttribute::ShowDebugTreeDetails();  
00992 #endif
00993 }
00994 
00995 
00996 void AttrBevelContrast::GetDebugDetails(StringBase* Str)
00997 {
00998 #ifdef _DEBUG
00999     NodeAttribute::GetDebugDetails( Str );
01000 
01001     String_256 TempStr;
01002     TempStr._MakeMsg( TEXT("\r\nValue=#1%d\r\n"), Value.m_Contrast );
01003     (*Str)+= TempStr;
01004 #else
01005     if (Str)
01006     {
01007         *Str = wxT("");
01008     }
01009 #endif
01010 }
01011 
01012 
01013 /********************************************************************************************
01014 
01015 >   virtual UINT32 AttrBevelContrast::GetNodeSize() const
01016 
01017     Author:     Simon_Maneggio (Xara Group Ltd) <camelotdev@xara.com>
01018     Created:    6/10/93
01019     Inputs:     -
01020     Outputs:    -
01021     Returns:    The size of the node in bytes
01022     Purpose:    For finding the size of the node 
01023                 
01024     SeeAlso:    Node::GetSubtreeSize
01025 
01026 ********************************************************************************************/
01027 
01028 UINT32 AttrBevelContrast::GetNodeSize() const 
01029 {     
01030     return (sizeof(AttrBevelContrast)); 
01031 }  
01032 
01033 /********************************************************************************************
01034 
01035   > virtual BOOL AttrBevelContrast::WritePreChildrenWeb(BaseCamelotFilter* pFilter)
01036 
01037     Author:     Mark_Neves (Xara Group Ltd) <camelotdev@xara.com>
01038     Created:    30/5/96
01039     Inputs:     pFilter = ptr to the filter
01040     Returns:    TRUE if record is written, FALSE if not
01041     Purpose:    Writes the line width record to the filter
01042     SeeAlso:    -
01043 
01044 ********************************************************************************************/
01045 
01046 BOOL AttrBevelContrast::WritePreChildrenWeb(BaseCamelotFilter* pFilter)
01047 {
01048     return TRUE;
01049 }
01050 
01051 //--------------------------------------------------------------
01052 // See AttrBevelContrast::WritePreChildrenWeb(BaseCamelotFilter* pFilter)
01053 //
01054 BOOL AttrBevelContrast::WritePreChildrenNative(BaseCamelotFilter* pFilter)
01055 {
01056 #ifdef DO_EXPORT
01057     return WritePreChildrenWeb(pFilter);
01058 #else
01059     return FALSE;
01060 #endif
01061 }
01062 
01064 // the actual attribute
01065 
01066 BevelAttributeValueContrast::BevelAttributeValueContrast()
01067 {
01068     m_Contrast = 50;
01069 }
01070 
01071 /********************************************************************************************
01072 
01073 >   void BevelAttributeValueContrast::Render(RenderRegion *pRegion)
01074 
01075     Author:     Tim_Browse (Xara Group Ltd) <camelotdev@xara.com>
01076     Created:    03/02/94
01077     Inputs:     pRegion - the render region to render this attribute into.
01078     Purpose:    Sets the line width attribute for the given render region. i.e. all
01079                 lines drawn will now be drawn with this line width.
01080     SeeAlso:    BevelAttributeValueContrast; RenderStack; AttributeValue; NodeAttribute;
01081                 BevelAttributeValueContrast::Restore; BevelAttributeValueContrast::SimpleCopy;
01082                 AttributeValue::Render; AttributeValue::Restore; AttributeValue::SimpleCopy
01083 
01084 ********************************************************************************************/
01085 
01086 void BevelAttributeValueContrast::Render(RenderRegion *pRegion, BOOL Temp)
01087 {
01088 }
01089 
01090 /********************************************************************************************
01091 
01092 >   void BevelAttributeValueContrast::Restore(RenderRegion *pRegion, BOOL Temp)
01093 
01094     Author:     Tim_Browse (Xara Group Ltd) <camelotdev@xara.com>
01095     Created:    03/02/94
01096     Inputs:     pRegion - the render region to restore the attribute into.
01097                 Temp    - TRUE if this is a temporary attribute, FALSE if it is
01098                           permanent (e.g. it's in a document tree).
01099     Purpose:    Restores the line width attribute for the given render region. i.e. all
01100                 lines drawn will now be drawn with this line width.
01101     SeeAlso:    BevelAttributeValueContrast; RenderStack; AttributeValue; NodeAttribute;
01102                 BevelAttributeValueContrast::Render; BevelAttributeValueContrast::SimpleCopy;
01103                 AttributeValue::Render; AttributeValue::Restore; AttributeValue::SimpleCopy
01104 
01105 ********************************************************************************************/
01106 
01107 void BevelAttributeValueContrast::Restore(RenderRegion *pRegion, BOOL Temp)
01108 {
01109 }
01110 
01111 /********************************************************************************************
01112 
01113 >   void BevelAttributeValueContrast::SimpleCopy(AttributeValue *pValue)
01114 
01115     Author:     Tim_Browse (Xara Group Ltd) <camelotdev@xara.com>
01116     Created:    03/02/94
01117     Inputs:     pAttr - pointer to the AttributeValue to copy.
01118     Purpose:    See AttributeValue::SimpleCopy
01119     SeeAlso:    BevelAttributeValueContrast; RenderStack; AttributeValue; NodeAttribute;
01120                 BevelAttributeValueContrast::Render; BevelAttributeValueContrast::Restore;
01121                 AttributeValue::Render; AttributeValue::Restore; AttributeValue::SimpleCopy
01122 
01123 ********************************************************************************************/
01124 
01125 void BevelAttributeValueContrast::SimpleCopy(AttributeValue *pValue)
01126 {
01127     m_Contrast = ((BevelAttributeValueContrast *) pValue)->m_Contrast;
01128 }
01129 
01130 /********************************************************************************************
01131 
01132 >   BOOL BevelAttributeValueContrast::Init()
01133 
01134     Author:     Tim_Browse (Xara Group Ltd) <camelotdev@xara.com>
01135     Created:    11/04/94
01136     Returns:    TRUE - initialised ok; FALSE if not.
01137     Purpose:    Registers line width attribute, and provides a default attribute to give
01138                 0.25pt lines.
01139     Errors:     Out of memory.
01140     SeeAlso:    AttributeManager
01141 
01142 ********************************************************************************************/
01143 
01144 BOOL BevelAttributeValueContrast::Init()
01145 {
01146     BevelAttributeValueContrast *pAttr = new BevelAttributeValueContrast;
01147     if (pAttr == NULL)
01148         return FALSE;
01149 
01150     UINT32 ID = AttributeManager::RegisterDefaultAttribute(CC_RUNTIME_CLASS(NodeRenderableInk), 
01151                                                          pAttr);
01152     if (ID == ATTR_BAD_ID)
01153         return FALSE;
01154     ENSURE(ID == ATTR_BEVELCONTRAST, "Incorrect ID for attribute!");
01155     return TRUE;
01156 }
01157 
01158 /********************************************************************************************
01159 
01160 >   NodeAttribute *BevelAttributeValueContrast::MakeNode()
01161 
01162     Author:     Tim_Browse (Xara Group Ltd) <camelotdev@xara.com>
01163     Created:    11/04/94
01164     Returns:    Pointer to the new node, or NULL if out of memory.
01165     Purpose:    Make a AttrbValue node from this line width attribute.
01166     Errors:     Out of memory
01167     SeeAlso:    AttributeValue::MakeNode
01168 
01169 ********************************************************************************************/
01170 
01171 NodeAttribute *BevelAttributeValueContrast::MakeNode()
01172 {
01173     // Create new attribute node
01174     AttrBevelContrast *pAttr = new AttrBevelContrast();
01175 
01176     // Copy attribute value into the new node.
01177     pAttr->Value.SimpleCopy(this);
01178 
01179     // Return the new node
01180     return pAttr;
01181 }
01182 
01183 /********************************************************************************************
01184 
01185 >   BOOL BevelAttributeValueContrast::IsDifferent(AttributeValue *pAttr)
01186 
01187     Author:     Tim_Browse (Xara Group Ltd) <camelotdev@xara.com>
01188     Created:    12/04/94
01189     Purpose:    See base class version.
01190     Errors:     The two attributes are not of the same type.
01191     SeeAlso:    AttributeValue::IsDifferent
01192 
01193 ********************************************************************************************/
01194 
01195 BOOL BevelAttributeValueContrast::IsDifferent(AttributeValue *pAttr)
01196 {
01197     ENSURE(GetRuntimeClass() == pAttr->GetRuntimeClass(), 
01198            "Different attribute types in AttributeValue::IsDifferent()");
01199     return ((BevelAttributeValueContrast *) pAttr)->m_Contrast != m_Contrast;
01200 }
01201 
01202 /********************************************************************************************
01203 
01204 >   AttrBevelType::AttrBevelType(Node* ContextNode,  
01205                     AttachNodeDirection Direction,  
01206                     BOOL Locked, 
01207                     BOOL Mangled,  
01208                     BOOL Marked, 
01209                     BOOL Selected    
01210             ): NodeAttribute(ContextNode, Direction, Locked, Mangled, Marked, Selected, TRUE)  
01211 
01212     Author:     Will_Cowling (Xara Group Ltd) <camelotdev@xara.com>
01213     Created:    21/6/93
01214     Inputs:     -
01215     Outputs:    -
01216     Returns:    -
01217     Purpose:    Creates a bValue Attribute
01218     Errors:     -
01219     SeeAlso:    -
01220 
01221 ********************************************************************************************/
01222 
01223 AttrBevelType::AttrBevelType(Node* ContextNode,  
01224                     AttachNodeDirection Direction,  
01225                     BOOL Locked, 
01226                     BOOL Mangled,  
01227                     BOOL Marked, 
01228                     BOOL Selected    
01229             ): AttrBevel(ContextNode, Direction, Locked, Mangled, Marked, Selected)  
01230 {                         
01231 } 
01232 
01233 /********************************************************************************************
01234 
01235 >   AttrBevelType::AttrBevelType()
01236 
01237     Author:     Will_Cowling (Xara Group Ltd) <camelotdev@xara.com>
01238     Created:    21/6/93
01239     Inputs:     -
01240     Outputs:    -
01241     Returns:    -
01242     Purpose:    Default constructor for Line Width Attribute class
01243     Errors:     -
01244     SeeAlso:    -
01245 
01246 ********************************************************************************************/
01247 
01248 AttrBevelType::AttrBevelType()
01249 {
01250 }
01251 
01252 /********************************************************************************************
01253 
01254 >   void AttrBevelType::Render( RenderRegion* pRender)
01255 
01256     Author:     Will_Cowling (Xara Group Ltd) <camelotdev@xara.com>
01257     Created:    21/6/93
01258     Inputs:     -
01259     Outputs:    -
01260     Returns:    -
01261     Purpose:    'Renders' a Line Width attribute.
01262     Errors:     -
01263     SeeAlso:    -
01264 
01265 ********************************************************************************************/
01266 
01267 void AttrBevelType::Render( RenderRegion* pRender)
01268 {
01269 }
01270 
01271 
01272 /********************************************************************************************
01273 
01274 >   void AttrBevelType::Transform( TransformBase& Trans )
01275 
01276     Author:     Will_Cowling (Xara Group Ltd) <camelotdev@xara.com>
01277     Created:    1/8/94
01278     Inputs:     Trans - the transform object to apply to this attribute.
01279     Purpose:    Scale the Line Width.
01280     SeeAlso:    NodeRenderable::Transform
01281 
01282 ********************************************************************************************/
01283 
01284 void AttrBevelType::Transform( TransformBase& Trans )
01285 {
01286     
01287 }
01288 
01289 /***********************************************************************************************
01290 > Node* AttrBevelType::SimpleCopy() 
01291 
01292     Author:     Will_Cowling (Xara Group Ltd) <camelotdev@xara.com>
01293     Created:    21/6/93
01294     
01295     Inputs:         - 
01296     Outputs:     
01297     Returns:    A copy of the node, or NULL if memory runs out 
01298          
01299     Purpose:    This method returns a shallow copy of the node with all Node pointers NULL. 
01300                 The function is virtual, and must be defined for all derived classes.  
01301 
01302     Errors:     If memory runs out when trying to copy, then ERROR is called with an out of memory
01303                 error and the function returns NULL. 
01304     
01305     Scope:      protected       
01306 ***********************************************************************************************/
01307      
01308 Node* AttrBevelType::SimpleCopy()
01309 {
01310     AttrBevelType* NodeCopy = new AttrBevelType();
01311     ERRORIF(NodeCopy == NULL, _R(IDE_NOMORE_MEMORY), NULL); 
01312     CopyNodeContents(NodeCopy);
01313     NodeCopy->Value.SimpleCopy(&Value);
01314     return NodeCopy;
01315 } 
01316 
01317 /********************************************************************************************
01318 
01319 >   INT32 AttrBevelType::operator==(const NodeAttribute& Attrib)
01320 
01321     Author:     Simon_Maneggio (Xara Group Ltd) <camelotdev@xara.com>
01322     Created:    9/2/94
01323     Inputs:     Atrib:  The attribute to compare, which must be an AttrBevelType 
01324     Outputs:    -
01325     Returns:    -
01326     Purpose:    A virtual comparison operator. See NodeAttribute::operator== for 
01327                 a description of why it's required. 
01328  
01329     Errors:     An ENSURE failure will occur if Attrib does not have a AttrBevelType 
01330                 runtime class.
01331                  
01332     SeeAlso:    NodeAttribute::operator==
01333 
01334 ********************************************************************************************/
01335 
01336 INT32 AttrBevelType::operator==(const NodeAttribute& Attrib)
01337 {
01338     ENSURE(Attrib.IsKindOf(CC_RUNTIME_CLASS(AttrBevelType)), 
01339         "Trying to compare two objects with different types"); 
01340     AttrBevelType * Attr = (AttrBevelType *) &Attrib;
01341 
01342     if (Attr->Value.IsDifferent(&Value))
01343     {
01344         return FALSE;
01345     }
01346 
01347     return TRUE; 
01348     
01349 } 
01350 
01351 
01352 /********************************************************************************************
01353 
01354 >   virtual UINT32 AttrBevelType::GetAttrNameID(void)  
01355 
01356     Author:     Simon_Maneggio (Xara Group Ltd) <camelotdev@xara.com>
01357     Created:    22/2/94
01358     Inputs:     -
01359     Outputs:    -
01360     Returns:    Attribute description ID
01361     Purpose:    Returns back a string resource ID describing the attribute
01362 
01363     Errors:     -
01364     SeeAlso:    -
01365 
01366 ********************************************************************************************/
01367 
01368 UINT32 AttrBevelType::GetAttrNameID(void)  
01369 {
01370     return (_R(IDS_BEVEL_TYPE_ID)); 
01371 }               
01372                  
01373 
01374 /***********************************************************************************************
01375 > ` void AttrBevel::CopyNodeContents( AttrBevelType* NodeCopy)
01376 
01377     Author:     Simon_Maneggio (Xara Group Ltd) <camelotdev@xara.com>
01378     Created:    28/4/93
01379     
01380     Inputs:           
01381     Outputs:    A copy of this node
01382     Returns:    -
01383          
01384     Purpose:    This method copies the node's contents to the node pointed to by NodeCopy.
01385               
01386     Errors:     An assertion failure will occur if NodeCopy is NULL
01387     
01388     Scope:      protected
01389                                      
01390 ***********************************************************************************************/
01391 
01392 void AttrBevelType::CopyNodeContents( AttrBevelType* NodeCopy)
01393 {
01394     NodeAttribute::CopyNodeContents( NodeCopy );
01395 
01396     NodeCopy->Value.SimpleCopy(&Value);
01397 } 
01398 
01399 /***********************************************************************************************
01400 >   void AttrBevelContrast::PolyCopyNodeContents(NodeRenderable* pNodeCopy)
01401 
01402     Author:     Phil_Martin (Xara Group Ltd) <camelotdev@xara.com>
01403     Created:    18/12/2003
01404     Outputs:    -
01405     Purpose:    Polymorphically copies the contents of this node to another
01406     Errors:     An assertion failure will occur if NodeCopy is NULL
01407     Scope:      protected
01408                                      
01409 ***********************************************************************************************/
01410 
01411 void AttrBevelType::PolyCopyNodeContents(NodeRenderable* pNodeCopy)
01412 {
01413     ENSURE(pNodeCopy, "Trying to copy a node's contents into a NULL node");
01414     ENSURE(IS_A(pNodeCopy, AttrBevelType), "PolyCopyNodeContents given wrong dest node type");
01415 
01416     if (IS_A(pNodeCopy, AttrBevelType))
01417         CopyNodeContents((AttrBevelType*)pNodeCopy);
01418 }
01419 
01420 
01421 
01422 /***********************************************************************************************
01423 
01424 >   void AttrBevelType::ShowDebugTreeDetails() const
01425 
01426     Author:     Will_Cowling (Xara Group Ltd) <camelotdev@xara.com>
01427     Created:    21/6/93
01428     Purpose:    Displays debugging info of the tree
01429 
01430 ***********************************************************************************************/
01431 
01432 void AttrBevelType::ShowDebugTreeDetails() const
01433 {
01434     // Display a bit of debugging info
01435     // For now, we will just call the base class version
01436 #ifdef _DEBUG
01437     NodeAttribute::ShowDebugTreeDetails();  
01438 #endif
01439 }
01440 
01441 
01442 void AttrBevelType::GetDebugDetails(StringBase* Str)
01443 {
01444 #ifdef _DEBUG
01445     if (!Str)
01446         return ;
01447 
01448     NodeAttribute::GetDebugDetails( Str );
01449     String_256 TempStr;
01450     TempStr._MakeMsg( TEXT("\r\nValue=#1%d\r\n"), Value.m_Type );
01451     (*Str) += TempStr;
01452 #else
01453     if (Str)
01454     {
01455         *Str = wxT("");
01456     }
01457 #endif
01458 }
01459 
01460 /***********************************************************************************************
01461 
01462 >   DocRect AttrBevelType::GetAttrBoundingRect(NodeRenderableInk* pParent, 
01463                         CCAttrMap* pAttribMap)
01464 
01465     Author:     David_McClarnon (Xara Group Ltd) <camelotdev@xara.com>
01466     Created:    17/12/99
01467     Purpose:    Gets the bounding rect of this attribute
01468 ***********************************************************************************************/
01469 DocRect AttrBevelType::GetAttrBoundingRect(NodeRenderableInk* pParent, CCAttrMap* pAttribMap)
01470 {
01471     if (!pParent)
01472         return DocRect(0,0,0,0);
01473     
01474     if (!Value.m_bPassback)
01475         return pParent->GetBoundingRect(TRUE, FALSE);
01476 
01477     DocRect dr = pParent->GetBoundingRect(TRUE, FALSE);
01478 
01479     if (Value.GetIndent() < 0)
01480     {
01481         dr.Inflate(-Value.GetIndent());
01482     }
01483 
01484     return dr;
01485 }
01486 
01487 
01488 /********************************************************************************************
01489 
01490 >   virtual UINT32 AttrBevelType::GetNodeSize() const
01491 
01492     Author:     Simon_Maneggio (Xara Group Ltd) <camelotdev@xara.com>
01493     Created:    6/10/93
01494     Inputs:     -
01495     Outputs:    -
01496     Returns:    The size of the node in bytes
01497     Purpose:    For finding the size of the node 
01498                 
01499     SeeAlso:    Node::GetSubtreeSize
01500 
01501 ********************************************************************************************/
01502 
01503 UINT32 AttrBevelType::GetNodeSize() const 
01504 {     
01505     return (sizeof(AttrBevelType)); 
01506 }  
01507 
01508 /********************************************************************************************
01509 
01510 >   BOOL AttrBevelType::Blend(BlendAttrParam* pBlendParam)
01511 
01512     Author:     David_McClarnon (Xara Group Ltd) <camelotdev@xara.com>
01513     Created:    12/12/99
01514     Inputs:     The blend attribute param
01515     Purpose:    Blends this light angle to another
01516     SeeAlso:    
01517 
01518 ********************************************************************************************/
01519 BOOL AttrBevelType::Blend(BlendAttrParam* pBlendParam)
01520 {
01521     ERROR2IF(pBlendParam == NULL,FALSE,"pBlendParam == NULL");
01522     ERROR3IF(!(pBlendParam->GetOtherAttr()->IS_KIND_OF(AttrBevelType)),
01523         "Blend attribute isn't a bevel type attribute");
01524 
01525     AttrBevelType * pBlendedAttr = NULL;
01526 
01527     // assign the other attribute we're looking at
01528     AttrBevelType * pOtherAttr = (AttrBevelType *)pBlendParam->GetOtherAttr();
01529 
01530     // split at the half way mark
01531     if (pBlendParam->GetBlendRatio() <= 0.5)
01532     {
01533         pBlendedAttr = (AttrBevelType *)SimpleCopy();
01534     }
01535     else
01536     {
01537         pBlendedAttr = (AttrBevelType *)pOtherAttr->SimpleCopy();
01538     }
01539 
01540     if (!pBlendedAttr)
01541         return FALSE;
01542 
01543     // set the blended attribute
01544     pBlendParam->SetBlendedAttr(pBlendedAttr);
01545 
01546     return TRUE;
01547 }
01548 
01549 /********************************************************************************************
01550 
01551 >   virtual BOOL AttrBevelType::CanBecomeA(BecomeA* pBecomeA)
01552 
01553     Author:     David_McClarnon (Xara Group Ltd) <camelotdev@xara.com> 
01554     Created:    17/12/99
01555     Inputs:     pClass  -   the class to convert this to
01556                 pNumObjects -  returns the number of objects this is converted into
01557     Returns:    TRUE if we can do the change, FALSE if otherwise
01558     Purpose:    Informs whether this node can be changed into another node or not
01559     SeeAlso:    -
01560 
01561 ********************************************************************************************/
01562 BOOL AttrBevelType::CanBecomeA(BecomeA* pBecomeA)
01563 {
01564     if (!Value.m_bPassback)
01565         return FALSE;
01566 
01567     if (pBecomeA->BAPath())
01568     {
01569         pBecomeA->AddCount(1);
01570         return TRUE;
01571     }
01572 
01573     return FALSE;
01574 }
01575 
01576 /********************************************************************************************
01577 
01578 >   virtual BOOL AttrBevelType::DoBecomeA(BecomeA* pBecomeA)
01579 
01580     Author:     David_McClarnon (Xara Group Ltd) <camelotdev@xara.com> 
01581     Created:    17/12/99
01582     Inputs:     pBecomeA    -  The become A structure to use
01583     Returns:    TRUE if we can do the change, FALSE if otherwise
01584     Purpose:    Changes this node into something else, maybe even altering the original
01585                 node
01586     SeeAlso:    -
01587 
01588 ********************************************************************************************/
01589 BOOL AttrBevelType::DoBecomeA(BecomeA* pBecomeA)
01590 {
01591     return TRUE;
01592 }
01593 
01594 /********************************************************************************************
01595 
01596   > virtual BOOL AttrBevelType::WritePreChildrenWeb(BaseCamelotFilter* pFilter)
01597 
01598     Author:     Mark_Neves (Xara Group Ltd) <camelotdev@xara.com>
01599     Created:    30/5/96
01600     Inputs:     pFilter = ptr to the filter
01601     Returns:    TRUE if record is written, FALSE if not
01602     Purpose:    Writes the line width record to the filter
01603     SeeAlso:    -
01604 
01605 ********************************************************************************************/
01606 
01607 BOOL AttrBevelType::WritePreChildrenWeb(BaseCamelotFilter* pFilter)
01608 {
01609     return TRUE;
01610 }
01611 
01612 //--------------------------------------------------------------
01613 // See AttrBevelType::WritePreChildrenWeb(BaseCamelotFilter* pFilter)
01614 //
01615 BOOL AttrBevelType::WritePreChildrenNative(BaseCamelotFilter* pFilter)
01616 {
01617 #ifdef DO_EXPORT
01618     return WritePreChildrenWeb(pFilter);
01619 #else
01620     return FALSE;
01621 #endif
01622 }
01623 
01625 // the actual attribute
01626 
01627 BevelAttributeValueType::BevelAttributeValueType()
01628 {
01629     m_Type = -1;
01630     m_bPassback = FALSE;
01631     m_pProc = NULL;
01632 
01633     m_Indent = 0;
01634     m_LightAngle = 0;
01635     m_Contrast = 0;
01636 }
01637 
01638 BevelAttributeValueType::BevelAttributeValueType(INT32 Val)
01639 {
01640     m_Type = Val;
01641     m_bPassback = FALSE;
01642     m_pProc = NULL;
01643 
01644     m_Indent = 0;
01645     m_LightAngle = 0;
01646     m_Contrast = 0;
01647 }
01648 
01649 BevelAttributeValueType::~BevelAttributeValueType()
01650 {
01651     if (m_pProc)
01652     {
01653         delete m_pProc;
01654         m_pProc = NULL;
01655     }
01656 }
01657 
01658 /********************************************************************************************
01659 
01660 >   void BevelAttributeValueType::Render(RenderRegion *pRegion)
01661 
01662     Author:     Tim_Browse (Xara Group Ltd) <camelotdev@xara.com>
01663     Created:    03/02/94
01664     Inputs:     pRegion - the render region to render this attribute into.
01665     Purpose:    Sets the line width attribute for the given render region. i.e. all
01666                 lines drawn will now be drawn with this line width.
01667     SeeAlso:    BevelAttributeValueType; RenderStack; AttributeValue; NodeAttribute;
01668                 BevelAttributeValueType::Restore; BevelAttributeValueType::SimpleCopy;
01669                 AttributeValue::Render; AttributeValue::Restore; AttributeValue::SimpleCopy
01670 
01671 ********************************************************************************************/
01672 
01673 void BevelAttributeValueType::Render(RenderRegion *pRegion, BOOL Temp)
01674 {
01675 }
01676 
01677 /********************************************************************************************
01678 
01679 >   void BevelAttributeValueType::Restore(RenderRegion *pRegion, BOOL Temp)
01680 
01681     Author:     Tim_Browse (Xara Group Ltd) <camelotdev@xara.com>
01682     Created:    03/02/94
01683     Inputs:     pRegion - the render region to restore the attribute into.
01684                 Temp    - TRUE if this is a temporary attribute, FALSE if it is
01685                           permanent (e.g. it's in a document tree).
01686     Purpose:    Restores the line width attribute for the given render region. i.e. all
01687                 lines drawn will now be drawn with this line width.
01688     SeeAlso:    BevelAttributeValueType; RenderStack; AttributeValue; NodeAttribute;
01689                 BevelAttributeValueType::Render; BevelAttributeValueType::SimpleCopy;
01690                 AttributeValue::Render; AttributeValue::Restore; AttributeValue::SimpleCopy
01691 
01692 ********************************************************************************************/
01693 
01694 void BevelAttributeValueType::Restore(RenderRegion *pRegion, BOOL Temp)
01695 {
01696 }
01697 
01698 /********************************************************************************************
01699 
01700 >   void BevelAttributeValueType::GoingOutOfScope(RenderRegion * pRegion)
01701 
01702     Author:     David_McClarnon (Xara Group Ltd) <camelotdev@xara.com>
01703     Created:    12/12/99
01704     Inputs:     pRegion - the render region to render this attribute into.
01705     Purpose:    Enables this attribute to remove its path processor when it's restored
01706     SeeAlso:    BevelAttributeValueType; RenderStack; AttributeValue; NodeAttribute;
01707                 BevelAttributeValueType::Restore; BevelAttributeValueType::SimpleCopy;
01708                 AttributeValue::Render; AttributeValue::Restore; AttributeValue::SimpleCopy
01709 
01710 ********************************************************************************************/
01711 void BevelAttributeValueType::GoingOutOfScope(RenderRegion * pRegion)
01712 {
01713 }
01714 
01715 /********************************************************************************************
01716 
01717 >   KernelBitmap * BevelAttributeValueType::CreateBevelBitmap(RenderRegion * pRegion);
01718 
01719     Author:     David_McClarnon (Xara Group Ltd) <camelotdev@xara.com>
01720     Created:    12/12/99
01721     Inputs:     pRegion -   The render region to use
01722     Returns:    A new KernelBitmap with the bevel bitmap in it
01723                 NULL for failure
01724     Purpose:    Creates the bevel bitmap from the region
01725     SeeAlso:    
01726 
01727 ********************************************************************************************/
01728 KernelBitmap * BevelAttributeValueType::CreateBevelBitmap(RenderRegion * pRegion)
01729 {
01730     // get all the necessary variables out of the render region
01731     // set up the outer flag
01732     BOOL bOuter = FALSE;
01733                 
01734     if (m_Indent < 0)
01735         bOuter = TRUE;
01736                 
01737     // calculate the width & height of the bitmap necessary
01738     DocRect dr = m_pProc->GetSummedPath()->GetBoundingRect();
01739 
01740     if (bOuter)
01741     {
01742         dr.lo.x -= abs(m_Indent);
01743         dr.lo.y -= abs(m_Indent);
01744         dr.hi.x += abs(m_Indent);
01745         dr.hi.y += abs(m_Indent);
01746     }
01747 
01748     double lWidth = ((double)dr.Width()) / 750.0;
01749     double lHeight = ((double)dr.Height()) / 750.0;
01750 
01751     INT32 Width = (INT32)lWidth;
01752     INT32 Height = (INT32)lHeight;
01753                 
01754     // calculate the light angle vector
01755     double angle = m_LightAngle;
01756                 
01757     angle = (3.142 * angle) / 180;
01758             
01759     NormCoord LightAngle;
01760                 
01761     LightAngle.x = cos(angle);
01762     LightAngle.y = sin(angle);  
01763                 
01764     // calculate the light vector from the light angle attribute
01765                 
01766     // ok, build the bitmap for the bevel
01767     CBeveler Beveler(m_pProc->GetSummedPath());
01768     Beveler.SetBevelAngle(m_LightAngle);
01769     Beveler.SetBevelType(m_Type);
01770     BOOL Ok = Beveler.SetUpBeveler(abs(m_Indent), RoundJoin, &LightAngle, bOuter, 100, NULL, 200);
01771     Ok = Beveler.SetBevelerSize(Width,Height);
01772 
01773     return NULL;
01774 }
01775 
01776 /********************************************************************************************
01777 
01778 >   BOOL BevelAttributeValueType::RenderBitmap(RenderRegion * pRegion, 
01779                         KernelBitmap * pBitmap, Path * pSrcPath, Path * pRenderPath)
01780 
01781     Author:     David_McClarnon (Xara Group Ltd) <camelotdev@xara.com>
01782     Created:    12/12/99
01783     Inputs:     pRegion -   The render region to use
01784                 pBitmap -   The bitmap to render
01785                 pSrcPath      - The path to be bevelled
01786                 pRenderPath   - The path to use to render the bitmap
01787     Returns:    TRUE for success
01788     Purpose:    Renders the bevel bitmap using the given path
01789     SeeAlso:    
01790 
01791 ********************************************************************************************/
01792 BOOL BevelAttributeValueType::RenderBitmap(RenderRegion * pRegion, 
01793                         KernelBitmap * pBitmap, Path * pSrcPath, Path * pRenderPath)
01794 {
01795     return TRUE;
01796 }
01797 
01798 /********************************************************************************************
01799 
01800 >   void BevelAttributeValueType::SimpleCopy(AttributeValue *pValue)
01801 
01802     Author:     Tim_Browse (Xara Group Ltd) <camelotdev@xara.com>
01803     Created:    03/02/94
01804     Inputs:     pAttr - pointer to the AttributeValue to copy.
01805     Purpose:    See AttributeValue::SimpleCopy
01806     SeeAlso:    BevelAttributeValueType; RenderStack; AttributeValue; NodeAttribute;
01807                 BevelAttributeValueType::Render; BevelAttributeValueType::Restore;
01808                 AttributeValue::Render; AttributeValue::Restore; AttributeValue::SimpleCopy
01809 
01810 ********************************************************************************************/
01811 
01812 void BevelAttributeValueType::SimpleCopy(AttributeValue *pValue)
01813 {
01814     m_Type          = ((BevelAttributeValueType *) pValue)->m_Type;
01815     m_bPassback     = ((BevelAttributeValueType *) pValue)->m_bPassback;
01816     m_Indent        = ((BevelAttributeValueType *) pValue)->m_Indent;
01817     m_LightAngle    = ((BevelAttributeValueType *) pValue)->m_LightAngle;
01818     m_Contrast      = ((BevelAttributeValueType *) pValue)->m_Contrast;
01819 }
01820 
01821 /********************************************************************************************
01822 
01823 >   INT32 BevelAttributeValueType::operator=(AttributeValue& Attrib)
01824 
01825     Author:     David_McClarnon (Xara Group Ltd) <camelotdev@xara.com>
01826     Created:    13/12/99
01827     Inputs:     pAttr - pointer to the AttributeValue to copy.
01828     Purpose:    Equality operator
01829     SeeAlso:    
01830 
01831 ********************************************************************************************/
01832 
01833 INT32 BevelAttributeValueType::operator=(AttributeValue& Attrib)
01834 {
01835     SimpleCopy(&Attrib);
01836 
01837     return TRUE;
01838 }
01839 
01840 /********************************************************************************************
01841 
01842 >   BOOL BevelAttributeValueType::Init()
01843 
01844     Author:     Tim_Browse (Xara Group Ltd) <camelotdev@xara.com>
01845     Created:    11/04/94
01846     Returns:    TRUE - initialised ok; FALSE if not.
01847     Purpose:    Registers line width attribute, and provides a default attribute to give
01848                 0.25pt lines.
01849     Errors:     Out of memory.
01850     SeeAlso:    AttributeManager
01851 
01852 ********************************************************************************************/
01853 
01854 BOOL BevelAttributeValueType::Init()
01855 {
01856     BevelAttributeValueType *pAttr = new BevelAttributeValueType;
01857     if (pAttr == NULL)
01858         return FALSE;
01859 
01860     UINT32 ID = AttributeManager::RegisterDefaultAttribute(CC_RUNTIME_CLASS(NodeRenderableInk), 
01861                                                          pAttr);
01862     if (ID == ATTR_BAD_ID)
01863         return FALSE;
01864     ENSURE(ID == ATTR_BEVELTYPE, "Incorrect ID for attribute!");
01865     return TRUE;
01866 }
01867 
01868 /********************************************************************************************
01869 
01870 >   NodeAttribute *BevelAttributeValueType::MakeNode()
01871 
01872     Author:     Tim_Browse (Xara Group Ltd) <camelotdev@xara.com>
01873     Created:    11/04/94
01874     Returns:    Pointer to the new node, or NULL if out of memory.
01875     Purpose:    Make a AttrbValue node from this line width attribute.
01876     Errors:     Out of memory
01877     SeeAlso:    AttributeValue::MakeNode
01878 
01879 ********************************************************************************************/
01880 
01881 NodeAttribute *BevelAttributeValueType::MakeNode()
01882 {
01883     // Create new attribute node
01884     AttrBevelType *pAttr = new AttrBevelType();
01885 
01886     // Copy attribute value into the new node.
01887     pAttr->Value.SimpleCopy(this);
01888 
01889     // Return the new node
01890     return pAttr;
01891 }
01892 
01893 /********************************************************************************************
01894 
01895 >   INT32 BevelAttributeValueType::operator==(AttributeValue& Attrib)
01896 
01897     Author:     David_McClarnon (Xara Group Ltd) <camelotdev@xara.com>
01898     Created:    13/12/99
01899     Returns:    Pointer to the new node, or NULL if out of memory.
01900     Purpose:    Equation operator
01901     Errors:     Out of memory
01902     SeeAlso:    AttributeValue::MakeNode
01903 
01904 ********************************************************************************************/
01905 INT32 BevelAttributeValueType::operator==(AttributeValue& Attrib)
01906 {
01907     if (!IsDifferent(&Attrib))
01908     {
01909         return TRUE;
01910     }
01911 
01912     return FALSE;
01913 }
01914 
01915 /********************************************************************************************
01916 
01917 >   NodeAttribute *BevelAttributeValueType::MakeNode()
01918 
01919     Author:     Tim_Browse (Xara Group Ltd) <camelotdev@xara.com>
01920     Created:    11/04/94
01921     Returns:    Pointer to the new node, or NULL if out of memory.
01922     Purpose:    Make a AttrbValue node from this line width attribute.
01923     Errors:     Out of memory
01924     SeeAlso:    AttributeValue::MakeNode
01925 
01926 ********************************************************************************************/
01927 
01928 NodeAttribute *BevelAttributeValueType::MakeNode(Node* pContextNode, 
01929                                                  AttachNodeDirection Direction)
01930 {
01931     NodeAttribute * pAttr = MakeNode();
01932 
01933     if (!pAttr)
01934         return NULL;
01935 
01936     pAttr->AttachNode(pContextNode, Direction);
01937 
01938     return pAttr;
01939 }
01940 
01941 
01942 /********************************************************************************************
01943 
01944 >   BOOL BevelAttributeValueType::IsDifferent(AttributeValue *pAttr)
01945 
01946     Author:     Tim_Browse (Xara Group Ltd) <camelotdev@xara.com>
01947     Created:    12/04/94
01948     Purpose:    See base class version.
01949     Errors:     The two attributes are not of the same type.
01950     SeeAlso:    AttributeValue::IsDifferent
01951 
01952 ********************************************************************************************/
01953 
01954 BOOL BevelAttributeValueType::IsDifferent(AttributeValue *pAttr)
01955 {
01956     ENSURE(GetRuntimeClass() == pAttr->GetRuntimeClass(), 
01957            "Different attribute types in AttributeValue::IsDifferent()");
01958 
01959     if (((BevelAttributeValueType *) pAttr)->m_bPassback !=
01960         m_bPassback)
01961         return TRUE;
01962 
01963     if (m_bPassback)
01964     {
01965         if (((BevelAttributeValueType *) pAttr)->m_Type != m_Type ||
01966             ((BevelAttributeValueType *) pAttr)->m_LightAngle != m_LightAngle ||
01967             ((BevelAttributeValueType *) pAttr)->m_Contrast != m_Contrast ||
01968             ((BevelAttributeValueType *) pAttr)->m_Indent != m_Indent)
01969             return TRUE;
01970         else
01971             return FALSE;
01972     }
01973 
01974     return ((BevelAttributeValueType *) pAttr)->m_Type != m_Type;
01975 }
01976 
01977 /********************************************************************************************
01978 
01979 >   AttrBevelLightAngle::AttrBevelLightAngle(Node* ContextNode,  
01980                     AttachNodeDirection Direction,  
01981                     BOOL Locked, 
01982                     BOOL Mangled,  
01983                     BOOL Marked, 
01984                     BOOL Selected    
01985             ): NodeAttribute(ContextNode, Direction, Locked, Mangled, Marked, Selected, TRUE)  
01986 
01987     Author:     Will_Cowling (Xara Group Ltd) <camelotdev@xara.com>
01988     Created:    21/6/93
01989     Inputs:     -
01990     Outputs:    -
01991     Returns:    -
01992     Purpose:    Creates a bValue Attribute
01993     Errors:     -
01994     SeeAlso:    -
01995 
01996 ********************************************************************************************/
01997 
01998 AttrBevelLightAngle::AttrBevelLightAngle(Node* ContextNode,  
01999                     AttachNodeDirection Direction,  
02000                     BOOL Locked, 
02001                     BOOL Mangled,  
02002                     BOOL Marked, 
02003                     BOOL Selected    
02004             ): AttrBevel(ContextNode, Direction, Locked, Mangled, Marked, Selected)  
02005 {                         
02006 } 
02007 
02008 /********************************************************************************************
02009 
02010 >   AttrBevelLightAngle::AttrBevelLightAngle()
02011 
02012     Author:     Will_Cowling (Xara Group Ltd) <camelotdev@xara.com>
02013     Created:    21/6/93
02014     Inputs:     -
02015     Outputs:    -
02016     Returns:    -
02017     Purpose:    Default constructor for Line Width Attribute class
02018     Errors:     -
02019     SeeAlso:    -
02020 
02021 ********************************************************************************************/
02022 
02023 AttrBevelLightAngle::AttrBevelLightAngle()
02024 {
02025 }
02026 
02027 
02028 /********************************************************************************************
02029 
02030 >   void AttrBevelLightAngle::Render( RenderRegion* pRender)
02031 
02032     Author:     Will_Cowling (Xara Group Ltd) <camelotdev@xara.com>
02033     Created:    21/6/93
02034     Inputs:     -
02035     Outputs:    -
02036     Returns:    -
02037     Purpose:    'Renders' a Line Width attribute.
02038     Errors:     -
02039     SeeAlso:    -
02040 
02041 ********************************************************************************************/
02042 
02043 void AttrBevelLightAngle::Render( RenderRegion* pRender)
02044 {
02045 }
02046 
02047 /********************************************************************************************
02048 
02049 >   void AttrBevelLightAngle::Transform( TransformBase& Trans )
02050 
02051     Author:     Will_Cowling (Xara Group Ltd) <camelotdev@xara.com>
02052     Created:    1/8/94
02053     Inputs:     Trans - the transform object to apply to this attribute.
02054     Purpose:    Scale the Line Width.
02055     SeeAlso:    NodeRenderable::Transform
02056 
02057 ********************************************************************************************/
02058 
02059 void AttrBevelLightAngle::Transform( TransformBase& Trans )
02060 {
02061     
02062 }
02063 
02064 /***********************************************************************************************
02065 > Node* AttrBevelLightAngle::SimpleCopy() 
02066 
02067     Author:     Will_Cowling (Xara Group Ltd) <camelotdev@xara.com>
02068     Created:    21/6/93
02069     
02070     Inputs:         - 
02071     Outputs:     
02072     Returns:    A copy of the node, or NULL if memory runs out 
02073          
02074     Purpose:    This method returns a shallow copy of the node with all Node pointers NULL. 
02075                 The function is virtual, and must be defined for all derived classes.  
02076 
02077     Errors:     If memory runs out when trying to copy, then ERROR is called with an out of memory
02078                 error and the function returns NULL. 
02079     
02080     Scope:      protected       
02081 ***********************************************************************************************/
02082      
02083 Node* AttrBevelLightAngle::SimpleCopy()
02084 {
02085     AttrBevelLightAngle* NodeCopy = new AttrBevelLightAngle();
02086     ERRORIF(NodeCopy == NULL, _R(IDE_NOMORE_MEMORY), NULL); 
02087     CopyNodeContents(NodeCopy);
02088     NodeCopy->Value.m_LightAngle = Value.m_LightAngle;
02089     return NodeCopy;
02090 } 
02091 
02092 /********************************************************************************************
02093 
02094 >   INT32 AttrBevelLightAngle::operator==(const NodeAttribute& Attrib)
02095 
02096     Author:     Simon_Maneggio (Xara Group Ltd) <camelotdev@xara.com>
02097     Created:    9/2/94
02098     Inputs:     Atrib:  The attribute to compare, which must be an AttrBevelLightAngle 
02099     Outputs:    -
02100     Returns:    -
02101     Purpose:    A virtual comparison operator. See NodeAttribute::operator== for 
02102                 a description of why it's required. 
02103  
02104     Errors:     An ENSURE failure will occur if Attrib does not have a AttrBevelLightAngle 
02105                 runtime class.
02106                  
02107     SeeAlso:    NodeAttribute::operator==
02108 
02109 ********************************************************************************************/
02110 
02111 INT32 AttrBevelLightAngle::operator==(const NodeAttribute& Attrib)
02112 {
02113     ENSURE(Attrib.IsKindOf(CC_RUNTIME_CLASS(AttrBevelLightAngle)), 
02114         "Trying to compare two objects with different types"); 
02115     AttrBevelLightAngle * Attr = (AttrBevelLightAngle *) &Attrib;
02116     return (Attr->Value.m_LightAngle == Value.m_LightAngle); 
02117 } 
02118 
02119 
02120 /********************************************************************************************
02121 
02122 >   virtual UINT32 AttrBevelLightAngle::GetAttrNameID(void)  
02123 
02124     Author:     Simon_Maneggio (Xara Group Ltd) <camelotdev@xara.com>
02125     Created:    22/2/94
02126     Inputs:     -
02127     Outputs:    -
02128     Returns:    Attribute description ID
02129     Purpose:    Returns back a string resource ID describing the attribute
02130 
02131     Errors:     -
02132     SeeAlso:    -
02133 
02134 ********************************************************************************************/
02135 
02136 UINT32 AttrBevelLightAngle::GetAttrNameID(void)  
02137 {
02138     return (_R(IDS_BEVEL_LIGHTANGLE_ID)); 
02139 }               
02140                  
02141 
02142 /***********************************************************************************************
02143 > ` void AttrBevel::CopyNodeContents( AttrBevelLightAngle* NodeCopy)
02144 
02145     Author:     Simon_Maneggio (Xara Group Ltd) <camelotdev@xara.com>
02146     Created:    28/4/93
02147     
02148     Inputs:           
02149     Outputs:    A copy of this node
02150     Returns:    -
02151          
02152     Purpose:    This method copies the node's contents to the node pointed to by NodeCopy.
02153               
02154     Errors:     An assertion failure will occur if NodeCopy is NULL
02155     
02156     Scope:      protected
02157                                      
02158 ***********************************************************************************************/
02159 
02160 void AttrBevelLightAngle::CopyNodeContents( AttrBevelLightAngle* NodeCopy)
02161 {
02162     NodeAttribute::CopyNodeContents( NodeCopy );
02163 
02164     NodeCopy->Value = Value;
02165 } 
02166 
02167 /***********************************************************************************************
02168 >   void AttrBevelContrast::PolyCopyNodeContents(NodeRenderable* pNodeCopy)
02169 
02170     Author:     Phil_Martin (Xara Group Ltd) <camelotdev@xara.com>
02171     Created:    18/12/2003
02172     Outputs:    -
02173     Purpose:    Polymorphically copies the contents of this node to another
02174     Errors:     An assertion failure will occur if NodeCopy is NULL
02175     Scope:      protected
02176                                      
02177 ***********************************************************************************************/
02178 
02179 void AttrBevelLightAngle::PolyCopyNodeContents(NodeRenderable* pNodeCopy)
02180 {
02181     ENSURE(pNodeCopy, "Trying to copy a node's contents into a NULL node");
02182     ENSURE(IS_A(pNodeCopy, AttrBevelLightAngle), "PolyCopyNodeContents given wrong dest node type");
02183 
02184     if (IS_A(pNodeCopy, AttrBevelLightAngle))
02185         CopyNodeContents((AttrBevelLightAngle*)pNodeCopy);
02186 }
02187 
02188 
02189 
02190 /***********************************************************************************************
02191 
02192 >   void AttrBevelLightAngle::ShowDebugTreeDetails() const
02193 
02194     Author:     Will_Cowling (Xara Group Ltd) <camelotdev@xara.com>
02195     Created:    21/6/93
02196     Purpose:    Displays debugging info of the tree
02197 
02198 ***********************************************************************************************/
02199 
02200 void AttrBevelLightAngle::ShowDebugTreeDetails() const
02201 {
02202     // Display a bit of debugging info
02203     // For now, we will just call the base class version
02204 #ifdef _DEBUG
02205     NodeAttribute::ShowDebugTreeDetails();  
02206 #endif
02207 }
02208 
02209 /********************************************************************************************
02210 
02211 >   BOOL AttrBevelLightAngle::Blend(BlendAttrParam* pBlendParam)
02212 
02213     Author:     David_McClarnon (Xara Group Ltd) <camelotdev@xara.com>
02214     Created:    12/12/99
02215     Inputs:     The blend attribute param
02216     Purpose:    Blends this light angle to another
02217     SeeAlso:    
02218 
02219 ********************************************************************************************/
02220 BOOL AttrBevelLightAngle::Blend(BlendAttrParam* pBlendParam)
02221 {
02222     ERROR2IF(pBlendParam == NULL,FALSE,"pBlendParam == NULL");
02223     ERROR3IF(!(pBlendParam->GetOtherAttr()->IS_KIND_OF(AttrBevelLightAngle)),
02224         "Blend attribute isn't a bevel light angle attribute");
02225 
02226     AttrBevelLightAngle * pBlendedAttr = NULL;
02227 
02228     // assign the other attribute we're looking at
02229     AttrBevelLightAngle * pOtherAttr = (AttrBevelLightAngle *)pBlendParam->GetOtherAttr();
02230 
02231     // split at the half way mark
02232     if (pBlendParam->GetBlendRatio() <= 0.5)
02233     {
02234         pBlendedAttr = (AttrBevelLightAngle *)SimpleCopy();
02235     }
02236     else
02237     {
02238         pBlendedAttr = (AttrBevelLightAngle *)pOtherAttr->SimpleCopy();
02239     }
02240 
02241     // set the blended attribute
02242     pBlendParam->SetBlendedAttr(pBlendedAttr);
02243 
02244     if (!pBlendedAttr)
02245         return FALSE;
02246 
02247     double LightAngle1      = Value.m_LightAngle;
02248     double LightAngle2      = pOtherAttr->Value.m_LightAngle;
02249 
02250     // make both light angles between 0 and 360
02251     while (LightAngle1 >= 360)
02252         LightAngle1 -= 360;
02253 
02254     while (LightAngle1 < 0)
02255         LightAngle1 += 360;
02256 
02257     while (LightAngle2 >= 360)
02258         LightAngle2 -= 360;
02259 
02260     while (LightAngle2 < 0)
02261         LightAngle2 += 360;
02262 
02263     // check the difference between the two
02264     if (fabs(LightAngle2 - LightAngle1) > 180.0)
02265     {
02266         // choose the smallest difference
02267         if (LightAngle2 > LightAngle1)
02268         {
02269             LightAngle1 += 360.0;
02270         }
02271         else
02272         {
02273             LightAngle2 += 360.0;
02274         }
02275     }
02276 
02277     double NewLightAngle    = ((LightAngle2 - LightAngle1) * pBlendParam->GetBlendRatio()) +
02278                                     LightAngle1;
02279 
02280     pBlendedAttr->Value.m_LightAngle = (INT32)NewLightAngle;
02281 
02282     return TRUE;
02283 }
02284 
02285 
02286 
02287 void AttrBevelLightAngle::GetDebugDetails(StringBase* Str)
02288 {
02289 #ifdef _DEBUG
02290     if (Str)
02291     {
02292         NodeAttribute::GetDebugDetails( Str );
02293         String_256 TempStr;
02294         TempStr._MakeMsg( TEXT("\r\nValue=#1%d\r\n"), Value.m_LightAngle );
02295         (*Str) += TempStr;
02296     }
02297 #else
02298     if (Str)
02299     {
02300         *Str = wxT("");
02301     }
02302 #endif
02303 }
02304 
02305 
02306 /********************************************************************************************
02307 
02308 >   virtual UINT32 AttrBevelLightAngle::GetNodeSize() const
02309 
02310     Author:     Simon_Maneggio (Xara Group Ltd) <camelotdev@xara.com>
02311     Created:    6/10/93
02312     Inputs:     -
02313     Outputs:    -
02314     Returns:    The size of the node in bytes
02315     Purpose:    For finding the size of the node 
02316                 
02317     SeeAlso:    Node::GetSubtreeSize
02318 
02319 ********************************************************************************************/
02320 
02321 UINT32 AttrBevelLightAngle::GetNodeSize() const 
02322 {     
02323     return (sizeof(AttrBevelLightAngle)); 
02324 }  
02325 
02326 /********************************************************************************************
02327 
02328   > virtual BOOL AttrBevelLightAngle::WritePreChildrenWeb(BaseCamelotFilter* pFilter)
02329 
02330     Author:     Mark_Neves (Xara Group Ltd) <camelotdev@xara.com>
02331     Created:    30/5/96
02332     Inputs:     pFilter = ptr to the filter
02333     Returns:    TRUE if record is written, FALSE if not
02334     Purpose:    Writes the line width record to the filter
02335     SeeAlso:    -
02336 
02337 ********************************************************************************************/
02338 
02339 BOOL AttrBevelLightAngle::WritePreChildrenWeb(BaseCamelotFilter* pFilter)
02340 {
02341     return TRUE;
02342 }
02343 
02344 //--------------------------------------------------------------
02345 // See AttrBevelLightAngle::WritePreChildrenWeb(BaseCamelotFilter* pFilter)
02346 //
02347 BOOL AttrBevelLightAngle::WritePreChildrenNative(BaseCamelotFilter* pFilter)
02348 {
02349 #ifdef DO_EXPORT
02350     return WritePreChildrenWeb(pFilter);
02351 #else
02352     return FALSE;
02353 #endif
02354 }
02355 
02357 // the actual attribute
02358 
02359 BevelAttributeValueLightAngle::BevelAttributeValueLightAngle()
02360 {
02361     m_LightAngle = 300;
02362 }
02363 
02364 /********************************************************************************************
02365 
02366 >   void BevelAttributeValueLightAngle::Render(RenderRegion *pRegion)
02367 
02368     Author:     Tim_Browse (Xara Group Ltd) <camelotdev@xara.com>
02369     Created:    03/02/94
02370     Inputs:     pRegion - the render region to render this attribute into.
02371     Purpose:    Sets the line width attribute for the given render region. i.e. all
02372                 lines drawn will now be drawn with this line width.
02373     SeeAlso:    BevelAttributeValueLightAngle; RenderStack; AttributeValue; NodeAttribute;
02374                 BevelAttributeValueLightAngle::Restore; BevelAttributeValueLightAngle::SimpleCopy;
02375                 AttributeValue::Render; AttributeValue::Restore; AttributeValue::SimpleCopy
02376 
02377 ********************************************************************************************/
02378 
02379 void BevelAttributeValueLightAngle::Render(RenderRegion *pRegion, BOOL Temp)
02380 {
02381 }
02382 
02383 /********************************************************************************************
02384 
02385 >   void BevelAttributeValueLightAngle::Restore(RenderRegion *pRegion, BOOL Temp)
02386 
02387     Author:     Tim_Browse (Xara Group Ltd) <camelotdev@xara.com>
02388     Created:    03/02/94
02389     Inputs:     pRegion - the render region to restore the attribute into.
02390                 Temp    - TRUE if this is a temporary attribute, FALSE if it is
02391                           permanent (e.g. it's in a document tree).
02392     Purpose:    Restores the line width attribute for the given render region. i.e. all
02393                 lines drawn will now be drawn with this line width.
02394     SeeAlso:    BevelAttributeValueLightAngle; RenderStack; AttributeValue; NodeAttribute;
02395                 BevelAttributeValueLightAngle::Render; BevelAttributeValueLightAngle::SimpleCopy;
02396                 AttributeValue::Render; AttributeValue::Restore; AttributeValue::SimpleCopy
02397 
02398 ********************************************************************************************/
02399 
02400 void BevelAttributeValueLightAngle::Restore(RenderRegion *pRegion, BOOL Temp)
02401 {
02402 }
02403 
02404 /********************************************************************************************
02405 
02406 >   void BevelAttributeValueLightAngle::SimpleCopy(AttributeValue *pValue)
02407 
02408     Author:     Tim_Browse (Xara Group Ltd) <camelotdev@xara.com>
02409     Created:    03/02/94
02410     Inputs:     pAttr - pointer to the AttributeValue to copy.
02411     Purpose:    See AttributeValue::SimpleCopy
02412     SeeAlso:    BevelAttributeValueLightAngle; RenderStack; AttributeValue; NodeAttribute;
02413                 BevelAttributeValueLightAngle::Render; BevelAttributeValueLightAngle::Restore;
02414                 AttributeValue::Render; AttributeValue::Restore; AttributeValue::SimpleCopy
02415 
02416 ********************************************************************************************/
02417 
02418 void BevelAttributeValueLightAngle::SimpleCopy(AttributeValue *pValue)
02419 {
02420     m_LightAngle = ((BevelAttributeValueLightAngle *) pValue)->m_LightAngle;
02421 }
02422 
02423 /********************************************************************************************
02424 
02425 >   BOOL BevelAttributeValueLightAngle::Init()
02426 
02427     Author:     Tim_Browse (Xara Group Ltd) <camelotdev@xara.com>
02428     Created:    11/04/94
02429     Returns:    TRUE - initialised ok; FALSE if not.
02430     Purpose:    Registers line width attribute, and provides a default attribute to give
02431                 0.25pt lines.
02432     Errors:     Out of memory.
02433     SeeAlso:    AttributeManager
02434 
02435 ********************************************************************************************/
02436 
02437 BOOL BevelAttributeValueLightAngle::Init()
02438 {
02439     BevelAttributeValueLightAngle *pAttr = new BevelAttributeValueLightAngle;
02440     if (pAttr == NULL)
02441         return FALSE;
02442 
02443     UINT32 ID = AttributeManager::RegisterDefaultAttribute(CC_RUNTIME_CLASS(NodeRenderableInk), 
02444                                                          pAttr);
02445     if (ID == ATTR_BAD_ID)
02446         return FALSE;
02447     ENSURE(ID == ATTR_BEVELLIGHTANGLE, "Incorrect ID for attribute!");
02448     return TRUE;
02449 }
02450 
02451 /********************************************************************************************
02452 
02453 >   NodeAttribute *BevelAttributeValueLightAngle::MakeNode()
02454 
02455     Author:     Tim_Browse (Xara Group Ltd) <camelotdev@xara.com>
02456     Created:    11/04/94
02457     Returns:    Pointer to the new node, or NULL if out of memory.
02458     Purpose:    Make a AttrbValue node from this line width attribute.
02459     Errors:     Out of memory
02460     SeeAlso:    AttributeValue::MakeNode
02461 
02462 ********************************************************************************************/
02463 
02464 NodeAttribute *BevelAttributeValueLightAngle::MakeNode()
02465 {
02466     // Create new attribute node
02467     AttrBevelLightAngle *pAttr = new AttrBevelLightAngle();
02468 
02469     // Copy attribute value into the new node.
02470     pAttr->Value.SimpleCopy(this);
02471 
02472     // Return the new node
02473     return pAttr;
02474 }
02475 
02476 /********************************************************************************************
02477 
02478 >   BOOL BevelAttributeValueLightAngle::IsDifferent(AttributeValue *pAttr)
02479 
02480     Author:     Tim_Browse (Xara Group Ltd) <camelotdev@xara.com>
02481     Created:    12/04/94
02482     Purpose:    See base class version.
02483     Errors:     The two attributes are not of the same type.
02484     SeeAlso:    AttributeValue::IsDifferent
02485 
02486 ********************************************************************************************/
02487 
02488 BOOL BevelAttributeValueLightAngle::IsDifferent(AttributeValue *pAttr)
02489 {
02490     ENSURE(GetRuntimeClass() == pAttr->GetRuntimeClass(), 
02491            "Different attribute types in AttributeValue::IsDifferent()");
02492     return ((BevelAttributeValueLightAngle *) pAttr)->m_LightAngle != m_LightAngle;
02493 }
02494 
02495 /********************************************************************************************
02496 
02497 >   AttrBevelLightTilt::AttrBevelLightTilt(Node* ContextNode,  
02498                     AttachNodeDirection Direction,  
02499                     BOOL Locked, 
02500                     BOOL Mangled,  
02501                     BOOL Marked, 
02502                     BOOL Selected    
02503             ): NodeAttribute(ContextNode, Direction, Locked, Mangled, Marked, Selected, TRUE)  
02504 
02505     Author:     Will_Cowling (Xara Group Ltd) <camelotdev@xara.com>
02506     Created:    21/6/93
02507     Inputs:     -
02508     Outputs:    -
02509     Returns:    -
02510     Purpose:    Creates a bValue Attribute
02511     Errors:     -
02512     SeeAlso:    -
02513 
02514 ********************************************************************************************/
02515 
02516 AttrBevelLightTilt::AttrBevelLightTilt(Node* ContextNode,  
02517                     AttachNodeDirection Direction,  
02518                     BOOL Locked, 
02519                     BOOL Mangled,  
02520                     BOOL Marked, 
02521                     BOOL Selected    
02522             ): AttrBevel(ContextNode, Direction, Locked, Mangled, Marked, Selected)  
02523 {                         
02524 } 
02525 
02526 /********************************************************************************************
02527 
02528 >   AttrBevelLightTilt::AttrBevelLightTilt()
02529 
02530     Author:     Will_Cowling (Xara Group Ltd) <camelotdev@xara.com>
02531     Created:    21/6/93
02532     Inputs:     -
02533     Outputs:    -
02534     Returns:    -
02535     Purpose:    Default constructor for Line Width Attribute class
02536     Errors:     -
02537     SeeAlso:    -
02538 
02539 ********************************************************************************************/
02540 
02541 AttrBevelLightTilt::AttrBevelLightTilt()
02542 {
02543 }
02544 
02545 
02546 /********************************************************************************************
02547 
02548 >   void AttrBevelLightTilt::Render( RenderRegion* pRender)
02549 
02550     Author:     Will_Cowling (Xara Group Ltd) <camelotdev@xara.com>
02551     Created:    21/6/93
02552     Inputs:     -
02553     Outputs:    -
02554     Returns:    -
02555     Purpose:    'Renders' a Line Width attribute.
02556     Errors:     -
02557     SeeAlso:    -
02558 
02559 ********************************************************************************************/
02560 
02561 void AttrBevelLightTilt::Render( RenderRegion* pRender)
02562 {
02563 }
02564 
02565 /********************************************************************************************
02566 
02567 >   void AttrBevelLightTilt::Transform( TransformBase& Trans )
02568 
02569     Author:     Will_Cowling (Xara Group Ltd) <camelotdev@xara.com>
02570     Created:    1/8/94
02571     Inputs:     Trans - the transform object to apply to this attribute.
02572     Purpose:    Scale the Line Width.
02573     SeeAlso:    NodeRenderable::Transform
02574 
02575 ********************************************************************************************/
02576 
02577 void AttrBevelLightTilt::Transform( TransformBase& Trans )
02578 {
02579     
02580 }
02581 
02582 /***********************************************************************************************
02583 > Node* AttrBevelLightTilt::SimpleCopy() 
02584 
02585     Author:     Will_Cowling (Xara Group Ltd) <camelotdev@xara.com>
02586     Created:    21/6/93
02587     
02588     Inputs:         - 
02589     Outputs:     
02590     Returns:    A copy of the node, or NULL if memory runs out 
02591          
02592     Purpose:    This method returns a shallow copy of the node with all Node pointers NULL. 
02593                 The function is virtual, and must be defined for all derived classes.  
02594 
02595     Errors:     If memory runs out when trying to copy, then ERROR is called with an out of memory
02596                 error and the function returns NULL. 
02597     
02598     Scope:      protected       
02599 ***********************************************************************************************/
02600      
02601 Node* AttrBevelLightTilt::SimpleCopy()
02602 {
02603     AttrBevelLightTilt* NodeCopy = new AttrBevelLightTilt();
02604     ERRORIF(NodeCopy == NULL, _R(IDE_NOMORE_MEMORY), NULL); 
02605     CopyNodeContents(NodeCopy);
02606     NodeCopy->Value.m_LightTilt = Value.m_LightTilt;
02607     return NodeCopy;
02608 } 
02609 
02610 /********************************************************************************************
02611 
02612 >   INT32 AttrBevelLightTilt::operator==(const NodeAttribute& Attrib)
02613 
02614     Author:     Simon_Maneggio (Xara Group Ltd) <camelotdev@xara.com>
02615     Created:    9/2/94
02616     Inputs:     Atrib:  The attribute to compare, which must be an AttrBevelLightTilt 
02617     Outputs:    -
02618     Returns:    -
02619     Purpose:    A virtual comparison operator. See NodeAttribute::operator== for 
02620                 a description of why it's required. 
02621  
02622     Errors:     An ENSURE failure will occur if Attrib does not have a AttrBevelLightTilt 
02623                 runtime class.
02624                  
02625     SeeAlso:    NodeAttribute::operator==
02626 
02627 ********************************************************************************************/
02628 
02629 INT32 AttrBevelLightTilt::operator==(const NodeAttribute& Attrib)
02630 {
02631     ENSURE(Attrib.IsKindOf(CC_RUNTIME_CLASS(AttrBevelLightTilt)), 
02632         "Trying to compare two objects with different types"); 
02633     AttrBevelLightTilt * Attr = (AttrBevelLightTilt *) &Attrib;
02634     return (Attr->Value.m_LightTilt == Value.m_LightTilt); 
02635 } 
02636 
02637 /********************************************************************************************
02638 
02639 >   BOOL AttrBevelLightTilt::Blend(BlendAttrParam* pBlendParam)
02640 
02641     Author:     David_McClarnon (Xara Group Ltd) <camelotdev@xara.com>
02642     Created:    12/12/99
02643     Inputs:     The blend attribute param
02644     Purpose:    Blends this light angle to another
02645     SeeAlso:    
02646 
02647 ********************************************************************************************/
02648 BOOL AttrBevelLightTilt::Blend(BlendAttrParam* pBlendParam)
02649 {
02650     ERROR2IF(pBlendParam == NULL,FALSE,"pBlendParam == NULL");
02651     ERROR3IF(!(pBlendParam->GetOtherAttr()->IS_KIND_OF(AttrBevelLightTilt)),
02652         "Blend attribute isn't a bevel light tilt attribute");
02653 
02654     AttrBevelLightTilt * pBlendedAttr = NULL;
02655 
02656     // assign the other attribute we're looking at
02657     AttrBevelLightTilt * pOtherAttr = (AttrBevelLightTilt *)pBlendParam->GetOtherAttr();
02658 
02659     // split at the half way mark
02660     if (pBlendParam->GetBlendRatio() <= 0.5)
02661     {
02662         pBlendedAttr = (AttrBevelLightTilt *)SimpleCopy();
02663     }
02664     else
02665     {
02666         pBlendedAttr = (AttrBevelLightTilt *)pOtherAttr->SimpleCopy();
02667     }
02668 
02669     // set the blended attribute
02670     pBlendParam->SetBlendedAttr(pBlendedAttr);
02671 
02672     if (!pBlendedAttr)
02673         return FALSE;
02674 
02675     double LightTilt1           = Value.m_LightTilt;
02676     double LightTilt2           = pOtherAttr->Value.m_LightTilt;
02677     double NewLightTilt         = ((LightTilt2 - LightTilt1) * pBlendParam->GetBlendRatio()) + LightTilt1;
02678 
02679     // set the blended attribute's values
02680     pBlendedAttr->Value.m_LightTilt = (INT32) NewLightTilt;
02681     
02682     return TRUE;
02683 }
02684 
02685 
02686 /********************************************************************************************
02687 
02688 >   virtual UINT32 AttrBevelLightTilt::GetAttrNameID(void)  
02689 
02690     Author:     Simon_Maneggio (Xara Group Ltd) <camelotdev@xara.com>
02691     Created:    22/2/94
02692     Inputs:     -
02693     Outputs:    -
02694     Returns:    Attribute description ID
02695     Purpose:    Returns back a string resource ID describing the attribute
02696 
02697     Errors:     -
02698     SeeAlso:    -
02699 
02700 ********************************************************************************************/
02701 
02702 UINT32 AttrBevelLightTilt::GetAttrNameID(void)  
02703 {
02704     return (_R(IDS_BEVEL_LIGHTTILT_ID)); 
02705 }               
02706                  
02707 
02708 /***********************************************************************************************
02709 > ` void AttrBevel::CopyNodeContents( AttrBevelLightTilt* NodeCopy)
02710 
02711     Author:     Simon_Maneggio (Xara Group Ltd) <camelotdev@xara.com>
02712     Created:    28/4/93
02713     
02714     Inputs:           
02715     Outputs:    A copy of this node
02716     Returns:    -
02717          
02718     Purpose:    This method copies the node's contents to the node pointed to by NodeCopy.
02719               
02720     Errors:     An assertion failure will occur if NodeCopy is NULL
02721     
02722     Scope:      protected
02723                                      
02724 ***********************************************************************************************/
02725 
02726 void AttrBevelLightTilt::CopyNodeContents( AttrBevelLightTilt* NodeCopy)
02727 {
02728     NodeAttribute::CopyNodeContents( NodeCopy );
02729 
02730     NodeCopy->Value = Value;
02731 } 
02732 
02733 /***********************************************************************************************
02734 >   void AttrBevelLightTilt::PolyCopyNodeContents(NodeRenderable* pNodeCopy)
02735 
02736     Author:     Phil_Martin (Xara Group Ltd) <camelotdev@xara.com>
02737     Created:    18/12/2003
02738     Outputs:    -
02739     Purpose:    Polymorphically copies the contents of this node to another
02740     Errors:     An assertion failure will occur if NodeCopy is NULL
02741     Scope:      protected
02742                                      
02743 ***********************************************************************************************/
02744 
02745 void AttrBevelLightTilt::PolyCopyNodeContents(NodeRenderable* pNodeCopy)
02746 {
02747     ENSURE(pNodeCopy, "Trying to copy a node's contents into a NULL node");
02748     ENSURE(IS_A(pNodeCopy, AttrBevelLightTilt), "PolyCopyNodeContents given wrong dest node type");
02749 
02750     if (IS_A(pNodeCopy, AttrBevelLightTilt))
02751         CopyNodeContents((AttrBevelLightTilt*)pNodeCopy);
02752 }
02753 
02754 
02755 
02756 /***********************************************************************************************
02757 
02758 >   void AttrBevelLightTilt::ShowDebugTreeDetails() const
02759 
02760     Author:     Will_Cowling (Xara Group Ltd) <camelotdev@xara.com>
02761     Created:    21/6/93
02762     Purpose:    Displays debugging info of the tree
02763 
02764 ***********************************************************************************************/
02765 
02766 void AttrBevelLightTilt::ShowDebugTreeDetails() const
02767 {
02768     // Display a bit of debugging info
02769     // For now, we will just call the base class version
02770 #ifdef _DEBUG
02771     NodeAttribute::ShowDebugTreeDetails();  
02772 #endif
02773 }
02774 
02775 
02776 void AttrBevelLightTilt::GetDebugDetails(StringBase* Str)
02777 {
02778 #ifdef _DEBUG
02779     if (Str)
02780     {
02781         NodeAttribute::GetDebugDetails( Str );
02782         String_256 TempStr;
02783         TempStr._MakeMsg( TEXT("\r\nValue=#1%d\r\n"), Value.m_LightTilt );
02784         (*Str) += TempStr;
02785     }
02786 #else
02787     if (Str)
02788     {
02789         *Str = wxT("");
02790     }
02791 #endif
02792 }
02793 
02794 
02795 /********************************************************************************************
02796 
02797 >   virtual UINT32 AttrBevelLightTilt::GetNodeSize() const
02798 
02799     Author:     Simon_Maneggio (Xara Group Ltd) <camelotdev@xara.com>
02800     Created:    6/10/93
02801     Inputs:     -
02802     Outputs:    -
02803     Returns:    The size of the node in bytes
02804     Purpose:    For finding the size of the node 
02805                 
02806     SeeAlso:    Node::GetSubtreeSize
02807 
02808 ********************************************************************************************/
02809 
02810 UINT32 AttrBevelLightTilt::GetNodeSize() const 
02811 {     
02812     return (sizeof(AttrBevelLightTilt)); 
02813 }  
02814 
02815 /********************************************************************************************
02816 
02817   > virtual BOOL AttrBevelLightTilt::WritePreChildrenWeb(BaseCamelotFilter* pFilter)
02818 
02819     Author:     Mark_Neves (Xara Group Ltd) <camelotdev@xara.com>
02820     Created:    30/5/96
02821     Inputs:     pFilter = ptr to the filter
02822     Returns:    TRUE if record is written, FALSE if not
02823     Purpose:    Writes the line width record to the filter
02824     SeeAlso:    -
02825 
02826 ********************************************************************************************/
02827 
02828 BOOL AttrBevelLightTilt::WritePreChildrenWeb(BaseCamelotFilter* pFilter)
02829 {
02830 /*
02831 #ifdef DO_EXPORT
02832     ERROR2IF(pFilter == NULL,FALSE,"NULL filter param");
02833 
02834     CamelotFileRecord Rec(pFilter,TAG_BEVATTR_LightTilt,sizeof(Value.m_LightTilt));
02835 
02836     BOOL ok = Rec.Init();
02837 
02838     if (ok) ok = Rec.WriteINT32(Value.m_LightTilt);
02839     if (ok) ok = pFilter->Write(&Rec);
02840 
02841     return ok;
02842 #else
02843     return FALSE;
02844 #endif
02845     */
02846     return TRUE;
02847 }
02848 
02849 //--------------------------------------------------------------
02850 // See AttrBevelLightTilt::WritePreChildrenWeb(BaseCamelotFilter* pFilter)
02851 //
02852 BOOL AttrBevelLightTilt::WritePreChildrenNative(BaseCamelotFilter* pFilter)
02853 {
02854 #ifdef DO_EXPORT
02855     return WritePreChildrenWeb(pFilter);
02856 #else
02857     return FALSE;
02858 #endif
02859 }
02860 
02862 // the actual attribute
02863 
02864 BevelAttributeValueLightTilt::BevelAttributeValueLightTilt()
02865 {
02866     m_LightTilt = 32;
02867 }
02868 
02869 /********************************************************************************************
02870 
02871 >   void BevelAttributeValueLightTilt::Render(RenderRegion *pRegion)
02872 
02873     Author:     Tim_Browse (Xara Group Ltd) <camelotdev@xara.com>
02874     Created:    03/02/94
02875     Inputs:     pRegion - the render region to render this attribute into.
02876     Purpose:    Sets the line width attribute for the given render region. i.e. all
02877                 lines drawn will now be drawn with this line width.
02878     SeeAlso:    BevelAttributeValueLightTilt; RenderStack; AttributeValue; NodeAttribute;
02879                 BevelAttributeValueLightTilt::Restore; BevelAttributeValueLightTilt::SimpleCopy;
02880                 AttributeValue::Render; AttributeValue::Restore; AttributeValue::SimpleCopy
02881 
02882 ********************************************************************************************/
02883 
02884 void BevelAttributeValueLightTilt::Render(RenderRegion *pRegion, BOOL Temp)
02885 {
02886 }
02887 
02888 /********************************************************************************************
02889 
02890 >   void BevelAttributeValueLightTilt::Restore(RenderRegion *pRegion, BOOL Temp)
02891 
02892     Author:     Tim_Browse (Xara Group Ltd) <camelotdev@xara.com>
02893     Created:    03/02/94
02894     Inputs:     pRegion - the render region to restore the attribute into.
02895                 Temp    - TRUE if this is a temporary attribute, FALSE if it is
02896                           permanent (e.g. it's in a document tree).
02897     Purpose:    Restores the line width attribute for the given render region. i.e. all
02898                 lines drawn will now be drawn with this line width.
02899     SeeAlso:    BevelAttributeValueLightTilt; RenderStack; AttributeValue; NodeAttribute;
02900                 BevelAttributeValueLightTilt::Render; BevelAttributeValueLightTilt::SimpleCopy;
02901                 AttributeValue::Render; AttributeValue::Restore; AttributeValue::SimpleCopy
02902 
02903 ********************************************************************************************/
02904 
02905 void BevelAttributeValueLightTilt::Restore(RenderRegion *pRegion, BOOL Temp)
02906 {
02907 }
02908 
02909 /********************************************************************************************
02910 
02911 >   void BevelAttributeValueLightTilt::SimpleCopy(AttributeValue *pValue)
02912 
02913     Author:     Tim_Browse (Xara Group Ltd) <camelotdev@xara.com>
02914     Created:    03/02/94
02915     Inputs:     pAttr - pointer to the AttributeValue to copy.
02916     Purpose:    See AttributeValue::SimpleCopy
02917     SeeAlso:    BevelAttributeValueLightTilt; RenderStack; AttributeValue; NodeAttribute;
02918                 BevelAttributeValueLightTilt::Render; BevelAttributeValueLightTilt::Restore;
02919                 AttributeValue::Render; AttributeValue::Restore; AttributeValue::SimpleCopy
02920 
02921 ********************************************************************************************/
02922 
02923 void BevelAttributeValueLightTilt::SimpleCopy(AttributeValue *pValue)
02924 {
02925     m_LightTilt = ((BevelAttributeValueLightTilt *) pValue)->m_LightTilt;
02926 }
02927 
02928 /********************************************************************************************
02929 
02930 >   BOOL BevelAttributeValueLightTilt::Init()
02931 
02932     Author:     Tim_Browse (Xara Group Ltd) <camelotdev@xara.com>
02933     Created:    11/04/94
02934     Returns:    TRUE - initialised ok; FALSE if not.
02935     Purpose:    Registers line width attribute, and provides a default attribute to give
02936                 0.25pt lines.
02937     Errors:     Out of memory.
02938     SeeAlso:    AttributeManager
02939 
02940 ********************************************************************************************/
02941 
02942 BOOL BevelAttributeValueLightTilt::Init()
02943 {
02944     BevelAttributeValueLightTilt *pAttr = new BevelAttributeValueLightTilt;
02945     if (pAttr == NULL)
02946         return FALSE;
02947 
02948     UINT32 ID = AttributeManager::RegisterDefaultAttribute(CC_RUNTIME_CLASS(NodeRenderableInk), 
02949                                                          pAttr);
02950     if (ID == ATTR_BAD_ID)
02951         return FALSE;
02952     ENSURE(ID == ATTR_BEVELLIGHTTILT, "Incorrect ID for attribute!");
02953     return TRUE;
02954 }
02955 
02956 /********************************************************************************************
02957 
02958 >   NodeAttribute *BevelAttributeValueLightTilt::MakeNode()
02959 
02960     Author:     Tim_Browse (Xara Group Ltd) <camelotdev@xara.com>
02961     Created:    11/04/94
02962     Returns:    Pointer to the new node, or NULL if out of memory.
02963     Purpose:    Make a AttrbValue node from this line width attribute.
02964     Errors:     Out of memory
02965     SeeAlso:    AttributeValue::MakeNode
02966 
02967 ********************************************************************************************/
02968 
02969 NodeAttribute *BevelAttributeValueLightTilt::MakeNode()
02970 {
02971     // Create new attribute node
02972     AttrBevelLightTilt *pAttr = new AttrBevelLightTilt();
02973 
02974     // Copy attribute value into the new node.
02975     pAttr->Value.SimpleCopy(this);
02976 
02977     // Return the new node
02978     return pAttr;
02979 }
02980 
02981 /********************************************************************************************
02982 
02983 >   BOOL BevelAttributeValueLightTilt::IsDifferent(AttributeValue *pAttr)
02984 
02985     Author:     Tim_Browse (Xara Group Ltd) <camelotdev@xara.com>
02986     Created:    12/04/94
02987     Purpose:    See base class version.
02988     Errors:     The two attributes are not of the same type.
02989     SeeAlso:    AttributeValue::IsDifferent
02990 
02991 ********************************************************************************************/
02992 
02993 BOOL BevelAttributeValueLightTilt::IsDifferent(AttributeValue *pAttr)
02994 {
02995     ENSURE(GetRuntimeClass() == pAttr->GetRuntimeClass(), 
02996            "Different attribute types in AttributeValue::IsDifferent()");
02997     return ((BevelAttributeValueLightTilt *) pAttr)->m_LightTilt != m_LightTilt;
02998 }

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