00001 // $Id: opgrad.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 Grad Fill creation and Editing operations 00099 00100 00101 #ifndef INC_OPGRAD 00102 #define INC_OPGRAD 00103 00104 //#include "selop.h" - in camtypes.h [AUTOMATICALLY REMOVED] 00105 //#include "fillattr.h" - in camtypes.h [AUTOMATICALLY REMOVED] 00106 #include "attrappl.h" 00107 //#include "flags.h" - in camtypes.h [AUTOMATICALLY REMOVED] 00108 #include "fillramp.h" 00109 00110 #define OPTOKEN_GRADFILL _T("GraduatedFill") 00111 #define OPTOKEN_EDITFILL _T("EditGraduatedFill") 00112 #define OPTOKEN_MUTATEFILL _T("MutateGraduatedFill") 00113 #define OPTOKEN_CHANGEFILL _T("ChangeFillColour") 00114 #define OPTOKEN_SELECTCOLS _T("ChangeSelectionColours") 00115 00116 class Spread; 00117 00118 // These are lots of helper functions for drawing the fill meshes. 00119 // Some of them won't be needed eventually, and others should really 00120 // be in the Blob Manager. 00121 void MakeMeshArrow(Path *, DocCoord &, DocCoord &, DocCoord*); 00122 void MakeMeshDottedLine(Path *, DocCoord &, DocCoord &); 00123 void MakeMeshSemiCircle(Path *, DocCoord , DocCoord, DocCoord); 00124 void MakeMeshEllipse(Path *, DocCoord , DocCoord , DocCoord End2 = DocCoord(0,0)); 00125 void CalcMeshEllipseEdge(const DocCoord&, const DocCoord&, DocCoord*, DocCoord*, DocCoord*); 00126 DocRect GetMeshSemiCircleBounds(DocCoord Start, DocCoord End, DocCoord End2); 00127 DocRect GetMeshEllipseBounds(DocCoord Start, DocCoord End, DocCoord End2 = DocCoord(0,0)); 00128 DocCoord MakeLineAtAngle(DocCoord Start, DocCoord End, ANGLE Offset = 90, INT32 Length = 0); 00129 ANGLE CalcLineAngle(DocCoord Start, DocCoord End); 00130 void MakePerpendicularMeshLines(DocCoord, DocCoord, DocRect, DocCoord*); 00131 DocCoord CentreOf(DocRect Rect); 00132 void MakeMeshParallelagram(Path*, DocCoord, DocCoord, DocCoord); 00133 void GetMeshParallelagram(DocCoord, DocCoord, DocCoord, 00134 DocCoord*, DocCoord*, DocCoord*, DocCoord*); 00135 DocRect GetParallelagramBounds(DocCoord, DocCoord, DocCoord); 00136 void GetBitmapVirtualPoints(DocCoord Start, DocCoord End, DocCoord End2, 00137 DocCoord* P1, DocCoord* P2, DocCoord* P3); 00138 void GetBitmapRealPoints(DocCoord Start, DocCoord End, DocCoord End2, 00139 DocCoord* P1, DocCoord* P2, DocCoord* P3); 00140 00141 void IncludeArrowHead(DocRect* Bounds, DocCoord Start, DocCoord End); 00142 00143 BOOL AreLinesPerpendicular(DocCoord* Start, DocCoord* End, DocCoord* End2); 00144 00145 /******************************************************************************************** 00146 00147 > class OpCreateFill : public Operation 00148 00149 Author: Will_Cowling (Xara Group Ltd) <camelotdev@xara.com> 00150 Created: 20/7/94 00151 Purpose: An operation to add a Linear Graduated Fill to the selected Object(s). 00152 00153 ********************************************************************************************/ 00154 00155 class OpCreateFill : public Operation 00156 { 00157 00158 CC_DECLARE_DYNCREATE(OpCreateFill); 00159 00160 public: 00161 // Construction/Destruction 00162 OpCreateFill(); 00163 00164 // Virtual functions needed for the dragging operations to work 00165 virtual void DoDrag( AttrFillGeometry*, Spread* pSpread, DocCoord Anchor); 00166 virtual void DragPointerMove( DocCoord PointerPos, ClickModifiers ClickMods, Spread*, BOOL bSolidDrag); 00167 virtual void DragFinished( DocCoord PointerPos, 00168 ClickModifiers ClickMods, Spread*, 00169 BOOL Success, BOOL bSolidDrag); 00170 00171 00172 // Some Render functions to draw the EORed control lines 00173 virtual void RenderDragBlobs( DocRect, Spread* , BOOL bSolidDrag); 00174 00175 // These functions required for the OpDescriptor class 00176 static BOOL Init(); 00177 static OpState GetState(String_256* Description, OpDescriptor*); 00178 00179 // interogates the current (drag) Operation for statusLine text 00180 virtual BOOL GetStatusLineText(String_256* pText, Spread* pSpread, DocCoord DocPos, ClickModifiers ClickMods); 00181 00182 private: 00183 DocRect GetDragBlobRect(); 00184 00185 protected: 00186 // Infomation about what we are editing 00187 AttrFillGeometry* GradFill; 00188 Spread* StartSpread; 00189 00190 // Mouse Positions 00191 DocCoord StartPoint; 00192 DocCoord LastMousePosition; 00193 }; 00194 00195 00196 00197 /******************************************************************************************** 00198 00199 ********************************************************************************************/ 00200 00201 00202 00203 /******************************************************************************************** 00204 00205 > class OpEditFill : public OpApplyAttribToSelected 00206 00207 Author: Will_Cowling (Xara Group Ltd) <camelotdev@xara.com> 00208 Created: 22/7/94 00209 Purpose: This operation edits an AttrLinearFill already in the tree. 00210 It is normally started when the Tool detects a drag on one of its selected 00211 blobs. 00212 00213 ********************************************************************************************/ 00214 00215 class OpEditFill : public OpApplyAttribToSelected 00216 { 00217 CC_DECLARE_DYNCREATE(OpEditFill); 00218 00219 public: 00220 // Construction/Destruction 00221 OpEditFill(); 00222 00223 // The all important Do functions 00224 void DoCreate(DocCoord&, Spread*, AttrFillGeometry*); 00225 void DoDrag(DocCoord&, Spread*, AttrFillGeometry*, FillControl ControlHit); 00226 00227 // Virtual functions needed for the dragging operations to work 00228 virtual void DragPointerMove(DocCoord PointerPos, ClickModifiers ClickMods, Spread*, BOOL bSolidDrag); 00229 virtual void DragPointerIdle(DocCoord PointerPos, ClickModifiers ClickMods, Spread*, BOOL bSolidDrag); 00230 virtual void DragFinished(DocCoord PointerPos, ClickModifiers ClickMods, Spread*, BOOL Success, BOOL bSolidDrag); 00231 virtual BOOL DragKeyPress(KeyPress* pKeyPress, BOOL bSolidDrag); 00232 virtual void DragModeChanged(BOOL bSolidDrag); 00233 00234 // Some Render functions to will draw the EORed path 00235 void RenderDragBlobs(DocRect, Spread*, BOOL bSolidDrag); 00236 00237 // interogates the current (drag) Operation for StatusLine text 00238 BOOL GetStatusLineText(String_256* pText, Spread* pSpread, DocCoord DocPos, ClickModifiers ClickMods); 00239 00240 // These functions required for the OpDescriptor class 00241 static BOOL Init(); 00242 static OpState GetState(String_256* Description, OpDescriptor*); 00243 00244 AttrFillGeometry * GetGradFill() { return GradFill; } 00245 00246 protected: 00247 DocRect GetDragBlobRect(); 00248 00249 void RedrawFills(ClickModifiers& ClickMods); 00250 void CheckForCompoundRedraw(); 00251 00252 BOOL ApplyNewFill(); 00253 BOOL ApplyEditedFill(); 00254 00255 void SelectAllBlobs(); 00256 00257 void RenderFinalBlobs(DocRect, Spread*, BOOL bSolidDrag); 00258 void RenderSelectionFillBlobs(SelRange*, DocRect, Spread*); 00259 void RenderInitSelectionBlobs(SelRange*, DocRect, Spread*); 00260 void RenderInitBlobs(DocRect, Spread*, BOOL bSolidDrag); 00261 00262 double FindAspectRatio(); 00263 00264 // Vars 00265 protected: 00266 // Infomation about what we are editing 00267 AttrFillGeometry* GradFill; 00268 AttrFillGeometry* FillClone; 00269 Spread* StartSpread; 00270 FillControl DragControl; // Which Blob are we dragging ? 00271 00272 BaseDocument* pFillsDoc; 00273 DocRect LastDragRect; 00274 BOOL InvalidateAll; 00275 BOOL InvalidateCompound; 00276 Node* pCompound; 00277 00278 BOOL DragIsIdle; 00279 BOOL DoneIdleRedraw; 00280 MonotonicTime Time; 00281 00282 BOOL ShowDragBlobs; 00283 BOOL DontDrawBlobs; 00284 00285 BOOL AlwaysFail; 00286 BOOL ApplyAtEnd; 00287 BOOL ShouldApplyNewFill; 00288 BOOL ForceAspectLock; 00289 BOOL IsRequired; 00290 BOOL CheckForCompound; 00291 BOOL CallAllowOp; 00292 00293 FlagState TranspState; 00294 00295 List AttrGroups; 00296 00297 double AspectRatio; 00298 00299 // Mouse Positions 00300 DocCoord AnchorPos; 00301 DocCoord LastMousePosition; 00302 00303 public: 00304 static BOOL InteractiveDragUpdate; 00305 static BOOL ContinuousEOR; 00306 static BOOL CreateFill; 00307 00308 static UINT32 IdleFillDelay; 00309 }; 00310 00311 /******************************************************************************************** 00312 00313 > class ModifyFillCoordsAction : public Action 00314 00315 Author: Will_Cowling (Xara Group Ltd) <camelotdev@xara.com> 00316 Created: 24/7/94 00317 Purpose: An action which undoes the modification of Grad Fill data. This action can 00318 be used for undoing changing control points. 00319 SeeAlso: - 00320 00321 ********************************************************************************************/ 00322 /* 00323 class ModifyFillCoordsAction : public Action 00324 { 00325 00326 CC_DECLARE_DYNCREATE(ModifyFillCoordsAction) 00327 00328 public: 00329 ModifyFillCoordsAction(); 00330 ~ModifyFillCoordsAction(); 00331 virtual ActionCode Execute(); 00332 static ActionCode Init( Operation* pOp, 00333 ActionList* pActionList, 00334 INT32 NumChanged, 00335 Action** NewAction); 00336 void StoreChanges(AttrFillGeometry* Fill, DocCoord* Coords, BOOL* SelState); 00337 00338 protected: 00339 INT32 NumChangedCoords; 00340 00341 AttrFillGeometry* ChangedFill; 00342 DocCoord* ChangedCoords; 00343 BOOL* SelectionState; 00344 }; 00345 */ 00346 00347 /******************************************************************************************** 00348 00349 > class OpChangeFillColour : public SelOperation 00350 00351 Author: Will_Cowling (Xara Group Ltd) <camelotdev@xara.com> 00352 Created: 22/7/94 00353 Purpose: This operation Changes the Colour of a Fill already in the tree. 00354 00355 ********************************************************************************************/ 00356 /* 00357 class OpChangeFillColour : public SelOperation 00358 { 00359 CC_DECLARE_DYNCREATE(OpChangeFillColour); 00360 00361 public: 00362 // Construction/Destruction 00363 OpChangeFillColour(); 00364 00365 // The all important Do function 00366 void Do(DocColour &, DocColour &, AttrFillGeometry *); 00367 00368 // These functions required for the OpDescriptor class 00369 static BOOL Init(); 00370 static OpState GetState(String_256* Description, OpDescriptor*); 00371 }; 00372 */ 00373 00374 /******************************************************************************************** 00375 00376 > class OpChangeSelectionColours : public SelOperation 00377 00378 Author: Will_Cowling (Xara Group Ltd) <camelotdev@xara.com> 00379 Created: 22/7/94 00380 Purpose: This operation Changes the Colour of a Fill already in the tree. 00381 00382 ********************************************************************************************/ 00383 /* 00384 class OpChangeSelectionColours : public SelOperation 00385 { 00386 CC_DECLARE_DYNCREATE(OpChangeSelectionColours); 00387 00388 public: 00389 // Construction/Destruction 00390 OpChangeSelectionColours(); 00391 00392 // The all important Do function 00393 BOOL Do(DocColour &); 00394 00395 // These functions required for the OpDescriptor class 00396 static BOOL Init(); 00397 static OpState GetState(String_256* Description, OpDescriptor*); 00398 }; 00399 */ 00400 00401 /******************************************************************************************** 00402 00403 > class ModifyFillColoursAction : public Action 00404 00405 Author: Will_Cowling (Xara Group Ltd) <camelotdev@xara.com> 00406 Created: 24/7/94 00407 Purpose: An action which undoes the modification of Grad Fill data. This action can 00408 be used for undoing changing colours. 00409 SeeAlso: - 00410 00411 ********************************************************************************************/ 00412 /* 00413 class ModifyFillColoursAction : public Action 00414 { 00415 00416 CC_DECLARE_DYNCREATE(ModifyFillColoursAction) 00417 00418 public: 00419 ModifyFillColoursAction(); 00420 ~ModifyFillColoursAction(); 00421 virtual ActionCode Execute(); 00422 static ActionCode Init( Operation* pOp, 00423 ActionList* pActionList, 00424 INT32 NumChangedColours, 00425 Action** NewAction); 00426 void StoreChanges(AttrFillGeometry* Fill, DocColour* Colours, BOOL* SelState); 00427 00428 protected: 00429 INT32 NumChangedColours; 00430 00431 AttrFillGeometry* ChangedFill; 00432 DocColour* ChangedColours; 00433 BOOL* SelectionState; 00434 }; 00435 */ 00436 00437 /******************************************************************************************** 00438 00439 > class RestoreFillRampAction : public Action 00440 00441 Author: David_McClarnon (Xara Group Ltd) <camelotdev@xara.com> 00442 Created: 24/10/99 00443 Purpose: Action for restoring fill ramps after changes have been made 00444 SeeAlso: - 00445 00446 ********************************************************************************************/ 00447 00448 class RestoreFillRampAction : public Action 00449 { 00450 00451 CC_DECLARE_DYNCREATE(RestoreFillRampAction) 00452 00453 public: 00454 RestoreFillRampAction(); 00455 ~RestoreFillRampAction(); 00456 virtual ActionCode Execute(); 00457 static ActionCode Init( Operation* pOp, 00458 ActionList* pActionList, 00459 AttrFillGeometry* pFill, 00460 RestoreFillRampAction** NewAction); 00461 00462 protected: 00463 AttrFillGeometry* m_pAttr; 00464 ColourRamp m_LastRamp; 00465 }; 00466 00467 00468 #endif // INC_OPGRAD 00469 00470 00471