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: Wil