00001 // $Id: sgline2.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 sgline2.cpp 00101 00102 This header contains definitions of the member-functions of various classes derived 00103 from LineAttrItem, as used in the line-attributes gallery. 00104 00105 */ 00106 00107 #include "camtypes.h" 00108 //#include "app.h" - in camtypes.h [AUTOMATICALLY REMOVED] 00109 //#include "rndrgn.h" - in camtypes.h [AUTOMATICALLY REMOVED] 00110 //#include "paths.h" - in camtypes.h [AUTOMATICALLY REMOVED] 00111 #include "lineattr.h" 00112 #include "sgline2.h" 00113 00114 00115 /******************************************************************************************** 00116 > LineWidthItem::LineWidthItem(double nPointWidth, const String& strDescription) 00117 00118 Author: Justin_Flude (Xara Group Ltd) <camelotdev@xara.com> 00119 Created: 10/4/95 00120 Inputs: nPointWidth the width of the line, in points 00121 strDescription a text description of this user-interface item 00122 Outputs: - 00123 Returns: - 00124 Purpose: Constructs a user-interface item representing a line's width. 00125 Errors: - 00126 SeeAlso: - 00127 ********************************************************************************************/ 00128 00129 LineWidthItem::LineWidthItem(double nPointWidth, const String& strDescription) 00130 : LineAttrItem(strDescription, LEFT), 00131 m_nWidth((MILLIPOINT) (nPointWidth * 1000.0)) 00132 { 00133 // Empty. 00134 } 00135 00136 00137 00138 /******************************************************************************************** 00139 > virtual void LineWidthItem::SetAttributes(RenderRegion* pRegion) const 00140 00141 Author: Justin_Flude (Xara Group Ltd) <camelotdev@xara.com> 00142 Created: 10/4/95 00143 Inputs: pRegion the render-region to draw into 00144 Outputs: - 00145 Returns: - 00146 Purpose: Sets the line-width attributes in the given render-region to render this 00147 item correctly. 00148 Errors: - 00149 SeeAlso: - 00150 ********************************************************************************************/ 00151 00152 void LineWidthItem::SetAttributes(RenderRegion* pRegion) const 00153 { 00154 // Set the line width (this overrides the "default" line width set by the caller). 00155 pRegion->SetLineWidth(m_nWidth); 00156 00157 // If the line is only a pixel thick then draw it in red, to distinguish it from 00158 // other very thin lines. 00159 if (m_nWidth == 0) pRegion->SetLineColour(COLOUR_RED); 00160 } 00161 00162 00163 00164 /******************************************************************************************** 00165 > virtual NodeAttribute* LineWidthItem::CreateNewAttribute(BOOL) const 00166 00167 Author: Justin_Flude (Xara Group Ltd) <camelotdev@xara.com> 00168 Created: 10/4/95 00169 Inputs: - 00170 Outputs: - 00171 Returns: A pointer to a NodeAttribute-derivative that this user-interface item 00172 represents, ie. a line-width attribute that can be passed to the 00173 attribute manager. 00174 Purpose: 00175 Errors: - 00176 SeeAlso: - 00177 ********************************************************************************************/ 00178 00179 NodeAttribute* LineWidthItem::CreateNewAttribute(BOOL) const 00180 { 00181 AttrLineWidth* pAttr = new AttrLineWidth; 00182 if (pAttr != NULL) pAttr->Value.LineWidth = m_nWidth; 00183 return pAttr; 00184 } 00185 00186 00187 00188 /******************************************************************************************** 00189 > virtual MILLIPOINT LineWidthItem::GetWidth() const 00190 00191 Author: Justin_Flude (Xara Group Ltd) <camelotdev@xara.com> 00192 Created: 19/4/95 00193 Inputs: - 00194 Outputs: - 00195 Returns: The width of a line-width item, in millipoints. 00196 Purpose: Called by the line gallery formatting code. 00197 Errors: - 00198 SeeAlso: LineAttrItem::GetSize 00199 ********************************************************************************************/ 00200 00201 MILLIPOINT LineWidthItem::GetWidth() const 00202 { 00203 return 2 * LineAttrItem::GetWidth() / 3; 00204 } 00205 00206 00207 00208 /******************************************************************************************** 00209 > virtual CCRuntimeClass** LineWidthItem::GetAttribRuntimeClasses() const 00210 00211 Author: Justin_Flude (Xara Group Ltd) <camelotdev@xara.com> 00212 Created: 17/4/95 00213 Inputs: - 00214 Outputs: - 00215 Returns: The run-time class of the line attribute this type of display item 00216 represents. 00217 Purpose: Used when searching for display items representing the selection's current 00218 attributes. 00219 Errors: - 00220 SeeAlso: LineAttrItem::UpdateCurrentAttribStatus 00221 ********************************************************************************************/ 00222 00223 CCRuntimeClass** LineWidthItem::GetAttribRuntimeClasses() const 00224 { 00225 static CCRuntimeClass* aprtc[] = 00226 { 00227 CC_RUNTIME_CLASS(AttrLineWidth), 00228 NULL 00229 }; 00230 00231 return aprtc; 00232 } 00233 00234 00235 00236 /******************************************************************************************** 00237 > virtual BOOL LineWidthItem::IsEqualValueToAny(NodeAttribute** ppOtherAttribs) const 00238 00239 Author: Justin_Flude (Xara Group Ltd) <camelotdev@xara.com> 00240 Created: 17/4/95 00241 Inputs: pOtherAttrib the attribute value to compare this item to 00242 Outputs: - 00243 Returns: TRUE if this item represents the same attribute value as the given 00244 attribute. 00245 Purpose: Used when searching for display items representing the selection's current 00246 attributes. 00247 Errors: - 00248 SeeAlso: LineAttrItem::UpdateCurrentAttribStatus 00249 ********************************************************************************************/ 00250 00251 BOOL LineWidthItem::IsEqualValueToAny(NodeAttribute** ppOtherAttribs) const 00252 { 00253 AttrLineWidth* pattr = (AttrLineWidth*) *ppOtherAttribs; 00254 return pattr != NULL && pattr->Value.LineWidth == m_nWidth; 00255 } 00256 00257 00258 00259 /******************************************************************************************** 00260 > LineDashItem::LineDashItem(StockDash nDashType, const String& strDescription) 00261 00262 Author: Justin_Flude (Xara Group Ltd) <camelotdev@xara.com> 00263 Created: 10/4/95 00264 Inputs: nDashType an enum representing a stock dash pattern 00265 strDescription text description of this user-interface item 00266 Outputs: - 00267 Returns: - 00268 Purpose: Constructs a user-interface item representing a line's dash pattern. 00269 Errors: - 00270 SeeAlso: - 00271 ********************************************************************************************/ 00272 00273 LineDashItem::LineDashItem(StockDash nDashType, const String& strDescription) 00274 : LineAttrItem(strDescription, NO_LABEL), 00275 m_nDashType(nDashType) 00276 { 00277 // Empty. 00278 } 00279 00280 00281 00282 /******************************************************************************************** 00283 > virtual void LineDashItem::SetAttributes(RenderRegion* pRegion) const 00284 00285 Author: Justin_Flude (Xara Group Ltd) <camelotdev@xara.com> 00286 Created: 10/4/95 00287 Inputs: pRegion pointer to the render-region to draw into 00288 Outputs: - 00289 Returns: - 00290 Purpose: Sets the dash-pattern attributes in the given render-region to render this 00291 item correctly. 00292 Errors: - 00293 SeeAlso: - 00294 ********************************************************************************************/ 00295 00296 void LineDashItem::SetAttributes(RenderRegion* pRegion) const 00297 { 00298 // Set the dash pattern. 00299 pRegion->SetLineWidth(c_nDefaultLineWidth / 2); 00300 pRegion->SetDashPattern(m_nDashType); 00301 } 00302 00303 00304 00305 /******************************************************************************************** 00306 > virtual NodeAttribute* LineDashItem::CreateNewAttribute(BOOL) const 00307 00308 Author: Justin_Flude (Xara Group Ltd) <camelotdev@xara.com> 00309 Created: 10/4/95 00310 Inputs: - 00311 Outputs: - 00312 Returns: A pointer to a NodeAttribute-derivative that this user-interface item 00313 represents, ie. a dash-pattern attribute that can be passed to the 00314 attribute manager. 00315 Purpose: 00316 Errors: - 00317 SeeAlso: - 00318 ********************************************************************************************/ 00319 00320 NodeAttribute* LineDashItem::CreateNewAttribute(BOOL) const 00321 { 00322 AttrDashPattern* pAttr = new AttrDashPattern; 00323 if (pAttr != NULL) pAttr->Value.SetStockDashPattern(m_nDashType); 00324 return pAttr; 00325 } 00326 00327 00328 00329 /******************************************************************************************** 00330 > virtual MILLIPOINT LineDashItem::GetHeight() const 00331 00332 Author: Justin_Flude (Xara Group Ltd) <camelotdev@xara.com> 00333 Created: 17/4/95 00334 Inputs: - 00335 Outputs: - 00336 Returns: The height of this line gallery item, in millipoints. 00337 Purpose: Overrides the default height of items in the line gallery for dash pattern 00338 items, so they are half the usual height. 00339 Errors: - 00340 SeeAlso: LineAttrItem::CalculateMyRect; LineAttrItem::GetHeight 00341 ********************************************************************************************/ 00342 00343 MILLIPOINT LineDashItem::GetHeight() const 00344 { 00345 return LineAttrItem::GetHeight() / 2; 00346 } 00347 00348 00349 00350 /******************************************************************************************** 00351 > virtual CCRuntimeClass** LineDashItem::GetAttribRuntimeClasses() const 00352 00353 Author: Justin_Flude (Xara Group Ltd) <camelotdev@xara.com> 00354 Created: 17/4/95 00355 Inputs: - 00356 Outputs: - 00357 Returns: The run-time class of the line attribute this type of display item 00358 represents. 00359 Purpose: Used when searching for display items representing the selection's current 00360 attributes. 00361 Errors: - 00362 SeeAlso: LineAttrItem::UpdateCurrentAttribStatus 00363 ********************************************************************************************/ 00364 00365 CCRuntimeClass** LineDashItem::GetAttribRuntimeClasses() const 00366 { 00367 static CCRuntimeClass* aprtc[] = 00368 { 00369 CC_RUNTIME_CLASS(AttrDashPattern), 00370 NULL 00371 }; 00372 00373 return aprtc; 00374 } 00375 00376 00377 00378 /******************************************************************************************** 00379 > virtual BOOL LineDashItem::IsEqualValueToAny(NodeAttribute** ppOtherAttribs) const 00380 00381 Author: Justin_Flude (Xara Group Ltd) <camelotdev@xara.com> 00382 Created: 17/4/95 00383 Inputs: pOtherAttrib the attribute value to compare this item to 00384 Outputs: - 00385 Returns: TRUE if this item represents the same attribute value as the given 00386 attribute. 00387 Purpose: Used when searching for display items representing the selection's current 00388 attributes. 00389 Errors: - 00390 SeeAlso: LineAttrItem::UpdateCurrentAttribStatus 00391 ********************************************************************************************/ 00392 00393 BOOL LineDashItem::IsEqualValueToAny(NodeAttribute** ppOtherAttribs) const 00394 { 00395 DashPatternAttribute dpa; 00396 dpa.SetStockDashPattern(m_nDashType); 00397 AttrDashPattern* pattr = (AttrDashPattern*) *ppOtherAttribs; 00398 return pattr != NULL && pattr->Value.DashPattern == dpa.DashPattern; 00399 } 00400 00401 00402 00403 /******************************************************************************************** 00404 > LineArrowItem::LineArrowItem(StockArrow nArrowType, const String& strDescription) 00405 Author: Justin_Flude (Xara Group Ltd) <camelotdev@xara.com> 00406 Created: 10/4/95 00407 Inputs: nArrowType an enum representing a stock arrowhead/tail 00408 strDescription text description of this user-interface item 00409 Outputs: - 00410 Returns: - 00411 Purpose: Constructs a user-interface item representing an arrowhead/tail. 00412 NB. if -1 is passed for the nArrowType a blank, "no-arrow" arrowhead 00413 attribute is represented. 00414 Errors: - 00415 SeeAlso: - 00416 ********************************************************************************************/ 00417 00418 LineArrowItem::LineArrowItem(StockArrow nArrowType, double fpScale, 00419 const String& strDescription) 00420 : LineAttrItem(strDescription, NO_LABEL), 00421 m_fCentred(nArrowType == SA_SPOT || 00422 nArrowType == SA_DIAMOND || 00423 nArrowType == SA_HOLLOWDIAMOND) 00424 { 00425 // Fill in the blank ArrowRec object and scale it, if we have a valid stock arrow type. 00426 if (nArrowType != (StockArrow) -1) 00427 { 00428 m_arArrow.CreateStockArrow(nArrowType); 00429 m_arArrow.SetArrowSize((FIXED16) fpScale); 00430 } 00431 } 00432 00433 00434 00435 /******************************************************************************************** 00436 > virtual MILLIPOINT LineArrowItem::GetWidth() const 00437 00438 Author: Justin_Flude (Xara Group Ltd) <camelotdev@xara.com> 00439 Created: 13/4/95 00440 Inputs: - 00441 Outputs: - 00442 Returns: The width of this display item, in millipoints. 00443 Purpose: Overrides the default width of display items in the line gallery, making 00444 arrowhead items half the normal width. 00445 Errors: - 00446 SeeAlso: LineAttrItem::CalculateMyRect; LineAttrItem::GetWidth 00447 ********************************************************************************************/ 00448 00449 MILLIPOINT LineArrowItem::GetWidth() const 00450 { 00451 return 5 * LineAttrItem::GetWidth() / 8; 00452 } 00453 00454 00455 00456 /******************************************************************************************** 00457 > virtual MILLIPOINT LineArrowItem::GetHeight() const 00458 00459 Author: Justin_Flude (Xara Group Ltd) <camelotdev@xara.com> 00460 Created: 13/4/95 00461 Inputs: - 00462 Outputs: - 00463 Returns: The height of this display item, in millipoints. 00464 Purpose: Overrides the default width of display items in the line gallery, making 00465 arrowhead items one-and-a-half times the normal height. 00466 Errors: - 00467 SeeAlso: LineAttrItem::CalculateMyRect; LineAttrItem::GetHeight 00468 ********************************************************************************************/ 00469 00470 MILLIPOINT LineArrowItem::GetHeight() const 00471 { 00472 return 3 * LineAttrItem::GetHeight() / 2; 00473 } 00474 00475 00476 00477 /******************************************************************************************** 00478 > virtual MILLIPOINT LineArrowItem::GetHorzGap() const 00479 00480 Author: Justin_Flude (Xara Group Ltd) <camelotdev@xara.com> 00481 Created: 13/4/95 00482 Inputs: - 00483 Outputs: - 00484 Returns: The horizontal gap between this type of display item, in millipoints. 00485 Purpose: Overrides the default gap of display items in the line gallery, making 00486 arrowhead items more closely spaced horizontally than normal. 00487 Errors: - 00488 SeeAlso: LineAttrItem::CalculateMyRect; LineAttrItem::GetHorzGap 00489 ********************************************************************************************/ 00490 00491 MILLIPOINT LineArrowItem::GetHorzGap() const 00492 { 00493 return 0; 00494 } 00495 00496 00497 00498 /******************************************************************************************** 00499 > virtual MILLIPOINT LineArrowItem::GetVertGap() const 00500 00501 Author: Justin_Flude (Xara Group Ltd) <camelotdev@xara.com> 00502 Created: 20/4/95 00503 Inputs: - 00504 Outputs: - 00505 Returns: The line-spacing gap between arrowhead items. 00506 Purpose: Halves the vertical gap between arrowhead items. 00507 Errors: - 00508 SeeAlso: LineAttrItem::GetSize; LineAttrItem::GetVertGap 00509 ********************************************************************************************/ 00510 00511 MILLIPOINT LineArrowItem::GetVertGap() const 00512 { 00513 return LineAttrItem::GetVertGap() / 4; 00514 } 00515 00516 00517 00518 /******************************************************************************************** 00519 > virtual void LineArrowItem::SetAttributes(RenderRegion* pRegion) const 00520 00521 Author: Justin_Flude (Xara Group Ltd) <camelotdev@xara.com> 00522 Created: 10/4/95 00523 Inputs: pRegion pointer to the render-region to draw into 00524 Outputs: - 00525 Returns: - 00526 Purpose: Sets the arrowhead attributes in the given render-region to render this 00527 item. 00528 Errors: - 00529 SeeAlso: - 00530 ********************************************************************************************/ 00531 00532 void LineArrowItem::SetAttributes(RenderRegion* pRegion) const 00533 { 00534 pRegion->SetLineWidth(c_nDefaultLineWidth / 3); 00535 pRegion->SetStartArrow((ArrowRec&) m_arArrow); 00536 } 00537 00538 00539 00540 /******************************************************************************************** 00541 > virtual void LineArrowItem::DrawItem(RenderRegion* pRegion, const DocRect& drBounds) const 00542 00543 Author: Justin_Flude (Xara Group Ltd) <camelotdev@xara.com> 00544 Created: 10/4/95 00545 Inputs: pRegion pointer to the RenderRegion to draw into 00546 drBounds the bounds of the drawing area within the RenderRegion 00547 Outputs: - 00548 Returns: - 00549 Purpose: Formats and draws an arrowhead/tail. 00550 Errors: - 00551 SeeAlso: - 00552 ********************************************************************************************/ 00553 00554 void LineArrowItem::DrawItem(RenderRegion* pRegion, const DocRect& drBounds) const 00555 { 00556 // Calculate the mid-point of the bounding box. 00557 MILLIPOINT xMid = (drBounds.lo.x + drBounds.hi.x) / 2; 00558 MILLIPOINT yMid = (drBounds.lo.y + drBounds.hi.y) / 2; 00559 00560 // Work out where to draw the line to and from. This is a bodge worked out empirically 00561 // to get around the unfortunate Corel-like feature that arrowheads make lines longer 00562 // in an unknown way. 00563 const MILLIPOINT nFudge1 = drBounds.Width() / 7; 00564 const MILLIPOINT nFudge2 = 13 * drBounds.Width() / 84; 00565 DocCoord dcStart(xMid - nFudge1 + ((m_fCentred) ? (nFudge2 / 2) : nFudge2), yMid), 00566 dcEnd(drBounds.hi.x - nFudge1, yMid); 00567 00568 // Create and draw the path. 00569 Path pthLinePath; 00570 pthLinePath.Initialise(); 00571 pthLinePath.InsertMoveTo(dcStart); 00572 pthLinePath.InsertLineTo(dcEnd); 00573 pRegion->DrawPath(&pthLinePath); 00574 } 00575 00576 00577 00578 /******************************************************************************************** 00579 > virtual NodeAttribute* LineArrowItem::CreateNewAttribute(BOOL fIsAdjust) const 00580 00581 Author: Justin_Flude (Xara Group Ltd) <camelotdev@xara.com> 00582 Created: 10/4/95 00583 Inputs: fIsAdjust whether this item is being "applied" by a click with 00584 the Adjust modifier in force or not. This has the 00585 effect of applying the attribute to the "other" end 00586 of the line, eg. applying an "end-arrowhead" to the 00587 start of a line. 00588 Outputs: - 00589 Returns: - 00590 Purpose: A pointer to a NodeAttribute-derivative that this user-interface item 00591 represents, ie. an arrowhead attribute that can be passed to the 00592 attribute manager. This is either an AttrStartArrow or an AttrEndArrow, 00593 depending on the particular type of arrowhead and the state of the 00594 fIsAdjust parameter. 00595 Errors: - 00596 SeeAlso: - 00597 ********************************************************************************************/ 00598 00599 NodeAttribute* LineArrowItem::CreateNewAttribute(BOOL fIsAdjust) const 00600 { 00601 // Work out whether to make a start- or end-arrow attribute 00602 BOOL fMakeStart = IsStartArrow(); 00603 if (fIsAdjust) fMakeStart = !fMakeStart; 00604 00605 // Make the appropriate attribute. 00606 NodeAttribute* pNewAttr; 00607 if (fMakeStart) 00608 { 00609 // Make a start-arrow attribute. 00610 AttrStartArrow* pNewStartAttr = new AttrStartArrow; 00611 if (pNewStartAttr != NULL) pNewStartAttr->Value.StartArrow = m_arArrow; 00612 pNewAttr = pNewStartAttr; 00613 } 00614 else 00615 { 00616 // Make an end-arrow attribute. 00617 AttrEndArrow* pNewEndAttr = new AttrEndArrow; 00618 if (pNewEndAttr != NULL) pNewEndAttr->Value.EndArrow = m_arArrow; 00619 pNewAttr = pNewEndAttr; 00620 } 00621 00622 // Return the new attribute. 00623 return pNewAttr; 00624 } 00625 00626 00627 00628 /******************************************************************************************** 00629 > virtual CCRuntimeClass** LineArrowItem::GetAttribRuntimeClasses() const 00630 00631 Author: Justin_Flude (Xara Group Ltd) <camelotdev@xara.com> 00632 Created: 17/4/95 00633 Inputs: - 00634 Outputs: - 00635 Returns: The run-time class of the line attribute this type of display item 00636 represents. 00637 Purpose: Used when searching for display items representing the selection's current 00638 attributes. 00639 Errors: - 00640 SeeAlso: LineAttrItem::UpdateCurrentAttribStatus 00641 ********************************************************************************************/ 00642 00643 CCRuntimeClass** LineArrowItem::GetAttribRuntimeClasses() const 00644 { 00645 static CCRuntimeClass* aprtc[] = 00646 { 00647 CC_RUNTIME_CLASS(AttrStartArrow), 00648 CC_RUNTIME_CLASS(AttrEndArrow), 00649 NULL 00650 }; 00651 00652 return aprtc; 00653 } 00654 00655 00656 00657 /******************************************************************************************** 00658 > virtual BOOL LineArrowItem::IsEqualValueToAny(NodeAttribute** ppOtherAttribs) const 00659 00660 Author: Justin_Flude (Xara Group Ltd) <camelotdev@xara.com> 00661 Created: 17/4/95 00662 Inputs: pOtherAttrib the attribute values to compare this item to 00663 Outputs: - 00664 Returns: TRUE if this item represents the same attribute value as the given 00665 attribute. 00666 Purpose: Used when searching for display items representing the selection's current 00667 attributes. 00668 Errors: - 00669 SeeAlso: LineAttrItem::UpdateCurrentAttribStatus 00670 ********************************************************************************************/ 00671 00672 BOOL LineArrowItem::IsEqualValueToAny(NodeAttribute** ppOtherAttribs) const 00673 { 00674 AttrStartArrow* psattr = (AttrStartArrow*) *ppOtherAttribs; 00675 if (psattr != NULL && psattr->Value.StartArrow == m_arArrow) return TRUE; 00676 AttrEndArrow* peattr = (AttrEndArrow*) ppOtherAttribs[1]; 00677 return peattr != NULL && peattr->Value.EndArrow == m_arArrow; 00678 } 00679 00680 00681 00682 /******************************************************************************************** 00683 > virtual BOOL LineArrowItem::IsStartArrow() const 00684 00685 Author: Justin_Flude (Xara Group Ltd) <camelotdev@xara.com> 00686 Created: 25/4/95 00687 Returns: TRUE if this line gallery item represents a start arrow, FALSE if it 00688 represents an end arrow. 00689 Purpose: Used to work out what kind of AttrXXXXArrow attribute type to create in 00690 LineArrowItem::CreateNewAttribute. Can be overridden. This version 00691 asks the item's arrowhead record what kind it is. 00692 ********************************************************************************************/ 00693 00694 BOOL LineArrowItem::IsStartArrow() const 00695 { 00696 return ((ArrowRec&) m_arArrow).IsStartArrow(); 00697 } 00698 00699 00700 00701 /******************************************************************************************** 00702 00703 > virtual BOOL LineArrowItem::ShouldCloseOnDoubleClick(void) 00704 00705 Author: Jason_Williams (Xara Group Ltd) <camelotdev@xara.com> 00706 Created: 12/12/95 00707 00708 Returns: FALSE 00709 00710 Purpose: When an item is ctrl-double-clicked, the default action is to apply the 00711 item and close the gallery (for convenience). However, arrowheads do 00712 a special action for ctrl-double-click (they apply to the other end 00713 of the line) so they do not want auto-close to occur. 00714 00715 This function returns TRUE (auto-close) by default, and is overridden 00716 to return FALSE by this class, to stop the auto-close action. 00717 00718 SeeAlso: LineAttrItem::ShouldCloseOnDoubleClick 00719 00720 ********************************************************************************************/ 00721 00722 BOOL LineArrowItem::ShouldCloseOnDoubleClick(void) 00723 { 00724 return(FALSE); 00725 } 00726 00727 00728 00729 /******************************************************************************************** 00730 > LineNoArrowItem::LineNoArrowItem(const String& strDescription) 00731 00732 Author: Justin_Flude (Xara Group Ltd) <camelotdev@xara.com> 00733 Created: 19/4/95 00734 Inputs: strDescription text description of this item 00735 Outputs: - 00736 Returns: - 00737 Purpose: Constructs a "no-arrowhead" line gallery item. 00738 Errors: - 00739 SeeAlso: - 00740 ********************************************************************************************/ 00741 00742 LineNoArrowItem::LineNoArrowItem(const String& strDescription) 00743 : LineArrowItem((StockArrow) -1, 0, strDescription) 00744 { 00745 // Empty. 00746 } 00747 00748 00749 00750 /******************************************************************************************** 00751 > virtual MILLIPOINT LineNoArrowItem::GetWidth() const 00752 00753 Author: Justin_Flude (Xara Group Ltd) <camelotdev@xara.com> 00754 Created: 19/4/95 00755 Inputs: - 00756 Outputs: - 00757 Returns: The width of this item, in millipoints. 00758 Purpose: Forces a "no-arrow" item to be full-width. 00759 Errors: - 00760 SeeAlso: - 00761 ********************************************************************************************/ 00762 00763 MILLIPOINT LineNoArrowItem::GetWidth() const 00764 { 00765 return 2 * LineArrowItem::GetWidth(); 00766 } 00767 00768 00769 00770 /******************************************************************************************** 00771 > virtual MILLIPOINT LineNoArrowItem::GetHeight() const 00772 00773 Author: Justin_Flude (Xara Group Ltd) <camelotdev@xara.com> 00774 Created: 21/4/95 00775 Inputs: - 00776 Outputs: - 00777 Returns: The height of this item, in millipoints. 00778 Purpose: Called by the line gallery formatting code. 00779 Errors: - 00780 SeeAlso: - 00781 ********************************************************************************************/ 00782 00783 MILLIPOINT LineNoArrowItem::GetHeight() const 00784 { 00785 return LineAttrItem::GetHeight(); 00786 } 00787 00788 00789 00790 /******************************************************************************************** 00791 > virtual MILLIPOINT LineNoArrowItem::GetVertGap() const 00792 00793 Author: Justin_Flude (Xara Group Ltd) <camelotdev@xara.com> 00794 Created: 21/4/95 00795 Inputs: - 00796 Outputs: - 00797 Returns: The vertical gap between this "no arrow" item and other "arrowhead" items 00798 within the line gallery. 00799 Purpose: Called by the formatting code of the line gallery. 00800 Errors: - 00801 SeeAlso: - 00802 ********************************************************************************************/ 00803 00804 MILLIPOINT LineNoArrowItem::GetVertGap() const 00805 { 00806 return LineArrowItem::GetVertGap() / 3; 00807 } 00808 00809 00810 00811 /******************************************************************************************** 00812 > virtual void LineNoArrowItem::SetAttributes(RenderRegion*) const 00813 00814 Author: Justin_Flude (Xara Group Ltd) <camelotdev@xara.com> 00815 Created: 19/4/95 00816 Inputs: - 00817 Outputs: - 00818 Returns: - 00819 Purpose: Overrides attribute setting for arrowheads to set NO attribute. 00820 Errors: - 00821 SeeAlso: - 00822 ********************************************************************************************/ 00823 00824 void LineNoArrowItem::SetAttributes(RenderRegion*) const 00825 { 00826 // Empty, as we have no attributes required to render this item. 00827 } 00828 00829 00830 00831 /******************************************************************************************** 00832 > virtual void LineNoArrowItem::DrawItem(RenderRegion* pRegion, 00833 const DocRect& drBounds) const 00834 Author: Justin_Flude (Xara Group Ltd) <camelotdev@xara.com> 00835 Created: 19/4/95 00836 Inputs: pRegion the render-region to draw into 00837 drBounds the bounding box of this item to draw within 00838 Outputs: - 00839 Returns: - 00840 Purpose: Draws a "no-arrowhead" item. 00841 Errors: - 00842 SeeAlso: - 00843 ********************************************************************************************/ 00844 00845 void LineNoArrowItem::DrawItem(RenderRegion* pRegion, const DocRect& drBounds) const 00846 { 00847 // Work out the difference in width between the text string and the bounding box. 00848 MILLIPOINT nWidthDiff = drBounds.Width() - (GetDescription().Length() * c_nAveCharWidth); 00849 00850 // Draw the item's description centred within the new bounding box, if it will fit. 00851 DocRect drTextBounds(drBounds); 00852 if (nWidthDiff > 0) drTextBounds.Inflate(-nWidthDiff / 2, 0); 00853 pRegion->DrawFixedSystemText(&((String&) GetDescription()), drTextBounds); 00854 } 00855 00856 00857 00858 /******************************************************************************************** 00859 > LineNoStartArrowItem::LineNoStartArrowItem(const String& strDescription) 00860 00861 Author: Justin_Flude (Xara Group Ltd) <camelotdev@xara.com> 00862 Created: 19/4/95 00863 Inputs: strDescription text description of this item 00864 Outputs: - 00865 Returns: - 00866 Purpose: Constructs a "no-arrowhead" line gallery item. 00867 Errors: - 00868 SeeAlso: - 00869 ********************************************************************************************/ 00870 00871 LineNoStartArrowItem::LineNoStartArrowItem(const String& strDescription) 00872 : LineNoArrowItem(strDescription) 00873 { 00874 // Empty. 00875 } 00876 00877 00878 00879 /******************************************************************************************** 00880 > virtual BOOL LineNoStartArrowItem::IsEqualValueToAny(NodeAttribute** ppOtherAttribs) const 00881 00882 Author: Justin_Flude (Xara Group Ltd) <camelotdev@xara.com> 00883 Created: 17/4/95 00884 Inputs: pOtherAttrib the attribute values to compare this item to 00885 Outputs: - 00886 Returns: TRUE if this item represents the same attribute value as the given 00887 attribute. 00888 Purpose: Used when searching for display items representing the selection's current 00889 attributes. 00890 Errors: - 00891 SeeAlso: LineAttrItem::UpdateCurrentAttribStatus 00892 ********************************************************************************************/ 00893 00894 BOOL LineNoStartArrowItem::IsEqualValueToAny(NodeAttribute** ppOtherAttribs) const 00895 { 00896 AttrStartArrow* psattr = (AttrStartArrow*) *ppOtherAttribs; 00897 return psattr != NULL && psattr->Value.StartArrow == m_arArrow; 00898 } 00899 00900 00901 00902 /******************************************************************************************** 00903 > virtual BOOL LineNoStartArrowItem::IsStartArrow() const 00904 00905 Author: Justin_Flude (Xara Group Ltd) <camelotdev@xara.com> 00906 Created: 25/4/95 00907 Returns: TRUE, as a LineNoStartArrowItem always represents a start arrow attribute. 00908 Purpose: Used to work out what kind of AttrXXXXArrow attribute type to create in 00909 LineArrowItem::CreateNewAttribute. 00910 ********************************************************************************************/ 00911 00912 BOOL LineNoStartArrowItem::IsStartArrow() const 00913 { 00914 return TRUE; 00915 } 00916 00917 00918 00919 /******************************************************************************************** 00920 > LineNoEndArrowItem::LineNoEndArrowItem(const String& strDescription) 00921 00922 Author: Justin_Flude (Xara Group Ltd) <camelotdev@xara.com> 00923 Created: 19/4/95 00924 Inputs: strDescription text description of this item 00925 Outputs: - 00926 Returns: - 00927 Purpose: Constructs a "no-arrowhead" line gallery item. 00928 Errors: - 00929 SeeAlso: - 00930 ********************************************************************************************/ 00931 00932 LineNoEndArrowItem::LineNoEndArrowItem(const String& strDescription) 00933 : LineNoArrowItem(strDescription) 00934 { 00935 // Empty. 00936 } 00937 00938 00939 00940 /******************************************************************************************** 00941 > virtual BOOL LineNoEndArrowItem::IsEqualValueToAny(NodeAttribute** ppOtherAttribs) const 00942 00943 Author: Justin_Flude (Xara Group Ltd) <camelotdev@xara.com> 00944 Created: 17/4/95 00945 Inputs: pOtherAttrib the attribute values to compare this item to 00946 Outputs: - 00947 Returns: TRUE if this item represents the same attribute value as the given 00948 attribute. 00949 Purpose: Used when searching for display items representing the selection's current 00950 attributes. 00951 Errors: - 00952 SeeAlso: LineAttrItem::UpdateCurrentAttribStatus 00953 ********************************************************************************************/ 00954 00955 BOOL LineNoEndArrowItem::IsEqualValueToAny(NodeAttribute** ppOtherAttribs) const 00956 { 00957 AttrEndArrow* peattr = (AttrEndArrow*) ppOtherAttribs[1]; 00958 return peattr != NULL && peattr->Value.EndArrow == m_arArrow; 00959 } 00960 00961 00962 00963 /******************************************************************************************** 00964 > virtual BOOL LineNoEndArrowItem::IsStartArrow() const 00965 00966 Author: Justin_Flude (Xara Group Ltd) <camelotdev@xara.com> 00967 Created: 25/4/95 00968 Returns: FALSE, as a LineNoEndArrowItem always represents an end arrow attribute. 00969 Purpose: Used to work out what kind of AttrXXXXArrow attribute type to create in 00970 LineArrowItem::CreateNewAttribute. 00971 ********************************************************************************************/ 00972 00973 BOOL LineNoEndArrowItem::IsStartArrow() const 00974 { 00975 return FALSE; 00976 } 00977 00978 00979 00980 /******************************************************************************************** 00981 > LineCapItem::LineCapItem(LineCapType nCapType, const String& strDescription) 00982 00983 Author: Justin_Flude (Xara Group Ltd) <camelotdev@xara.com> 00984 Created: 10/4/95 00985 Inputs: nCapType an enum representing a stock line-cap 00986 strDescription text description of this user-interface item 00987 Outputs: - 00988 Returns: - 00989 Purpose: Constructs an line-cap user-interface item. 00990 Errors: - 00991 SeeAlso: - 00992 ********************************************************************************************/ 00993 00994 LineCapItem::LineCapItem(LineCapType nCapType, const String& strDescription) 00995 : LineAttrItem(strDescription, NO_LABEL), 00996 m_nCapType(nCapType) 00997 { 00998 // Empty. 00999 } 01000 01001 01002 01003 /******************************************************************************************** 01004 > virtual void LineCapItem::SetAttributes(RenderRegion* pRegion) const 01005 01006 Author: Justin_Flude (Xara Group Ltd) <camelotdev@xara.com> 01007 Created: 10/4/95 01008 Inputs: pRegion pointer to the render-region to draw into 01009 Outputs: - 01010 Returns: - 01011 Purpose: Sets the line-cap attributes in the given render-region to render this 01012 item correctly. 01013 Errors: - 01014 SeeAlso: - 01015 ********************************************************************************************/ 01016 01017 void LineCapItem::SetAttributes(RenderRegion* pRegion) const 01018 { 01019 // Call the SetStartCap function (there are no 'end' caps) and make lines thick. 01020 StartCapAttribute* pAttr = new StartCapAttribute; 01021 pAttr->StartCap = m_nCapType; 01022 pRegion->SetStartCap(pAttr, TRUE); 01023 pRegion->SetLineWidth(c_nHorzSizeOfItem / 2); 01024 } 01025 01026 01027 01028 /******************************************************************************************** 01029 > virtual NodeAttribute* LineCapItem::CreateNewAttribute(BOOL) const 01030 01031 Author: Justin_Flude (Xara Group Ltd) <camelotdev@xara.com> 01032 Created: 10/4/95 01033 Inputs: - 01034 Outputs: - 01035 Returns: - 01036 Purpose: A pointer to a NodeAttribute-derivative that this user-interface item 01037 represents, ie. a line-cap attribute that can be passed to the 01038 attribute manager. 01039 Errors: - 01040 SeeAlso: - 01041 ********************************************************************************************/ 01042 01043 NodeAttribute* LineCapItem::CreateNewAttribute(BOOL) const 01044 { 01045 AttrStartCap* pAttr = new AttrStartCap; 01046 if (pAttr != NULL) pAttr->Value.StartCap = m_nCapType; 01047 return pAttr; 01048 } 01049 01050 01051 01052 01053 /******************************************************************************************** 01054 > virtual CCRuntimeClass** LineCapItem::GetAttribRuntimeClasses() const 01055 01056 Author: Justin_Flude (Xara Group Ltd) <camelotdev@xara.com> 01057 Created: 17/4/95 01058 Inputs: - 01059 Outputs: - 01060 Returns: The run-time class of the line attribute this type of display item 01061 represents. 01062 Purpose: Used when searching for display items representing the selection's current 01063 attributes. 01064 Errors: - 01065 SeeAlso: LineAttrItem::UpdateCurrentAttribStatus 01066 ********************************************************************************************/ 01067 01068 CCRuntimeClass** LineCapItem::GetAttribRuntimeClasses() const 01069 { 01070 static CCRuntimeClass* aprtc[] = 01071 { 01072 CC_RUNTIME_CLASS(AttrStartCap), 01073 NULL 01074 }; 01075 01076 return aprtc; 01077 } 01078 01079 01080 01081 /******************************************************************************************** 01082 > virtual BOOL LineCapItem::IsEqualValueToAny(NodeAttribute** ppOtherAttribs) const 01083 01084 Author: Justin_Flude (Xara Group Ltd) <camelotdev@xara.com> 01085 Created: 17/4/95 01086 Inputs: pOtherAttrib the attribute value to compare this item to 01087 Outputs: - 01088 Returns: TRUE if this item represents the same attribute value as the given 01089 attribute. 01090 Purpose: Used when searching for display items representing the selection's current 01091 attributes. 01092 Errors: - 01093 SeeAlso: LineAttrItem::UpdateCurrentAttribStatus 01094 ********************************************************************************************/ 01095 01096 BOOL LineCapItem::IsEqualValueToAny(NodeAttribute** ppOtherAttribs) const 01097 { 01098 AttrStartCap* pattr = (AttrStartCap*) *ppOtherAttribs; 01099 return pattr != NULL && pattr->Value.StartCap == m_nCapType; 01100 } 01101 01102 01103 01104 /******************************************************************************************** 01105 > LineJoinTypeItem::LineJoinTypeItem(JointType nJoinType, const String& strDescription) 01106 01107 Author: Justin_Flude (Xara Group Ltd) <camelotdev@xara.com> 01108 Created: 10/4/95 01109 Inputs: nJoinType an enum representing a stock line-join 01110 strDescription text description of this user-interface item 01111 Outputs: - 01112 Returns: - 01113 Purpose: Constructs an line-join user-interface item. 01114 Errors: - 01115 SeeAlso: - 01116 ********************************************************************************************/ 01117 01118 LineJoinTypeItem::LineJoinTypeItem(JointType nJoinType, const String& strDescription) 01119 : LineAttrItem(strDescription, NO_LABEL), 01120 m_nJoinType(nJoinType) 01121 { 01122 // Empty. 01123 } 01124 01125 01126 01127 /******************************************************************************************** 01128 > virtual void LineJoinTypeItem::SetAttributes(RenderRegion* pRegion) const 01129 01130 Author: Justin_Flude (Xara Group Ltd) <camelotdev@xara.com> 01131 Created: 10/4/95 01132 Inputs: pRegion pointer to the render-region to draw into 01133 Outputs: - 01134 Returns: - 01135 Purpose: Sets the line-join attributes in the given render-region to render this 01136 item correctly. 01137 Errors: - 01138 SeeAlso: - 01139 ********************************************************************************************/ 01140 01141 void LineJoinTypeItem::SetAttributes(RenderRegion* pRegion) const 01142 { 01143 // Set the join-type and make the lines even wider. 01144 JoinTypeAttribute* pAttr = new JoinTypeAttribute; 01145 pAttr->JoinType = m_nJoinType; 01146 pRegion->SetJoinType(pAttr, TRUE); 01147 pRegion->SetLineWidth(c_nHorzSizeOfItem / 2); 01148 } 01149 01150 01151 01152 /******************************************************************************************** 01153 > virtual void LineJoinTypeItem::DrawItem(RenderRegion* pRegion, 01154 const DocRect& drBounds) const 01155 Author: Justin_Flude (Xara Group Ltd) <camelotdev@xara.com> 01156 Created: 10/4/95 01157 Inputs: pRegion pointer to the RenderRegion to draw into 01158 drBounds the bounds of the drawing area within the RenderRegion 01159 Outputs: - 01160 Returns: - 01161 Purpose: Formats and draws a line-join. 01162 Errors: - 01163 SeeAlso: - 01164 ********************************************************************************************/ 01165 01166 void LineJoinTypeItem::DrawItem(RenderRegion* pRegion, const DocRect& drBounds) const 01167 { 01168 // Find the mid-points of the horizontal and vertical edges. 01169 MILLIPOINT xMid = (drBounds.lo.x + drBounds.hi.x) / 2; 01170 MILLIPOINT yMid = (drBounds.lo.y + drBounds.hi.y) / 2; 01171 01172 // Create a right-angle path. 01173 Path pthJoinPath; 01174 pthJoinPath.Initialise(); 01175 pthJoinPath.InsertMoveTo(DocCoord(xMid, drBounds.lo.y)); 01176 pthJoinPath.InsertLineTo(DocCoord(xMid, yMid)); 01177 pthJoinPath.InsertLineTo(DocCoord(drBounds.lo.x, yMid)); 01178 01179 // Now render the path. The join-type will be apparent at the "cusp". 01180 pRegion->DrawPath(&pthJoinPath); 01181 } 01182 01183 01184 01185 /******************************************************************************************** 01186 > virtual NodeAttribute* LineJoinTypeItem::CreateNewAttribute(BOOL) const 01187 01188 Author: Justin_Flude (Xara Group Ltd) <camelotdev@xara.com> 01189 Created: 10/4/95 01190 Inputs: - 01191 Outputs: - 01192 Returns: - 01193 Purpose: A pointer to a NodeAttribute-derivative that this user-interface item 01194 represents, ie. a line-join attribute that can be passed to the 01195 attribute manager. 01196 Errors: - 01197 SeeAlso: - 01198 ********************************************************************************************/ 01199 01200 NodeAttribute* LineJoinTypeItem::CreateNewAttribute(BOOL) const 01201 { 01202 AttrJoinType* pAttr = new AttrJoinType; 01203 if (pAttr != NULL) pAttr->Value.JoinType = m_nJoinType; 01204 return pAttr; 01205 } 01206 01207 01208 01209 /******************************************************************************************** 01210 > virtual CCRuntimeClass** LineJoinTypeItem::GetAttribRuntimeClasses() const 01211 01212 Author: Justin_Flude (Xara Group Ltd) <camelotdev@xara.com> 01213 Created: 17/4/95 01214 Inputs: - 01215 Outputs: - 01216 Returns: The run-time class of the line attribute this type of display item 01217 represents. 01218 Purpose: Used when searching for display items representing the selection's current 01219 attributes. 01220 Errors: - 01221 SeeAlso: LineAttrItem::UpdateCurrentAttribStatus 01222 ********************************************************************************************/ 01223 01224 CCRuntimeClass** LineJoinTypeItem::GetAttribRuntimeClasses() const 01225 { 01226 static CCRuntimeClass* aprtc[] = 01227 { 01228 CC_RUNTIME_CLASS(AttrJoinType), 01229 NULL 01230 }; 01231 01232 return aprtc; 01233 } 01234 01235 01236 01237 /******************************************************************************************** 01238 > virtual BOOL LineJoinTypeItem::IsEqualValueToAny(NodeAttribute** ppOtherAttribs) const 01239 01240 Author: Justin_Flude (Xara Group Ltd) <camelotdev@xara.com> 01241 Created: 17/4/95 01242 Inputs: pOtherAttrib the attribute value to compare this item to 01243 Outputs: - 01244 Returns: TRUE if this item represents the same attribute value as the given 01245 attribute. 01246 Purpose: Used when searching for display items representing the selection's current 01247 attributes. 01248 Errors: - 01249 SeeAlso: LineAttrItem::UpdateCurrentAttribStatus 01250 ********************************************************************************************/ 01251 01252 BOOL LineJoinTypeItem::IsEqualValueToAny(NodeAttribute** ppOtherAttribs) const 01253 { 01254 AttrJoinType* pattr = (AttrJoinType*) *ppOtherAttribs; 01255 return pattr != NULL && pattr->Value.JoinType == m_nJoinType; 01256 }