00001 // $Id: freehand.h 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 // The FreeHand Tool 00099 // Created by Rik on 2/9/93 00100 00101 00102 00103 #ifndef INC_FREEHAND 00104 #define INC_FREEHAND 00105 00106 00107 //#include "tool.h" - in camtypes.h [AUTOMATICALLY REMOVED] 00108 //#include "selop.h" - in camtypes.h [AUTOMATICALLY REMOVED] 00109 //#include "doccoord.h" - in camtypes.h [AUTOMATICALLY REMOVED] 00110 #include "wrkrect.h" 00111 //#include "binds.h" - in camtypes.h [AUTOMATICALLY REMOVED] 00112 //#include "grndbrsh.h" 00113 #include "brshcomp.h" 00114 #include "brshdata.h" 00115 #include "dragtool.h" 00116 00117 class NodePath; 00118 class Cursor; 00119 class FreeHandInfoBarOp; 00120 class NodeBrushPath; 00121 class Progress; 00122 class Trans2DMatrix; 00123 class BlendRef; 00124 class GRenderBrush; 00125 00126 /******************************************************************************************** 00127 00128 < struct FreeHandJoinInfo 00129 00130 Author: Rik_Heywood (Xara Group Ltd) <camelotdev@xara.com> 00131 Created: 24/10/94 00132 Purpose: Holds assorted data used to help join new path with existing paths 00133 00134 ********************************************************************************************/ 00135 00136 struct FreeHandJoinInfo 00137 { 00138 NodePath* pJoinPath; // The Path that we will try to join with 00139 BOOL IsNearEndPoint; // TRUE if we are to join at an open endpoint 00140 INT32 CloseSlot; // The element number we were closest to 00141 double Into; // The normalised distance along the element that we were closest to 00142 BrushHandle m_BrushHandle; // if we are going to join to a brush, this identifies which one 00143 BrushData m_BrushData; // likewise this holds data from the brush we ar about to join to 00144 MILLIPOINT FirstBrushSpacing; // the first spacing for the brush 00145 AttrBrushType* pAttrBrush; 00146 MILLIPOINT BrushDistance; 00147 DocColour StrokeColour; 00148 BOOL UseLocalColour; 00149 BOOL UseNamedColour; 00150 }; 00151 00152 00153 // flag which indicates when the offscreen buffer for the brush should be next updated. 00154 typedef enum UPDATE_STATE { 00155 UPDATE_NOW, 00156 UPDATE_ONIDLE, 00157 UPDATE_NEVER 00158 }; 00159 00160 00161 /******************************************************************************************** 00162 > class FreeHandTool : public Tool_v1 00163 00164 Author: Rik_Heywood (Xara Group Ltd) <camelotdev@xara.com> 00165 Created: 20/7/93 00166 Purpose: This class handles the Free Hand Tool that is used to draw lines that follow 00167 the path of the Mouse Pointer. 00168 ********************************************************************************************/ 00169 00170 class CCAPI FreeHandTool : public DragTool 00171 { 00172 // Give my name in memory dumps 00173 CC_DECLARE_MEMDUMP(FreeHandTool); 00174 00175 public: 00176 FreeHandTool(); 00177 ~FreeHandTool(); 00178 BOOL Init(); 00179 void Describe(void* InfoPtr); 00180 UINT32 GetID(); 00181 00182 // Event Handlers 00183 virtual void SelectChange(BOOL); 00184 virtual void OnClick( DocCoord, ClickType, ClickModifiers, Spread* ); 00185 virtual void OnMouseMove(DocCoord, Spread*, ClickModifiers); 00186 virtual BOOL GetStatusLineText(String_256* ptext, Spread*, DocCoord, ClickModifiers); 00187 00188 virtual BOOL OnIdle(); 00189 00190 // Rendering the blobs functions 00191 virtual void RenderToolBlobs(Spread*, DocRect*); 00192 00193 // Communication with the InfoBar 00194 void SetSmoothness(INT32 Smooth); 00195 INT32 GetSmoothness(); 00196 void PreviousPathInvalid(); 00197 void SetPreviousPath(NodePath*, INT32 Start, INT32 Len); 00198 00199 FreeHandInfoBarOp* GetInfoBar() { return pInfoBarOp;} 00200 00201 // functions to deal with the retro path validation 00202 BOOL IsRetroPathStillValid(); 00203 INT32 BuildPathCRC(NodePath*); 00204 void TranslateTrackData(); 00205 00206 // Retro Fitting functions 00207 void RetroFitChanging(); 00208 void RetroFitFinished(); 00209 00210 00211 public: // brush functions 00212 00213 void CreateBrush(); 00214 void SetCurrentBrushHandle(); 00215 // finds the current default brush attribute 00216 00217 MILLIPOINT GetBrushSpacing(); 00218 void SetBrushSpacing(MILLIPOINT Spacing); 00219 BrushHandle GetBrushHandle() { return m_BrushHandle;} 00220 00221 void BrushFinished(); 00222 BOOL BrushSelected(BrushHandle Handle, BOOL ApplyToSelection = TRUE); 00223 // tells the tool that the given brush has become the default attribute 00224 00225 BOOL ApplyBrushToSelection(BrushHandle Handle); 00226 00227 void ScreenChanged(BOOL WipeRegion = FALSE); 00228 // notifies the tool that the screen has changed 00229 00230 void InitialiseJoinInfoForBrush(AttrBrushType* pAttrBrush, NodePath* pNodePath, DocCoord JoinPoint); 00231 // sets up JoinInfo to join with the given brush 00232 00233 void BrushDeleted(BrushHandle Handle); 00234 // lets the tool know we have deleted a brush 00235 00236 BOOL SetBrushUpdateState(UPDATE_STATE State); // tells us when to next update the brush 00237 00238 protected: 00239 // the big bitmap that is passed to opdrawbrush 00240 GRenderBrush* GetBigGRenderBrush(Spread* pSpread); 00241 BOOL InitialiseBrushBitmaps(GRenderBrush* pGRender); 00242 00243 GRenderBrush* m_pGRenderBrush; 00244 00245 // gets the brush selected to be default current attribute 00246 BrushDefinition* GetSelectedBrush(); 00247 00248 UPDATE_STATE m_UpdateBrushState; //indicates when we will update the offscreen buffer 00249 protected: 00250 // Helper functions 00251 // Functions to load, remove and change the active cursor 00252 BOOL LoadCursors(); 00253 void RemoveCursors(); 00254 void ChangeCursor(Cursor* pCursor); 00255 00256 // Functions to help decide what the mouse is over before the drag starts 00257 BOOL IsCursorNearEndPoint(NodePath* pPath, const DocRect& BlobRect); 00258 BOOL IsCursorNearPath(NodePath* pPath, INT32 Range, const DocCoord& PointerPos); 00259 00260 // Functions to help manage the paths we control 00261 BOOL GetNewPaths(); 00262 BOOL DeletePaths(); 00263 00264 BOOL InitialiseBlendRef(NodeRenderableInk* pInk); 00265 BOOL NodeHasLineWidth(NodeRenderableInk* pNode); 00266 00267 void SetColourEditorProcessing(BOOL Value); 00268 protected: 00269 DocRect GetLargestInkBoundingRect(); //retrieves the bounding rect of the largest brush ink node 00270 void InitialiseBrushInkNodeArray(UINT32 NumObjects); 00271 void LaunchBrushDefinitionDialog(BrushHandle Handle); 00272 00273 static TCHAR* FamilyName; // The Tools Family Name 00274 static TCHAR* ToolName; // The Tool Name 00275 static TCHAR* Purpose; // What the tool is for 00276 static TCHAR* Author; // Who wrote it 00277 00278 // The required smoothness 00279 INT32 Smoothness; 00280 00281 // The status line text 00282 String_256 StatusMsg; 00283 00284 // The coord of the initial click 00285 DocCoord StartPos; 00286 Spread* StartSpread; 00287 00288 // Data used to retro fit the path 00289 // The Mouse Track path that holds the last set of mouse move positions 00290 Path* TrackData; 00291 Path* RetroPath; 00292 INT32 StartSlot; 00293 INT32 NumSlots; 00294 INT32 PathCRC; 00295 NodePath* PreviousPath; 00296 BOOL AreWeRetroFitting; 00297 BOOL IsPreviousPathValid; 00298 BOOL IsRetroPathValid; 00299 BOOL IsSelectBlobsOnScreen; 00300 00301 // The tools cursor 00302 Cursor* pNormalCursor; // The normal cursor 00303 Cursor* pJoinCursor; // The cursor used when Joining is possible 00304 Cursor* pActiveCursor; // Whichever cursor is being displayed (see ChangeCursor). 00305 Cursor* pModifyCursor; // The cursor that appears when it is possible to modify the line 00306 INT32 CurrentCursorID; // ID of the current cursor on the stack 00307 00308 // The path we need to join with if we start over one of its endpoints 00309 FreeHandJoinInfo JoinInfo; 00310 00311 // The info bar 00312 FreeHandInfoBarOp* pInfoBarOp; 00313 00314 std::vector< NodeRenderableInk * > m_BrushInkNodeArray; 00315 // as safer alternative to m_pBrushInkNodes 00316 00317 BlendRef* m_pBlendRef; // the blendref also used to create a brush 00318 MILLIPOINT m_BrushSpacing; 00319 UINT32 m_NumInkNodes; // counts the number of ink nodes we will use 00320 BrushHandle m_BrushHandle; // handle of the brush that we are going to draw with 00321 BOOL m_bBrushReady; 00322 00323 String_256 m_LastBrushDocument; // the name of the last document that the brush was used on 00324 00325 public: 00326 //Preference variable: determine whether freehand pointers have crosshairs 00327 static BOOL FreehandPtrCrosshair; 00328 00329 }; 00330 00331 00332 #endif //INC_FREEHAND 00333 00334 00335