00001 // $Id: guides.cpp 1315 2006-06-14 09:51:34Z 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 // NodeGuideline implementation 00099 00100 /* 00101 */ 00102 00103 #include "camtypes.h" 00104 00105 // WEBSTER - markn 14/1/97 00106 // Removed all code not needed in Webster 00107 // This is the same as the code removed from RALPH 00108 #ifdef WEBSTER 00109 #define EXCLUDE_FROM_RALPH 00110 #endif 00111 00112 #include "guides.h" 00113 #include "snap.h" 00114 //#include "stockcol.h" - in camtypes.h [AUTOMATICALLY REMOVED] 00115 //#include "rndrgn.h" 00116 //#include "attr.h" - in camtypes.h [AUTOMATICALLY REMOVED] 00117 //#include "view.h" - in camtypes.h [AUTOMATICALLY REMOVED] 00118 //#include "docview.h" - in camtypes.h [AUTOMATICALLY REMOVED] 00119 //#include "spread.h" - in camtypes.h [AUTOMATICALLY REMOVED] 00120 #include "layer.h" 00121 #include "sprdmsg.h" 00122 //#include "document.h" - in camtypes.h [AUTOMATICALLY REMOVED] 00123 #include "qualattr.h" 00124 #include "camview.h" 00125 //#include "markn.h" 00126 //#include "ed.h" 00127 //#include "tim.h" 00128 #include "contmenu.h" 00129 //#include "lyrprop.h" 00130 //#include "resource.h" 00131 #include "usercord.h" 00132 #include "layermsg.h" 00133 //#include "scrcamvw.h" 00134 //#include "grndrgn.h" 00135 //#include "osrndrgn.h" 00136 //#include "cameleps.h" 00137 #include "saveeps.h" 00138 #include "nativeps.h" // The old style EPS native filter, used in v1.1 00139 #include "keypress.h" 00140 #include "prpsgds.h" 00141 #include "snapops.h" 00142 //#include "viewrc.h" 00143 #include "csrstack.h" 00144 //#include "justin.h" 00145 //#include "app.h" - in camtypes.h [AUTOMATICALLY REMOVED] 00146 //#include "statline.h" 00147 #include "toollist.h" 00148 00149 //#include "cxfrec.h" - in camtypes.h [AUTOMATICALLY REMOVED] 00150 //#include "cxfrech.h" - in camtypes.h [AUTOMATICALLY REMOVED] 00151 #include "cxftags.h" 00152 //#include "cxfdefs.h" - in camtypes.h [AUTOMATICALLY REMOVED] 00153 //#include "camfiltr.h" - in camtypes.h [AUTOMATICALLY REMOVED] 00154 #include "page.h" 00155 00156 #if !defined(EXCLUDE_FROM_RALPH) 00157 #include "optsgrid.h" 00158 #include "statline.h" 00159 #endif 00160 00161 00162 static MILLIPOINT abs_milli(MILLIPOINT n) { if (n<0) return (0-n); else return (n);} 00163 00164 #define Swap(a,b) { (a)^=(b), (b)^=(a), (a)^=(b); } 00165 00166 #define MAX_INT (0x01000000) 00167 #define MIN_INT (0xf0000000) 00168 00169 #define GUIDE_CURSORID_UNSET -1 00170 00171 CC_IMPLEMENT_DYNAMIC(NodeGuideline, NodeRenderableInk) 00172 #if !defined(EXCLUDE_FROM_RALPH) 00173 CC_IMPLEMENT_DYNCREATE(OpGuideline, UndoableOperation) 00174 CC_IMPLEMENT_DYNCREATE(OpSpreadOrigin, UndoableOperation) 00175 CC_IMPLEMENT_DYNCREATE(GuidelinePropDlg, DialogOp) 00176 CC_IMPLEMENT_MEMDUMP(OpGuidelineParam, OpParam) 00177 CC_IMPLEMENT_DYNAMIC(LayerMsg, Msg) 00178 CC_IMPLEMENT_DYNCREATE(OpDeleteGuideline, OpGuideline) 00179 CC_IMPLEMENT_DYNCREATE(OpNewGuideline, OpGuideline) 00180 CC_IMPLEMENT_DYNCREATE(OpDeleteAllGuidelines, OpGuideline) 00181 CC_IMPLEMENT_DYNCREATE(OpResetSpreadOrigin, OpSpreadOrigin) 00182 #else 00183 CC_IMPLEMENT_DYNAMIC(LayerMsg, Msg) 00184 #endif 00185 00186 // Declare smart memory handling in Debug builds 00187 #define new CAM_DEBUG_NEW 00188 00189 #if !defined(EXCLUDE_FROM_RALPH) 00190 //------------------------------------- 00191 00192 NodeGuideline* OpDeleteGuideline::pGuideline = NULL; 00193 OpGuidelineParam OpNewGuideline::NewGuidelineParam; 00194 00195 //------------------------------------- 00196 00197 const CDlgMode GuidelinePropDlg::Mode = MODAL; 00198 const INT32 GuidelinePropDlg::IDD = _R(IDD_GUIDELINE_PROPERTIES); 00199 GuidelinePropDlgParams GuidelinePropDlg::Params; 00200 00201 //------------------------------------- 00202 #endif 00203 00204 // WEBSTER - markn 14/1/97 00205 // Helper func for NodeGuideline::Render() - still in it's experimental stage 00206 #ifndef WEBSTER 00207 static void PullOntoStep(INT32* pMin,INT32* pMax,INT32 Dist) 00208 { 00209 if (Dist != 0) 00210 { 00211 *pMin -= *pMin % Dist; 00212 *pMax += Dist-(*pMax % Dist); 00213 } 00214 } 00215 #endif // WEBSTER 00216 00217 /********************************************************************************************* 00218 00219 > NodeGuideline::NodeGuideline() 00220 00221 Author: Mark_Neves (Xara Group Ltd) <camelotdev@xara.com> 00222 Created: 5/9/95 00223 Inputs: - 00224 Outputs: 00225 Returns: - 00226 Purpose: This constructor creates a NodeGuideline linked to no other nodes, with all status 00227 flags false, and NULL bounding and pasteboard rectangles. 00228 Errors: 00229 00230 **********************************************************************************************/ 00231 00232 00233 NodeGuideline::NodeGuideline(): NodeRenderableInk() 00234 { 00235 // WEBSTER - markn 14/1/97 00236 #ifndef WEBSTER 00237 Type = GUIDELINE_HORZ; 00238 Ordinate = 72000*9; 00239 #endif // WEBSTER 00240 } 00241 00242 00243 00244 /*********************************************************************************************** 00245 00246 > Node* NodeGuideline::SimpleCopy() // Private method 00247 00248 Author: Mark_Neves (Xara Group Ltd) <camelotdev@xara.com> 00249 Created: 5/9/95 00250 Inputs: - 00251 Outputs: - 00252 Returns: A copy of the node, or NULL if memory runs out 00253 Purpose: This method returns a shallow copy of the node with all Node pointers NULL. 00254 The function is virtual, and must be defined for all derived classes. 00255 Errors: If memory runs out when trying to copy, then ERROR is called with an out of memory 00256 error and the function returns NULL. 00257 Scope: protected 00258 00259 **********************************************************************************************/ 00260 00261 Node* NodeGuideline::SimpleCopy() 00262 { 00263 // WEBSTER - markn 14/1/97 00264 #ifndef WEBSTER 00265 NodeGuideline* NodeCopy = new NodeGuideline(); 00266 if (NodeCopy != NULL) 00267 CopyNodeContents(NodeCopy); 00268 return (NodeCopy); 00269 #else 00270 return NULL; 00271 #endif // WEBSTER 00272 } 00273 00274 /*********************************************************************************************** 00275 00276 > void NodeGuideline::CopyNodeContents(NodeGuideline* NodeCopy) 00277 00278 Author: Mark_Neves (Xara Group Ltd) <camelotdev@xara.com> 00279 Created: 5/9/95 00280 Inputs: - 00281 Outputs: A copy of this node 00282 Returns: - 00283 Purpose: This method copies the node's contents to the node pointed to by NodeCopy. 00284 Errors: An assertion failure will occur if NodeCopy is NULL 00285 Scope: protected 00286 00287 ***********************************************************************************************/ 00288 00289 00290 void NodeGuideline::CopyNodeContents(NodeGuideline* NodeCopy) 00291 { 00292 // WEBSTER - markn 14/1/97 00293 #ifndef WEBSTER 00294 ENSURE(NodeCopy != NULL,"Trying to copy a NodeGuideline's contents to a NULL node"); 00295 00296 NodeRenderableInk::CopyNodeContents(NodeCopy); 00297 00298 NodeCopy->Type = this->Type; 00299 NodeCopy->Ordinate = this->Ordinate; 00300 #endif // WEBSTER 00301 } 00302 00303 00304 /*********************************************************************************************** 00305 > void NodeGuideline::PolyCopyNodeContents(NodeRenderable* pNodeCopy) 00306 00307 Author: Phil_Martin (Xara Group Ltd) <camelotdev@xara.com> 00308 Created: 18/12/2003 00309 Outputs: - 00310 Purpose: Polymorphically copies the contents of this node to another 00311 Errors: An assertion failure will occur if NodeCopy is NULL 00312 Scope: protected 00313 00314 ***********************************************************************************************/ 00315 00316 void NodeGuideline::PolyCopyNodeContents(NodeRenderable* pNodeCopy) 00317 { 00318 ENSURE(pNodeCopy, "Trying to copy a node's contents into a NULL node"); 00319 ENSURE(IS_A(pNodeCopy, NodeGuideline), "PolyCopyNodeContents given wrong dest node type"); 00320 00321 if (IS_A(pNodeCopy, NodeGuideline)) 00322 CopyNodeContents((NodeGuideline*)pNodeCopy); 00323 } 00324 00325 00326 00327 /******************************************************************************************** 00328 00329 > void* NodeGuideline::GetDebugDetails(StringBase* Str) 00330 00331 Author: Mark_Neves (Xara Group Ltd) <camelotdev@xara.com> 00332 Created: 5/9/95 00333 Inputs: - 00334 Outputs: Str: String giving debug info about the node 00335 Returns: - 00336 Purpose: For obtaining debug information about the Node 00337 Errors: - 00338 SeeAlso: - 00339 00340 ********************************************************************************************/ 00341 00342 00343 void NodeGuideline::GetDebugDetails(StringBase* Str) 00344 { 00345 // WEBSTER - markn 14/1/97 00346 #ifndef WEBSTER 00347 NodeRenderableInk::GetDebugDetails(Str); 00348 #endif // WEBSTER 00349 } 00350 00351 /******************************************************************************************** 00352 00353 > virtual String Describe(BOOL Plural, BOOL Verbose = TRUE) 00354 00355 Author: Mark_Neves (Xara Group Ltd) <camelotdev@xara.com> 00356 Created: 5/9/95 00357 Inputs: Plural: Flag indicating if the string description should be plural or 00358 singular. 00359 Outputs: - 00360 Retuns: Description of the object 00361 Purpose: To return a description of the Node object in either the singular or the 00362 plural. This method is called by the DescribeRange method. 00363 00364 The description will always begin with a lower case letter. 00365 00366 Errors: A resource exception will be thrown if a problem occurs when loading the 00367 string resource. 00368 SeeAlso: - 00369 00370 ********************************************************************************************/ 00371 /* 00372 Technical Notes: 00373 00374 The String resource identifiers should be of the form: ID_<Class>_DescriptionS for the 00375 singular description and ID_<Class>_DescriptionP for the plural. 00376 */ 00377 00378 String NodeGuideline::Describe(BOOL /*Plural*/, BOOL /*Verbose*/) 00379 { 00380 // ENSURE (FALSE,"The illegal function NodeGuideline::Describe was called\n"); 00381 00382 return( _T("") ); // Just to keep the compiler happy 00383 }; 00384 00385 /*********************************************************************************************** 00386 00387 > static MILLIPOINT NodeGuideline::GetScaledPixelWidth(RenderRegion* pRender) 00388 00389 Author: Mark_Neves (Xara Group Ltd) <camelotdev@xara.com> 00390 Created: 12/9/95 00391 Inputs: pRender: Render region to render into (can be NULL) 00392 Outputs: - 00393 Returns: - 00394 Purpose: Gets the scaled pixel width. 00395 if pRender != NULL, the render view associated with it is used, otherwise 00396 the selected doc view is used. 00397 00398 It uses the all View::GetScaledPixelSize() function. 00399 00400 ***********************************************************************************************/ 00401 00402 MILLIPOINT NodeGuideline::GetScaledPixelWidth(RenderRegion* pRender) 00403 { 00404 // WEBSTER - markn 14/1/97 00405 #ifndef WEBSTER 00406 MILLIPOINT Width = 0; 00407 View* pView = NULL; 00408 00409 if (pRender != NULL) 00410 pView = pRender->GetRenderView(); 00411 else 00412 pView = DocView::GetCurrent(); 00413 00414 if (pView != NULL) 00415 { 00416 // Get the scaled pixel size for the view 00417 FIXED16 ScaledPixelWidth, 00418 ScaledPixelHeight; // Not used 00419 pView->GetScaledPixelSize(&ScaledPixelWidth, &ScaledPixelHeight); 00420 Width = (MILLIPOINT)ScaledPixelWidth.MakeLong(); 00421 } 00422 00423 return Width; 00424 #else 00425 return 0; 00426 #endif // WEBSTER 00427 return 0; 00428 } 00429 00430 /*********************************************************************************************** 00431 00432 > virtual void NodeGuideline::Transform( TransformBase& Trans ) 00433 00434 Author: Mark_Neves (Xara Group Ltd) <camelotdev@xara.com> 00435 Created: 11/10/95 00436 Inputs: Trans = the transformation to apply 00437 Outputs: - 00438 Returns: - 00439 Purpose: Transforms the guideline using Trans 00440 00441 ***********************************************************************************************/ 00442 00443 void NodeGuideline::Transform( TransformBase& Trans ) 00444 { 00445 #if !defined(EXCLUDE_FROM_RALPH) 00446 DocCoord Coord(Ordinate,Ordinate); 00447 00448 Trans.Transform(&Coord,1); 00449 00450 if (Type == GUIDELINE_HORZ) 00451 Ordinate = Coord.y; 00452 else 00453 Ordinate = Coord.x; 00454 #endif 00455 } 00456 00457 /*********************************************************************************************** 00458 00459 > virtual void NodeGuideline::PreExportRender(RenderRegion* pRegion) 00460 00461 Author: Mark_Neves (Xara Group Ltd) <camelotdev@xara.com> 00462 Created: 11/10/95 00463 Inputs: pRegion = the render region to export to 00464 Outputs: - 00465 Returns: - 00466 Purpose: Called before any child nodes are asked to export 00467 00468 ***********************************************************************************************/ 00469 00470 void NodeGuideline::PreExportRender(RenderRegion* pRegion) 00471 { 00472 // WEBSTER - markn 14/1/97 00473 #ifndef WEBSTER 00474 #ifdef DO_EXPORT 00475 if (pRegion->IS_KIND_OF(NativeRenderRegion)) 00476 { 00477 EPSExportDC *pDC = (EPSExportDC *) pRegion->GetRenderDC(); 00478 00479 // pDC->OutputValue(INT32(TAG_GUIDELINE)); // Output start extended object tag and token 00480 // pDC->OutputToken("cso"); 00481 // pDC->OutputNewLine(); 00482 00483 pDC->OutputValue(Ordinate); 00484 pDC->OutputValue(INT32(Type)); 00485 00486 pDC->OutputToken(_T("glne")); // Camelot "guideline" token 00487 pDC->OutputNewLine(); 00488 } 00489 #endif 00490 #endif // WEBSTER 00491 } 00492 00493 /*********************************************************************************************** 00494 00495 > virtual BOOL NodeGuideline::ExportRender(RenderRegion* pRegion) 00496 00497 Author: Mark_Neves (Xara Group Ltd) <camelotdev@xara.com> 00498 Created: 11/10/95 00499 Inputs: pRegion = the render region to export to 00500 Outputs: - 00501 Returns: TRUE if exported completely, FALSE to indicate Render() needs to be called 00502 Purpose: Called after child nodes are asked to export 00503 00504 ***********************************************************************************************/ 00505 00506 BOOL NodeGuideline::ExportRender(RenderRegion* pRegion) 00507 { 00508 // WEBSTER - markn 14/1/97 00509 #ifndef WEBSTER 00510 #ifdef DO_EXPORT 00511 if (pRegion->IS_KIND_OF(NativeRenderRegion)) 00512 { 00513 /*EPSExportDC *pDC = */ (EPSExportDC *) pRegion->GetRenderDC(); 00514 00515 // pDC->OutputToken(_T("ceo")); // Output end extended object token 00516 // pDC->OutputNewLine(); 00517 } 00518 #endif 00519 #endif // WEBSTER 00520 return TRUE; 00521 } 00522 00523 /*********************************************************************************************** 00524 00525 > virtual void NodeGuideline::Render(RenderRegion* pRender) 00526 00527 Author: Mark_Neves (Xara Group Ltd) <camelotdev@xara.com> 00528 Created: 5/9/95 00529 Inputs: RendRegion: Render region to render into 00530 Outputs: - 00531 Returns: - 00532 Purpose: For rendering a node 00533 00534 ***********************************************************************************************/ 00535 00536 void NodeGuideline::Render( RenderRegion* pRender ) 00537 { 00538 #if !defined(EXCLUDE_FROM_RALPH) 00539 pRender->SaveContext(); 00540 DocRect Rect = pRender->GetClipRect(); 00541 00542 DocCoord StartCoord,EndCoord; 00543 00544 // INT32 DashUnit = (72000/4)*4; 00545 00546 if (Type == GUIDELINE_HORZ) 00547 { 00548 StartCoord.x = Rect.lo.x; 00549 EndCoord.x = Rect.hi.x; 00550 PullOntoStep(&StartCoord.x,&EndCoord.x,pRender->GetScaledPixelWidth()*4); 00551 00552 StartCoord.y = EndCoord.y = Ordinate; 00553 } 00554 else 00555 { 00556 StartCoord.y = Rect.lo.y; 00557 EndCoord.y = Rect.hi.y; 00558 PullOntoStep(&StartCoord.y,&EndCoord.y,pRender->GetScaledPixelWidth()*4); 00559 00560 StartCoord.x = EndCoord.x = Ordinate; 00561 } 00562 00563 pRender->DrawLine(StartCoord,EndCoord); 00564 00565 pRender->RestoreContext(); 00566 #endif 00567 } 00568 00569 /******************************************************************************************** 00570 00571 > BOOL NodeGuideline::NeedsToRender(RenderRegion *pRender) 00572 00573 Author: Mark_Neves (Xara Group Ltd) <camelotdev@xara.com> 00574 Created: 25/5/94 00575 Inputs: pRender - A pointer to the current render region (null if none) 00576 Returns: TRUE => This node should be rendered, 00577 FALSE => This node does not need to be rendered. 00578 Purpose: This function will indicate to the caller whether or not 00579 we want to render the given node, according to the information passed in. 00580 SeeAlso: NodeRenderableBounded::NeedsToRender 00581 00582 ********************************************************************************************/ 00583 00584 SubtreeRenderState NodeGuideline::RenderSubtree(RenderRegion* pRender, Node** ppNextNode, BOOL bClip) 00585 { 00586 #if !defined(EXCLUDE_FROM_RALPH) 00587 // If no cliprect supplied, assume we do need to render 00588 if (pRender==NULL) 00589 return SUBTREE_ROOTANDCHILDREN; 00590 00591 if (pRender->IsPrinting()) 00592 return SUBTREE_NORENDER; 00593 00594 if (pRender->IS_KIND_OF(EPSRenderRegion)) 00595 return SUBTREE_NORENDER; 00596 00597 return SUBTREE_ROOTANDCHILDREN; 00598 #else 00599 return SUBTREE_NORENDER; 00600 #endif 00601 } 00602 00603 /******************************************************************************************** 00604 00605 > BOOL NodeGuideline::NeedsToExport(RenderRegion *pRender,BOOL VisibleLayersOnly = FALSE, BOOL CheckSelected = FALSE) 00606 00607 Author: Mark_Neves (Xara Group Ltd) <camelotdev@xara.com> 00608 Created: 25/5/94 00609 Inputs: pRender - A pointer to the current render region (null if none) 00610 ExcludeInvisibleLayers - TRUE => remove nodes which are on invisible layers 00611 - FALSE => export everything 00612 CheckSelected - TRUE => we check if object selected and only export selected bjects 00613 - FALSE => we don't bother checking for selection or not 00614 Returns: TRUE => This node should be exported, 00615 FALSE => This node does not need to be exported. 00616 Purpose: This function will indicate to the caller whether or not 00617 we want to export the given node, according to the information passed in. 00618 00619 NodeGuidelines only export to the native file format. 00620 00621 SeeAlso: NodeGuideline::NeedsToRender 00622 00623 ********************************************************************************************/ 00624 00625 BOOL NodeGuideline::NeedsToExport(RenderRegion *pRender,BOOL VisibleLayersOnly, BOOL CheckSelected) 00626 { 00627 // WEBSTER - markn 14/1/97 00628 #ifdef DO_EXPORT 00629 #ifndef WEBSTER 00630 return (pRender->IS_KIND_OF(NativeRenderRegion)); 00631 #endif // WEBSTER 00632 #endif 00633 return FALSE; 00634 } 00635 00636 /*********************************************************************************************** 00637 00638 > DocRect NodeGuideline::GetRenderRect(BOOL HitTest= FALSE, RenderRegion* pRender = NULL) 00639 00640 Author: Mark_Neves (Xara Group Ltd) <camelotdev@xara.com> 00641 Created: 5/9/95 00642 Inputs: pRenderRect = ptr to a render region (if NULL current DocView is used) 00643 HitTest - TRUE if being called during HitTest 00644 Outputs: - 00645 Returns: Bounding rect for this guideline 00646 Purpose: see NodeGuideline::GetRenderRect(Ordinate,Type,HitTest,pRender) 00647 SeeAlso: CSnap 00648 00649 ***********************************************************************************************/ 00650 00651 DocRect NodeGuideline::GetRenderRect(BOOL HitTest, RenderRegion* pRender) 00652 { 00653 return NodeGuideline::GetRenderRect(Ordinate,Type,HitTest,pRender); 00654 } 00655 00656 /*********************************************************************************************** 00657 00658 > static DocRect NodeGuideline::GetRenderRect(MILLIPOINT Ordinate,GuidelineType Type,BOOL HitTest= FALSE, RenderRegion* pRender = NULL) 00659 00660 Author: Mark_Neves (Xara Group Ltd) <camelotdev@xara.com> 00661 Created: 12/9/95 00662 Inputs: Ordinate = ordinate value 00663 Type = guideline type 00664 pRenderRect = ptr to a render region (if NULL current DocView is used) 00665 HitTest - TRUE if being called during HitTest 00666 Outputs: - 00667 Returns: Rect to render 00668 Purpose: Main routine for calculating the bounding rect that represents a guideline 00669 This is mainly used for invalidating areas on screen for redraw purposes. 00670 If HitTest is TRUE, the rect is inflated by the size of the magnetic snap distance 00671 so that clicking near a guideline in order to drag it will work. 00672 SeeAlso: NodeGuideline::GetScaledPixelWidth() 00673 00674 ***********************************************************************************************/ 00675 00676 DocRect NodeGuideline::GetRenderRect(MILLIPOINT Ordinate,GuidelineType Type,BOOL HitTest, RenderRegion* pRender) 00677 { 00678 #if !defined(EXCLUDE_FROM_RALPH) 00679 DocRect Rect = DocRect(Ordinate,Ordinate,Ordinate,Ordinate); 00680 00681 MILLIPOINT PixelWidth = GetScaledPixelWidth(pRender); 00682 00683 if (HitTest) 00684 PixelWidth = (CSnap::GetSnapDist()*2); 00685 else 00686 PixelWidth *= 2; 00687 00688 if (Type == GUIDELINE_HORZ) 00689 { 00690 Rect.lo.x = MIN_INT; 00691 Rect.hi.x = MAX_INT; 00692 Rect.lo.y -= PixelWidth/2; 00693 Rect.hi.y += PixelWidth/2; 00694 } 00695 else 00696 { 00697 Rect.lo.x -= PixelWidth/2; 00698 Rect.hi.x += PixelWidth/2; 00699 Rect.lo.y = MIN_INT; 00700 Rect.hi.y = MAX_INT; 00701 } 00702 00703 return Rect; 00704 #else 00705 return DocRect(0,0,0,0); 00706 #endif 00707 } 00708 00709 /*********************************************************************************************** 00710 00711 > virtual DocRect NodeGuideline::GetBoundingRect(BOOL DontUseAttrs=FALSE, BOOL HitTest=FALSE) 00712 00713 Author: Mark_Neves (Xara Group Ltd) <camelotdev@xara.com> 00714 Created: 5/9/95 00715 Inputs: DontUseAttrs - TRUE if you want to ignore all the nodes attributes 00716 FALSE by default. 00717 HitTest - TRUE if being called during HitTest 00718 Outputs: - 00719 Returns: Bounding rect for the guideline 00720 Purpose: Calcs the bounds of the guideline. This varies with the current view. 00721 00722 NOTE: Bounds are only given for hit testing. This is so the bounds of guidelines 00723 aren't incorporated into the bounds of its parent (i.e. the layer). 00724 If you don't do this, doing a 'zoom to objects' will try and zoom to guidelines 00725 which is very wrong 00726 SeeAlso: CSnap 00727 00728 ***********************************************************************************************/ 00729 00730 DocRect NodeGuideline::GetBoundingRect(BOOL DontUseAttrs, BOOL HitTest) 00731 { 00732 // WEBSTER - markn 14/1/97 00733 #ifndef WEBSTER 00734 if (HitTest) 00735 return GetRenderRect(HitTest); 00736 else 00737 #endif // WEBSTER 00738 return DocRect(0,0,0,0); 00739 } 00740 00741 /******************************************************************************************** 00742 00743 > virtual BOOL NodeGuideline::OnClick( DocCoord PointerPos, ClickType Click, 00744 ClickModifiers ClickMods, Spread *pSpread ) 00745 00746 Author: Mark_Neves (Xara Group Ltd) <camelotdev@xara.com> 00747 Created: 6/9/95 00748 Inputs: PointerPos - The Location of the mouse pointer at the time of the click 00749 Click - The type of click received (single, double, drag etc) 00750 ClickMods - The modifiers to the click (eg shift, control etc ) 00751 pSpread - The spread the click occured in 00752 Returns: BOOL - TRUE if the node claims the click as its own and FALSE if it is 00753 not interested in the click 00754 Purpose: Allows the Node to respond to clicks. 00755 00756 Guidelines will return TRUE for ALL clicks. 00757 00758 They only acually do something on CLICKTYPE_SINGLE clicks. With this click they 00759 initiate a drag on the guideline to allow the user to move them about the page. 00760 00761 ***********************************************************************************************/ 00762 00763 BOOL NodeGuideline::OnClick( DocCoord PointerPos, ClickType Click, ClickModifiers ClickMods, Spread *pSpread) 00764 { 00765 #if !defined(EXCLUDE_FROM_RALPH) 00766 if (ClickMods.Menu) 00767 return FALSE; 00768 00769 if (Click == CLICKTYPE_SINGLE) 00770 { 00771 OpDescriptor* pOpDesc = OpDescriptor::FindOpDescriptor(OPTOKEN_GUIDELINE); 00772 ERROR3IF(pOpDesc == NULL,"FindOpDescriptor(OPTOKEN_GUIDELINE) failed"); 00773 00774 if (pOpDesc != NULL) 00775 { 00776 OpGuidelineParam GuidelineParam; 00777 00778 GuidelineParam.Method = GUIDELINEOPMETHOD_MOVE_DRAG; 00779 GuidelineParam.pGuideline = this; 00780 00781 pOpDesc->Invoke(&GuidelineParam); 00782 } 00783 } 00784 #endif 00785 return TRUE; 00786 } 00787 00788 00789 /******************************************************************************************** 00790 > virtual BOOL NodeGuideline::OnNodePopUp(Spread* pSpread, DocCoord PointerPos, ContextMenu* pMenu) 00791 00792 Author: Mark_Neves (Xara Group Ltd) <camelotdev@xara.com> 00793 Created: 12/5/95 00794 Inputs: pSpread The spread in which things are happening 00795 PointerPos The Location of the mouse pointer at the time of the click 00796 pMenu The menu to which items should be added 00797 Returns: BOOL - TRUE if the node claims the click as its own and FALSE if it is 00798 not interested in the click 00799 Purpose: Allows the guideline to respond to pop up menu clicks on itself. 00800 ********************************************************************************************/ 00801 00802 BOOL NodeGuideline::OnNodePopUp(Spread* pSpread, DocCoord PointerPos, ContextMenu* pMenu) 00803 { 00804 // WEBSTER-ranbirr-01/12/96 00805 #ifndef WEBSTER 00806 BOOL ok = TRUE; 00807 00808 #if !defined(EXCLUDE_FROM_RALPH) 00809 // set up data required for ops which could be invoked 00810 GuidelinePropDlg::SetEditGuidelineParams(this); 00811 OpDeleteGuideline::SetGuideline(this); 00812 00813 ok = ok && pMenu->BuildCommand(OPTOKEN_DELETEGUIDELINE); 00814 ok = ok && pMenu->BuildCommand(OPTOKEN_SNAPTOGUIDES,TRUE); 00815 ok = ok && pMenu->BuildCommand(OPTOKEN_EDITGUIDELINEPROPDLG); 00816 ok = ok && pMenu->BuildCommand(OPTOKEN_GUIDEPROPERTIESDLG); 00817 #endif 00818 00819 return ok; 00820 #else //webster 00821 return FALSE; 00822 #endif //webster 00823 } 00824 00825 /******************************************************************************************** 00826 00827 > virtual void NodeGuideline::SetSelected(BOOL Status) 00828 00829 Author: Mark_Neves (Xara Group Ltd) <camelotdev@xara.com> 00830 Created: 7/9/95 00831 Inputs: Status = selection state (ignored) 00832 Returns: - 00833 Purpose: Overrides the base class selection function 00834 00835 'Status' is ignored and the node is always forced to be unselected. 00836 00837 ***********************************************************************************************/ 00838 00839 void NodeGuideline::SetSelected(BOOL Status) 00840 { 00841 Flags.Selected = FALSE; 00842 } 00843 00844 /*********************************************************************************************** 00845 00846 > MILLIPOINT NodeGuideline::ExtractOrdinate(DocCoord* pDocCoord) 00847 00848 Author: Mark_Neves (Xara Group Ltd) <camelotdev@xara.com> 00849 Created: 5/9/95 00850 Inputs: pDocCoord = A DocCoord in Spread coords 00851 Outputs: - 00852 Returns: Either the X or the Y ordinate, dependant on the guideline type 00853 Purpose: Central place for ordinate extraction 00854 SeeAlso: CSnap 00855 00856 ***********************************************************************************************/ 00857 00858 MILLIPOINT NodeGuideline::ExtractOrdinate(DocCoord* pDocCoord) 00859 { 00860 #ifndef WEBSTER 00861 // WEBSTER - markn 14/1/97 00862 ERROR3IF(pDocCoord == NULL,"pDocCoord is NULL"); 00863 00864 if (Type == GUIDELINE_HORZ) 00865 return pDocCoord->y; 00866 else 00867 return pDocCoord->x; 00868 #else 00869 return 0; 00870 #endif // WEBSTER 00871 } 00872 00873 /*********************************************************************************************** 00874 00875 > void NodeGuideline::ReplaceOrdinate(DocCoord* pDocCoord,MILLIPOINT Ordinate) 00876 00877 Author: Mark_Neves (Xara Group Ltd) <camelotdev@xara.com> 00878 Created: 5/9/95 00879 Inputs: pDocCoord = A DocCoord in Spread coords 00880 Ordinate = ordinate value 00881 Outputs: Either the X or the Y ordinate of pDocCoord set to Ordinate, dependant on the guideline type 00882 Returns: - 00883 Purpose: Central place for ordinate setting 00884 SeeAlso: CSnap 00885 00886 ***********************************************************************************************/ 00887 00888 void NodeGuideline::ReplaceOrdinate(DocCoord* pDocCoord,MILLIPOINT Ordinate) 00889 { 00890 // WEBSTER - markn 14/1/97 00891 #ifndef WEBSTER 00892 ERROR3IF(pDocCoord == NULL,"pDocCoord is NULL"); 00893 00894 if (Type == GUIDELINE_HORZ) 00895 pDocCoord->y = Ordinate; 00896 else 00897 pDocCoord->x = Ordinate; 00898 #endif // WEBSTER 00899 } 00900 00901 00902 /*********************************************************************************************** 00903 00904 > static MILLIPOINT NodeGuideline::ToSpreadOrdinate(Spread* pSpread,MILLIPOINT UserOrdinate,GuidelineType Type) 00905 00906 Author: Mark_Neves (Xara Group Ltd) <camelotdev@xara.com> 00907 Created: 3/10/95 00908 Inputs: pSpread = ptr to a spread 00909 UserOrdinate= ordinate value in UserCoords 00910 Type = the type of guideline 00911 Outputs: - 00912 Returns: Spread ordinate version of UserOrdinate 00913 Purpose: Converts a given ordinate within UserCoord space, into a Spread-related ordinate 00914 SeeAlso: 00915 00916 ***********************************************************************************************/ 00917 00918 MILLIPOINT NodeGuideline::ToSpreadOrdinate(Spread* pSpread,MILLIPOINT UserOrdinate,GuidelineType Type) 00919 { 00920 // WEBSTER - markn 14/1/97 00921 #ifndef WEBSTER 00922 ERROR2IF(pSpread == NULL,0,"pSpread is NULL"); 00923 00924 UserCoord UCoord(UserOrdinate,UserOrdinate); 00925 DocCoord DCoord = UCoord.ToSpread(pSpread); 00926 00927 if (Type == GUIDELINE_HORZ) 00928 return DCoord.y; 00929 else 00930 return DCoord.x; 00931 #else 00932 return 0; 00933 #endif // WEBSTER 00934 } 00935 00936 /*********************************************************************************************** 00937 00938 > static MILLIPOINT NodeGuideline::ToUserOrdinate(Spread* pSpread,MILLIPOINT SpreadOrdinate,GuidelineType Type) 00939 00940 Author: Mark_Neves (Xara Group Ltd) <camelotdev@xara.com> 00941 Created: 3/10/95 00942 Inputs: pSpread = ptr to a spread 00943 SpreadOrdinate = ordinate value in UserCoords 00944 Type = the type of guideline 00945 Outputs: - 00946 Returns: User ordinate version of SpreadOrdinate 00947 Purpose: Converts a given ordinate within SpreadCoord space, into a User-related ordinate 00948 SeeAlso: 00949 00950 ***********************************************************************************************/ 00951 00952 MILLIPOINT NodeGuideline::ToUserOrdinate(Spread* pSpread,MILLIPOINT SpreadOrdinate,GuidelineType Type) 00953 { 00954 // WEBSTER - markn 14/1/97 00955 #ifndef WEBSTER 00956 ERROR2IF(pSpread == NULL,0,"pSpread is NULL"); 00957 00958 DocCoord DCoord(SpreadOrdinate,SpreadOrdinate); 00959 UserCoord UCoord = DCoord.ToUser(pSpread); 00960 00961 if (Type == GUIDELINE_HORZ) 00962 return UCoord.y; 00963 else 00964 return UCoord.x; 00965 #else 00966 return 0; 00967 #endif // WEBSTER 00968 } 00969 00970 00971 /*********************************************************************************************** 00972 00973 > void NodeGuideline::TranslateRect(DocRect* pDocRect,MILLIPOINT Delta) 00974 00975 Author: Mark_Neves (Xara Group Ltd) <camelotdev@xara.com> 00976 Created: 5/9/95 00977 Inputs: pDocRect = ptr to a DocRect 00978 Delta = amount to translate rect by 00979 Outputs: Either the X or the Y ordinates of pDocRec are translated by Delta, dependant on the guideline type 00980 Returns: - 00981 Purpose: Central place for doc rect translation 00982 SeeAlso: CSnap 00983 00984 ***********************************************************************************************/ 00985 00986 void NodeGuideline::TranslateRect(DocRect* pDocRect,MILLIPOINT Delta) 00987 { 00988 // WEBSTER - markn 14/1/97 00989 #ifndef WEBSTER 00990 ERROR3IF(pDocRect == NULL,"pDocRect is NULL"); 00991 00992 if (Type == GUIDELINE_HORZ) 00993 pDocRect->Translate(0,Delta); 00994 else 00995 pDocRect->Translate(Delta,0); 00996 #endif // WEBSTER 00997 } 00998 00999 /*********************************************************************************************** 01000 01001 > virtual BOOL NodeGuideline::Snap(DocCoord* pDocCoord) 01002 01003 Author: Mark_Neves (Xara Group Ltd) <camelotdev@xara.com> 01004 Created: 5/9/95 01005 Inputs: pDocCoord = A DocCoord in Spread coords 01006 Outputs: - 01007 Returns: TRUE if pDocCoord has snapped to this guideline - FALSE otherwise 01008 Purpose: The snap function for DocCoords 01009 SeeAlso: CSnap 01010 01011 ***********************************************************************************************/ 01012 01013 BOOL NodeGuideline::Snap(DocCoord* pDocCoord) 01014 { 01015 #if !defined(EXCLUDE_FROM_RALPH) 01016 MILLIPOINT SnapDist = CSnap::GetSnapDist(); 01017 MILLIPOINT SrcOrdinate = ExtractOrdinate(pDocCoord); 01018 01019 MILLIPOINT Dist = abs_milli(Ordinate-SrcOrdinate); 01020 01021 if (Dist <= SnapDist) 01022 { 01023 ReplaceOrdinate(pDocCoord,Ordinate); 01024 return TRUE; 01025 } 01026 #endif 01027 return FALSE; 01028 } 01029 01030 /*********************************************************************************************** 01031 01032 > virtual BOOL NodeGuideline::Snap(DocRect* pDocRect,const DocCoord& PrevCoord,const DocCoord& CurCoord); 01033 01034 Author: Mark_Neves (Xara Group Ltd) <camelotdev@xara.com> 01035 Created: 5/9/95 01036 Inputs: A DocRect, and two coords 01037 Outputs: - 01038 Returns: TRUE if pDocRect has snapped to this guideline - FALSE otherwise 01039 Purpose: Place holder for derived classes 01040 SeeAlso: CSnap 01041 01042 ***********************************************************************************************/ 01043 01044 BOOL NodeGuideline::Snap(DocRect* pDocRect,const DocCoord& PrevCoord,const DocCoord& CurCoord) 01045 { 01046 #if !defined(EXCLUDE_FROM_RALPH) 01047 MILLIPOINT SnapDist = CSnap::GetSnapDist(); 01048 01049 MILLIPOINT SrcOrdinate = ExtractOrdinate(&pDocRect->lo); 01050 MILLIPOINT Dist = Ordinate-SrcOrdinate; 01051 if (abs_milli(Dist) <= SnapDist) 01052 { 01053 TranslateRect(pDocRect,Dist); 01054 return TRUE; 01055 } 01056 01057 SrcOrdinate = ExtractOrdinate(&pDocRect->hi); 01058 Dist = Ordinate-SrcOrdinate; 01059 if (abs_milli(Dist) <= SnapDist) 01060 { 01061 TranslateRect(pDocRect,Dist); 01062 return TRUE; 01063 } 01064 #endif 01065 return FALSE; 01066 } 01067 01068 /*********************************************************************************************** 01069 01070 > virtual BOOL NodeGuideline::WritePreChildrenWeb(BaseCamelotFilter* pFilter) 01071 01072 Author: Mark_Neves (Xara Group Ltd) <camelotdev@xara.com> 01073 Created: 8/8/96 01074 Inputs: pFilter = ptr to filter to write to 01075 Outputs: - 01076 Returns: TRUE if ok, FALSE otherwise 01077 Purpose: Web format doesn't export guidelines 01078 SeeAlso: 01079 01080 ***********************************************************************************************/ 01081 01082 BOOL NodeGuideline::WritePreChildrenWeb(BaseCamelotFilter* pFilter) 01083 { 01084 return FALSE; 01085 } 01086 01087 01088 /*********************************************************************************************** 01089 01090 > virtual BOOL NodeGuideline::WritePreChildrenNative(BaseCamelotFilter* pFilter) 01091 01092 Author: Mark_Neves (Xara Group Ltd) <camelotdev@xara.com> 01093 Created: 8/8/96 01094 Inputs: pFilter = ptr to filter to write to 01095 Outputs: - 01096 Returns: TRUE if ok, FALSE otherwise 01097 Purpose: Saves out the guideline in the v2 native file format 01098 SeeAlso: 01099 01100 ***********************************************************************************************/ 01101 01102 BOOL NodeGuideline::WritePreChildrenNative(BaseCamelotFilter* pFilter) 01103 { 01104 #ifdef DO_EXPORT 01105 ERROR2IF(pFilter == NULL,FALSE,"NULL filter param"); 01106 ERROR3IF(UINT32(Type) > 255,"Can't store the guideline type in a byte"); 01107 01108 CamelotFileRecord Rec(pFilter,TAG_GUIDELINE,TAG_GUIDELINE_SIZE); 01109 01110 BOOL ok = Rec.Init(); 01111 if (ok) ok = Rec.WriteBYTE(Type); 01112 01113 if (ok && Type == GUIDELINE_HORZ) 01114 ok = Rec.WriteYOrd(Ordinate); 01115 else 01116 ok = Rec.WriteXOrd(Ordinate); 01117 01118 if (ok) ok = pFilter->Write(&Rec); 01119 01120 if (!ok) 01121 pFilter->GotError(_R(IDE_FILE_WRITE_ERROR)); 01122 01123 return ok; 01124 #else 01125 return FALSE; 01126 #endif 01127 } 01128 01129 //-------------------------------------------------------------------------------------------- 01130 01131 #ifdef _DEBUG 01132 01133 void NodeGuideline::ShowDebugTreeDetails() const 01134 { 01135 NodeRenderableInk::ShowDebugTreeDetails(); 01136 } 01137 #endif 01138 01139 01140 //-------------------------------------------------------------------------------------------- 01141 //-------------------------------------------------------------------------------------------- 01142 //-------------------------------------------------------------------------------------------- 01143 01144 #if !defined(EXCLUDE_FROM_RALPH) 01145 01146 /*********************************************************************************************** 01147 01148 > OpGuideline::OpGuideline() 01149 01150 Author: Mark_Neves (Xara Group Ltd) <camelotdev@xara.com> 01151 Created: 7/9/95 01152 Inputs: - 01153 Outputs: - 01154 Returns: - 01155 Purpose: Default constructor 01156 SeeAlso: UndoableOperation 01157 01158 ***********************************************************************************************/ 01159 01160 OpGuideline::OpGuideline() 01161 { 01162 pDraggedGuideline = NULL; 01163 pBroadcastLayer = NULL; 01164 UndoIDS = _R(IDS_MARKN_EMPTY); 01165 LeaveCopy = FALSE; 01166 pCursor = NULL; 01167 CurrentStatusHelp = _R(IDS_MARKN_EMPTY); 01168 CursorStackID = GUIDE_CURSORID_UNSET; 01169 RenderOn = TRUE; 01170 } 01171 01172 01173 /*********************************************************************************************** 01174 01175 > OpGuideline::~OpGuideline() 01176 01177 Author: Mark_Neves (Xara Group Ltd) <camelotdev@xara.com> 01178 Created: 7/9/95 01179 Inputs: - 01180 Outputs: - 01181 Returns: - 01182 Purpose: Default destructor 01183 SeeAlso: UndoableOperation 01184 01185 ***********************************************************************************************/ 01186 01187 OpGuideline::~OpGuideline() 01188 { 01189 if (pCursor != NULL) 01190 delete pCursor; 01191 } 01192 01193 /*********************************************************************************************** 01194 01195 > void OpGuideline::BroadcastGuidelineChanges(NodeGuideline* pGuideline) 01196 01197 Author: Mark_Neves (Xara Group Ltd) <camelotdev@xara.com> 01198 Created: 4/10/95 01199 Inputs: pGuideline = ptr to guideline 01200 Outputs: - 01201 Returns: - 01202 Purpose: Broadcasts a LayerMsg::LayerReason::GUIDELINES_CHANGED for the parent layer 01203 of pGuideline 01204 SeeAlso: DoWithParams() 01205 01206 ***********************************************************************************************/ 01207 01208 void OpGuideline::BroadcastGuidelineChanges(NodeGuideline* pGuideline) 01209 { 01210 if (pGuideline != NULL) 01211 BroadcastGuidelineChanges((Layer*)pGuideline->FindParent(CC_RUNTIME_CLASS(Layer))); 01212 } 01213 01214 /*********************************************************************************************** 01215 01216 > void OpGuideline::BroadcastGuidelineChanges(Layer* pLayer) 01217 01218 Author: Mark_Neves (Xara Group Ltd) <camelotdev@xara.com> 01219 Created: 4/10/95 01220 Inputs: pLayer = ptr to layer 01221 Outputs: - 01222 Returns: - 01223 Purpose: Broadcasts a LayerMsg::LayerReason::GUIDELINES_CHANGED for the given layer 01224 SeeAlso: DoWithParams() 01225 01226 ***********************************************************************************************/ 01227 01228 void OpGuideline::BroadcastGuidelineChanges(Layer* pLayer) 01229 { 01230 if (pLayer != NULL) 01231 { 01232 BROADCAST_TO_ALL(LayerMsg(pLayer,LayerMsg::GUIDELINES_CHANGED)); 01