00001 // $Id: arrows.h 751 2006-03-31 15:43: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 // Defines ArrowRec class (a Line ArrowHead Record) 00099 00100 #ifndef INC_ARROW 00101 #define INC_ARROW 00102 00103 #include "fixed16.h" 00104 #include "doccoord.h" 00105 #include "paths.h" 00106 00107 class Trans2DMatrix; 00108 00109 const INT32 DEFAULT_ARROW_LINEWIDTH = (72000/2); 00110 const INT32 DEFAULT_ARROW_SIZE = 3; 00111 00112 /******************************************************************************************** 00113 00114 < StockArrow 00115 00116 Comment: 00117 MonoOn 00118 enum StockArrow 00119 { 00120 SA_NULLARROW, 00121 SA_STRAIGHTARROW, 00122 SA_ANGLEDARROW, 00123 SA_ROUNDEDARROW, 00124 SA_SPOT, 00125 SA_DIAMOND, 00126 SA_ARROWFEATHER 00127 SA_ARROWFEATHER2, 00128 SA_HOLLOWDIAMOND 00129 }; 00130 MonoOff 00131 00132 ********************************************************************************************/ 00133 00134 enum StockArrow 00135 { 00136 SA_NULLARROW, 00137 SA_STRAIGHTARROW, 00138 SA_ANGLEDARROW, 00139 SA_ROUNDEDARROW, 00140 SA_SPOT, 00141 SA_DIAMOND, 00142 SA_ARROWFEATHER, 00143 SA_ARROWFEATHER2, 00144 SA_HOLLOWDIAMOND, 00145 00146 NUM_STOCK_ARROWS 00147 }; 00148 00149 /******************************************************************************************** 00150 00151 > class ArrowRec : public CCObject 00152 00153 Author: Will_Cowling (Xara Group Ltd) <camelotdev@xara.com> 00154 Created: 4/4/95 00155 Purpose: A class defining a Line ArrowHead Record. 00156 00157 ********************************************************************************************/ 00158 00159 class ArrowRec : public CCObject 00160 { 00161 CC_DECLARE_DYNCREATE(ArrowRec); 00162 00163 public: 00164 00165 // Construction 00166 ArrowRec(); 00167 ArrowRec(Path* pArrowPath, const DocCoord& Centre, 00168 INT32 LineWidth = DEFAULT_ARROW_LINEWIDTH, 00169 FIXED16 WidthScale = DEFAULT_ARROW_SIZE, 00170 FIXED16 HeightScale = DEFAULT_ARROW_SIZE, 00171 BOOL Start = FALSE); 00172 00173 // Copy constructor 00174 ArrowRec(const ArrowRec&); 00175 00176 // Destruction 00177 ~ArrowRec(); 00178 00179 //Initialisation 00180 BOOL CreateStockArrow(StockArrow); 00181 00182 void SetArrowSize(FIXED16 Width, FIXED16 Height = 0); 00183 00184 // Copying and equality 00185 INT32 operator==(const ArrowRec&); 00186 ArrowRec& operator=(const ArrowRec&); 00187 00188 INT32 operator==(StockArrow); 00189 ArrowRec& operator=(StockArrow); 00190 00191 // Arrow Data access 00192 Path* GetArrowPath(); 00193 DocCoord GetArrowCentre(); 00194 INT32 GetArrowLineWidth(); 00195 FIXED16 GetArrowWidth(); 00196 FIXED16 GetArrowHeight(); 00197 00198 BOOL IsStartArrow(); 00199 BOOL ShouldScaleWithLineWidth(); 00200 00201 INT32 GetArrowID(); 00202 00203 // Position and bounds calculations 00204 DocRect GetArrowBoundingRect(Path* pParent, INT32 LineWidth, BOOL StartArrow); 00205 00206 BOOL GetArrowMatrix(const DocCoord& Centre, const DocCoord& Direction, 00207 INT32 LineWidth, Trans2DMatrix* pMatrix); 00208 00209 // Statics for getting arrow positions within paths 00210 static BOOL DoesPathNeedArrowHeads(DocCoord* Coords, PathVerb* Verbs, INT32 NumCoords); 00211 00212 static BOOL GetFirstArrowPos(BOOL StartArrow, 00213 DocCoord* Coords, PathVerb* Verbs, INT32 NumCoords, 00214 INT32* Index, DocCoord* Centre, DocCoord* Direction); 00215 00216 static BOOL GetNextArrowPos(BOOL StartArrow, 00217 DocCoord* Coords, PathVerb* Verbs, INT32 NumCoords, 00218 INT32* Index, DocCoord* Centre, DocCoord* Direction); 00219 00220 // Check for a dummy ArrowHead 00221 inline BOOL IsNullArrow() { return (ArrowShape == NULL || IsNull); } 00222 00223 // Number of Stock Arrows available 00224 static INT32 GetNumStockArrows() { return NUM_STOCK_ARROWS; } 00225 static String_256 GetStockArrowName(StockArrow); 00226 00227 // Angle calculation 00228 static ANGLE CalcAngle(const DocCoord& Centre, const DocCoord& Direction); 00229 00230 private: 00231 DocRect FindBoundsAt(const DocCoord& Centre, const DocCoord& Direction, INT32 LineWidth); 00232 00233 public: 00234 Path* ArrowShape; 00235 DocCoord Centre; 00236 INT32 LineWidth; 00237 FIXED16 ArrowWidth; 00238 FIXED16 ArrowHeight; 00239 00240 BOOL StartArrow; 00241 BOOL ScaleWithLineWidth; 00242 INT32 ArrowID; 00243 00244 // For backwards compatability 00245 BOOL IsNull; 00246 00247 // gets the base of the arrow (in arrow coordinates i.e. before it's been transformed 00248 // by the matrix delivered in GetArrowMatrix) 00249 void GetArrowBase(DocCoord * pPoint); 00250 00251 // flag to indicate that the arrow is outside of the path 00252 BOOL m_bExtendPath; 00253 }; 00254 00255 #endif // INC_ARROW