00001 // $Id: gridtool.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 // Header for the grid tool implementation 00099 // Created by Mark Neves on 18/2/94 00100 00101 #ifndef INC_GRIDTOOL 00102 #define INC_GRIDTOOL 00103 00104 //#include "tool.h" - in camtypes.h [AUTOMATICALLY REMOVED] 00105 //#include "undoop.h" - in camtypes.h [AUTOMATICALLY REMOVED] 00106 //#include "doccoord.h" - in camtypes.h [AUTOMATICALLY REMOVED] 00107 #include "grid.h" 00108 //#include "bars.h" - in camtypes.h [AUTOMATICALLY REMOVED] 00109 00110 class Cursor; 00111 class Spread; 00112 class ChangeGrid; 00113 class GridInfoBarOp; 00114 class OpState; 00115 00116 00117 /******************************************************************************************** 00118 00119 > class GridTool : public Tool_v1 00120 00121 Author: Mark_Neves (Xara Group Ltd) <camelotdev@xara.com> 00122 Created: 18/2/94 00123 Purpose: A Tool for creating and editing grids 00124 00125 ********************************************************************************************/ 00126 00127 class CCAPI GridTool : public Tool_v1 00128 { 00129 // Give my name in memory dumps 00130 CC_DECLARE_MEMDUMP(GridTool); 00131 00132 public: 00133 GridTool(); 00134 ~GridTool(); 00135 BOOL Init(); 00136 void Describe(void* InfoPtr); 00137 UINT32 GetID(); 00138 00139 // Event Handlers 00140 void SelectChange(BOOL isSelected); 00141 void OnClick( DocCoord, ClickType, ClickModifiers, Spread* ); 00142 void OnMouseMove(DocCoord PointerPos, Spread* pSpread, ClickModifiers mods); 00143 void RenderToolBlobs(Spread* pSpread,DocRect* pDocRect); 00144 00145 static GridType DefaultGridType; 00146 00147 static void RenderAllGridBlobs(NodeGrid* pGrid); 00148 static void ChangeSelectedGrids(); 00149 static void ForceRedraw(Spread* pSpread,DocRect Rect); 00150 static void ForceRedraw(NodeGrid* pGrid); 00151 static void MakeDefaultGrid(Spread* pSpread); 00152 static void ToggleDefaultGrid(); 00153 static void DisplayStatusBarHelp(UINT32 StatusID); 00154 static void DisplayGridInfo(NodeGrid* pGrid); 00155 00156 static Spread* GetSpreadClicked() {return SpreadClicked; } 00157 static GridInfoBarOp* GetGridInfoBarOp() {return pGridInfoBarOp; } 00158 00159 //static BOOL IsCurrentTool() { return CurrentTool; } 00160 00161 static Document* GetDoc() { return GridTool::pDocument; } 00162 static void SetDoc(Document* pThisDoc); 00163 00164 private: 00165 static void ChangeGrid(NodeGrid* pGrid); 00166 00167 BOOL CreateCursors(); 00168 void RenderAllGridBlobs(); 00169 00170 static void RenderGridBlobsInSpread(DocView* pDocView,Spread* pSpread,DocRect* pDocRect); 00171 static void RenderGridBlobs(RenderRegion* pRender,NodeGrid* pGrid); 00172 static void RenderGridSelectBlobs(RenderRegion* pRender,NodeGrid* pGrid); 00173 static void RenderGridBlobs(NodeGrid* pGrid); 00174 static void RenderGridSelectBlobs(NodeGrid* pGrid); 00175 static void ClearSelection(Spread* pSpread); 00176 static BOOL GetGridBlobRenderVars(NodeGrid* pGrid,DocView** ppDocView,Spread** ppSpread,DocRect* pDocRect); 00177 static void FindCurrentSpread(); 00178 static BOOL HasSpreadSelGrids(Spread* pSpread); 00179 00180 BOOL WhichGridClicked(Spread* pSpread,const DocCoord& PointerPos,NodeGrid** ppGrid); 00181 BOOL WhichGridBlobClicked(Spread* pSpread,const DocCoord& PointerPos,NodeGrid** ppGrid,GridBlobType* pGridBlob); 00182 00183 00184 static Spread* SpreadClicked; // The Spread the click started on 00185 static DocCoord PointClicked; // The point where the drag started 00186 static NodeGrid* GridClicked; 00187 static GridBlobType GridBlobClicked; 00188 static NodeGrid* LastGridClicked; 00189 //static BOOL CurrentTool; 00190 static UINT32 LastStatusID; 00191 static GridInfoBarOp* pGridInfoBarOp; 00192 static Document* pDocument; 00193 00194 Cursor* pcNormalGridCursor; 00195 Cursor* pcOverGridCursor; 00196 Cursor* pcOverBlobCursorUD; 00197 Cursor* pcOverBlobCursorLR; 00198 Cursor* pcOverBlobCursorTL; 00199 Cursor* pcOverBlobCursorTR; 00200 Cursor* pcCurrentCursor; 00201 INT32 CurrentCursorID; // ID of the current cursor on the stack 00202 00203 static char* FamilyName; // The Tools Family Name 00204 static char* ToolName; // The Tool Name 00205 static char* Purpose; // What the tool is for 00206 static char* Author; // Who wrote it 00207 }; 00208 00209 00210 /******************************************************************************************** 00211 00212 > class OpGrid : public UndoableOperation 00213 00214 Author: Mark_Neves (Xara Group Ltd) <camelotdev@xara.com> 00215 Created: 12/7/94 00216 Purpose: Base class all grid operations are derived from 00217 00218 ********************************************************************************************/ 00219 00220 class OpGrid : public UndoableOperation 00221 { 00222 00223 CC_DECLARE_DYNCREATE(OpGrid); 00224 00225 public: 00226 OpGrid() { PreOpDisplayedGrid = PostOpDisplayedGrid = NULL; } 00227 00228 NodeGrid* GetPreOpDisplayedGrid() { return PreOpDisplayedGrid; } 00229 NodeGrid* GetPostOpDisplayedGrid() { return PostOpDisplayedGrid; } 00230 00231 NodeGrid* DoDuplicateGrid( NodeGrid* pGrid, 00232 AttachNodeDirection AttDir, 00233 Node* pContextNode, 00234 Spread* pSrcSpread, 00235 Spread* pDestSpread, 00236 BOOL FRedraw, 00237 INT32 XDelta = 0, 00238 INT32 YDelta = 0); 00239 00240 protected: 00241 NodeGrid* PreOpDisplayedGrid; 00242 NodeGrid* PostOpDisplayedGrid; 00243 }; 00244 00245 00246 00247 #define OPTOKEN_GRIDNEWRESIZE _T("GridNewResize") 00248 00249 00250 /******************************************************************************************** 00251 00252 > class OpGridNewResize : public OpGrid 00253 00254 Author: Mark_Neves (Xara Group Ltd) <camelotdev@xara.com> 00255 Created: 18/2/94 00256 Purpose: Provides the operations behind the Grid Tool. These include blob dragging, 00257 creation of grid and addition of grids to the document tree. 00258 00259 ********************************************************************************************/ 00260 00261 enum OpGridOpType { NEW, RESIZE }; 00262 00263 class OpGridNewResize : public OpGrid 00264 { 00265 00266 CC_DECLARE_DYNCREATE(OpGridNewResize); 00267 00268 public: 00269 // Construction/Destruction 00270 OpGridNewResize(); 00271 ~OpGridNewResize(); 00272 00273 // The all important Do functions 00274 void DoDrag(Spread* pSpread,NodeGrid* pGrid,GridBlobType Blob, 00275 DocCoord PointClicked); 00276 00277 // Virtual functions needed for the dragging operations to work 00278 virtual void DragPointerMove( DocCoord PointerPos, ClickModifiers ClickMods, Spread*, BOOL bSolidDrag); 00279 virtual void DragFinished( DocCoord PointerPos, 00280 ClickModifiers ClickMods, Spread*, 00281 BOOL Success, BOOL bSolidDrag); 00282 00283 // Some Render functions to will draw the EORed drag box 00284 void RenderMyDragBlobs(); 00285 void RenderDragBlobs(DocRect Rect,Spread* pSpread, BOOL bSolidDrag); 00286 00287 // These functions required for the OpDescriptor class 00288 static BOOL Declare(); 00289 static OpState GetState(String_256* Description, OpDescriptor*); 00290 void GetOpName(String_256* OpName); 00291 00292 static BOOL StartADrag; 00293 static BOOL EndTheDrag; 00294 00295 private: 00296 // Member vars of the operation 00297 Spread* SpreadClicked; // The Spread the click started on 00298 NodeGrid* GridClicked; // The grid the click occurred on (or NULL if no grid clicked) 00299 GridBlobType GridBlobClicked; // The grid select blob clicked (or NoGridBlob if none clicked) 00300 DocCoord AnchorPoint; // The point where the drag started 00301 DocCoord DragPoint; // The last position the mouse was in 00302 00303 OpGridOpType OpType; 00304 }; 00305 00306 00307 /******************************************************************************************** 00308 00309 > class OpGridSelection : public OpGrid 00310 00311 Author: Mark_Neves (Xara Group Ltd) <camelotdev@xara.com> 00312 Created: 18/2/94 00313 Purpose: Provides the operations on the selected grids. These include dragging, 00314 cut copy paste etc. 00315 00316 ********************************************************************************************/ 00317 00318 #define OPTOKEN_GRIDSELECTION _T("GridSelection") 00319 00320 class OpGridSelection : public OpGrid 00321 { 00322 00323 CC_DECLARE_DYNCREATE(OpGridSelection); 00324 00325 public: 00326 // Construction/Destruction 00327 OpGridSelection(); 00328 ~OpGridSelection(); 00329 00330 // The all important Do functions 00331 void DoDrag(Spread* pSpread,DocCoord PointClicked,NodeGrid* GridClicked); 00332 00333 // Virtual functions needed for the dragging operations to work 00334 virtual void DragPointerMove( DocCoord PointerPos, ClickModifiers ClickMods, Spread*, BOOL bSolidDrag); 00335 virtual void DragFinished( DocCoord PointerPos, 00336 ClickModifiers ClickMods, Spread*, 00337 BOOL Success, BOOL bSolidDrag); 00338 00339 // Returns the union of all the selected grids in the given spread 00340 DocRect OpGridSelection::GetSelectedGridBounds(Spread* pSpread); 00341 00342 // Some Render functions to will draw the EORed drag boxes 00343 void RenderMyDragBlobs(); 00344 void RenderDragBlobs(DocRect Rect,Spread* pSpread, BOOL bSolidDrag); 00345 00346 // These functions required for the OpDescriptor class 00347 static BOOL Declare(); 00348 static OpState GetState(String_256* Description, OpDescriptor*); 00349 void GetOpName(String_256* OpName); 00350 00351 private: 00352 // Member vars of the operation 00353 Spread* SpreadClicked; // The Spread the click started on 00354 DocCoord StartPoint; // The point where the drag started 00355 DocCoord DragPoint; // The last position the mouse was in 00356 Spread* SpreadDrag; // Spread current DragPoint is over 00357 DocRect StartRect; // The union of selected grid bounds before the drag 00358 DocRect DragRect; // The union of selected grid bounds after the drag 00359 00360 BOOL Plural; 00361 }; 00362 00363 /******************************************************************************************** 00364 00365 > class OpGridChange : public OpGrid 00366 00367 Author: Mark_Neves (Xara Group Ltd) <camelotdev@xara.com> 00368 Created: 18/2/94 00369 Purpose: Provides the operation for changing the selected grids. 00370 00371 ********************************************************************************************/ 00372 00373 #define OPTOKEN_GRIDCHANGE _T("GridChange") 00374 00375 class OpGridChange : public OpGrid 00376 { 00377 00378 CC_DECLARE_DYNCREATE(OpGridChange); 00379 00380 public: 00381 // Construction/Destruction 00382 OpGridChange(); 00383 ~OpGridChange(); 00384 00385 // These functions required for the OpDescriptor class 00386 static BOOL Declare(); 00387 static OpState GetState(String_256* Description, OpDescriptor*); 00388 void GetOpName(String_256* OpName); 00389 00390 void DoChangeSelectedGrids(ChangeGrid* pChangeGrid); 00391 BOOL DoChangeGrid(NodeGrid* pOldGrid,ChangeGrid* pChangeGrid); 00392 00393 private: 00394 UINT32 ChangeGridUndoIDS; 00395 }; 00396 00397 /******************************************************************************************** 00398 00399 > class OpGridDelete : public OpGrid 00400 00401 Author: Mark_Neves (Xara Group Ltd) <camelotdev@xara.com> 00402 Created: 19/7/93 00403 Purpose: This class represents the grid Delete operation. 00404 00405 ********************************************************************************************/ 00406 00407 class OpGridDelete: public OpGrid 00408 { 00409 CC_DECLARE_DYNCREATE(OpGridDelete) 00410 00411 public: 00412 static OpState GetState(String_256*, OpDescriptor*); 00413 void Do(OpDescriptor*); 00414 void GetOpName(String_256* OpName); 00415 00416 private: 00417 BOOL Plural; 00418 }; 00419 00420 /******************************************************************************************** 00421 00422 > class OpGridCut : public OpGrid 00423 00424 Author: Mark_Neves (Xara Group Ltd) <camelotdev@xara.com> 00425 Created: 27/7/93 00426 Purpose: This class represents the grid Cut operation. 00427 Currently, it just greys out the menu/button/keypress associated with the op 00428 00429 ********************************************************************************************/ 00430 00431 class OpGridCut: public OpGrid 00432 { 00433 CC_DECLARE_DYNCREATE(OpGridCut) 00434 }; 00435 00436 /******************************************************************************************** 00437 00438 > class OpGridCopy : public OpGrid 00439 00440 Author: Mark_Neves (Xara Group Ltd) <camelotdev@xara.com> 00441 Created: 27/7/93 00442 Purpose: This class represents the grid Copy operation. 00443 Currently, it just greys out the menu/button/keypress associated with the op 00444 00445 ********************************************************************************************/ 00446 00447 class OpGridCopy: public OpGrid 00448 { 00449 CC_DECLARE_DYNCREATE(OpGridCopy) 00450 }; 00451 00452 /******************************************************************************************** 00453 00454 > class OpGridPaste : public OpGrid 00455 00456 Author: Mark_Neves (Xara Group Ltd) <camelotdev@xara.com> 00457 Created: 27/7/93 00458 Purpose: This class represents the grid Paste operation. 00459 Currently, it just greys out the menu/button/keypress associated with the op 00460 00461 ********************************************************************************************/ 00462 00463 class OpGridPaste: public OpGrid 00464 { 00465 CC_DECLARE_DYNCREATE(OpGridPaste) 00466 }; 00467 00468 /******************************************************************************************** 00469 00470 > class OpGridDuplicate : public OpGrid 00471 00472 Author: Mark_Neves (Xara Group Ltd) <camelotdev@xara.com> 00473 Created: 27/7/93 00474 Purpose: This class represents the grid Duplicate operation. 00475 Currently, it just greys out the menu/button/keypress associated with the op 00476 00477 ********************************************************************************************/ 00478 00479 class OpGridDuplicate: public OpGrid 00480 { 00481 CC_DECLARE_DYNCREATE(OpGridDuplicate) 00482 00483 public: 00484 static OpState GetState(String_256*, OpDescriptor*); 00485 void Do(OpDescriptor*); 00486 void GetOpName(String_256* OpName); 00487 00488 private: 00489 BOOL Plural; 00490 }; 00491 00492 //-------------------------------------------------------- 00493 //-------------------------------------------------------- 00494 //-------------------------------------------------------- 00495 //-------------------------------------------------------- 00496 00497 /******************************************************************************************** 00498 00499 > class ChangeGrid : 00500 00501 Author: Mark_Neves (Xara Group Ltd) <camelotdev@xara.com> 00502 Created: 14/3/94 00503 Purpose: An abstract class used for changing aspects of a grid 00504 00505 ********************************************************************************************/ 00506 00507 class ChangeGrid : public SimpleCCObject 00508 { 00509 public: 00510 virtual void Change(NodeGrid* pGrid) = 0; 00511 virtual GridType GetGridType(NodeGrid* pGrid) = 0; 00512 virtual UINT32 GetUndoIDS() = 0; 00513 }; 00514 00515 /******************************************************************************************** 00516 00517 > class ChangeGridUnits : public Grid 00518 00519 Author: Mark_Neves (Xara Group Ltd) <camelotdev@xara.com> 00520 Created: 14/3/94 00521 Purpose: An abstract class used for changing aspects of a grid 00522 00523 ********************************************************************************************/ 00524 00525 class ChangeGridUnits : public ChangeGrid 00526 { 00527 public: 00528 void Change(NodeGrid* pGrid); 00529 GridType GetGridType(NodeGrid* pGrid); 00530 UINT32 GetUndoIDS(); 00531 }; 00532 00533 /******************************************************************************************** 00534 00535 > class ChangeGridDivisions : public Grid 00536 00537 Author: Mark_Neves (Xara Group Ltd) <camelotdev@xara.com> 00538 Created: 14/3/94 00539 Purpose: An abstract class used for changing aspects of a grid 00540 00541 ********************************************************************************************/ 00542 00543 class ChangeGridDivisions : public ChangeGrid 00544 { 00545 public: 00546 void Change(NodeGrid* pGrid); 00547 GridType GetGridType(NodeGrid* pGrid); 00548 UINT32 GetUndoIDS(); 00549 }; 00550 00551 /******************************************************************************************** 00552 00553 > class ChangeGridSubdivisions : public Grid 00554 00555 Author: Mark_Neves (Xara Group Ltd) <camelotdev@xara.com> 00556 Created: 14/3/94 00557 Purpose: An abstract class used for changing aspects of a grid 00558 00559 ********************************************************************************************/ 00560 00561 class ChangeGridSubdivisions : public ChangeGrid 00562 { 00563 public: 00564 void Change(NodeGrid* pGrid); 00565 GridType GetGridType(NodeGrid* pGrid); 00566 UINT32 GetUndoIDS(); 00567 }; 00568 00569 /******************************************************************************************** 00570 00571 > class ChangeGridType : public Grid 00572 00573 Author: Mark_Neves (Xara Group Ltd) <camelotdev@xara.com> 00574 Created: 14/3/94 00575 Purpose: An abstract class used for changing aspects of a grid 00576 00577 ********************************************************************************************/ 00578 00579 class ChangeGridType : public ChangeGrid 00580 { 00581 public: 00582 void Change(NodeGrid* pGrid); 00583 GridType GetGridType(NodeGrid* pGrid); 00584 UINT32 GetUndoIDS(); 00585 }; 00586 00587 //----------------------------------------------- 00588 //----------------------------------------------- 00589 //----------------------------------------------- 00590 //----------------------------------------------- 00591 00592 00593 /******************************************************************************************** 00594 00595 > class GridInfoBarOp : public InformationBarOp 00596 00597 Author: Mark_Neves (Xara Group Ltd) <camelotdev@xara.com> 00598 Created: 28/4/94 00599 Purpose: Class for handling the grid tool's information bar. 00600 00601 ********************************************************************************************/ 00602 00603 class GridInfoBarOp : public InformationBarOp 00604 { 00605 CC_DECLARE_DYNCREATE( GridInfoBarOp ) 00606 public: 00607 GridInfoBarOp() {}; // Dummy default constructor for DYNCREATE 00608 00609 MsgResult Message(Msg* Msg); // All messages to the info bar come through here 00610 00611 void InitControls(); // Initialises the controls in the info bar 00612 void EnableControls(); // Enables/disables the controls in the info bar 00613 00614 // A set of routines for displaying information in the info bar 00615 void DisplayDefaultGridInfo(); 00616 void DisplayGridInfo(double Divisions, UnitType Units, UINT32 Subdivisions, GridType GType); 00617 void DisplayGridInfo(NodeGrid* pGrid); 00618 00619 NodeGrid* GetLastGridDisplayed() { return LastGridDisplayed; } 00620 00621 private: 00622 NodeGrid* LastGridDisplayed; 00623 }; 00624 00625 00626 /******************************************************************************************** 00627 00628 > class GridInfoBarOpCreate : public BarCreate 00629 00630 Author: Mark_Neves (Xara Group Ltd) <camelotdev@xara.com> 00631 Created: 28/4/94 00632 Purpose: Class for creating GridInfoBarOps. 00633 Derived classes of BarCreate are used by DialogBarOp::ReadBarsFromFile() 00634 00635 ********************************************************************************************/ 00636 00637 class GridInfoBarOpCreate : public BarCreate 00638 { 00639 public: 00640 DialogBarOp* Create() { return (new GridInfoBarOp); } 00641 }; 00642 00643 00644 #endif // INC_GRIDTOOL 00645