guides.cpp

Go to the documentation of this file.
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));
01233     }
01234 
01235     pBroadcastLayer = pLayer;
01236 }
01237 
01238 /***********************************************************************************************
01239 
01240 >   void OpGuideline::DoWithParam(OpDescriptor* pOpDesc,OpParam* pParam)
01241 
01242     Author:     Mark_Neves (Xara Group Ltd) <camelotdev@xara.com>
01243     Created:    22/9/95
01244     Inputs:     pOpDesc = ptr op desc
01245                 pOpParam = param block to use
01246     Outputs:    -
01247     Returns:    -
01248     Purpose:    This function is used to create a guideline in the selected spread.
01249                 It calls DoAddNewGuideline() with pParam->Param1 specifying the guideline type.
01250     SeeAlso:    DoAddNewGuideline(), OilRuler::OnLButtonDown()
01251         
01252 ***********************************************************************************************/
01253 
01254 void OpGuideline::DoWithParam(OpDescriptor* pOpDesc,OpParam* pParam)
01255 {
01256     ERROR3IF(pParam == NULL,"pParam is NULL");
01257 
01258     if (pParam != NULL)
01259     {
01260         OpGuidelineParam* pGuidelineParam = (OpGuidelineParam*)pParam;
01261         NodeGuideline* pGuideline = pGuidelineParam->pGuideline;
01262 
01263         OpMethod = pGuidelineParam->Method;
01264 
01265         switch (OpMethod)
01266         {
01267             //-----------------------------------
01268             case GUIDELINEOPMETHOD_MOVE_DRAG:
01269             {
01270                 ERROR3IF(pGuideline == NULL,"pGuideline is NULL");
01271 
01272                 if (pGuideline != NULL)
01273                 {
01274                     DocCoord PointerPos(pGuideline->GetOrdinate(),pGuideline->GetOrdinate());
01275                     DoMoveGuideline(NULL,PointerPos,pGuideline);
01276                 }
01277             }
01278             UndoIDS = _R(IDS_OPMOVEGUIDELINE);
01279             break;
01280 
01281             //-----------------------------------
01282             case GUIDELINEOPMETHOD_MOVE_IMMEDIATE:
01283             {
01284                 ERROR3IF(pGuideline == NULL,"pGuideline is NULL");
01285 
01286                 pSpread = Document::GetSelectedSpread();
01287 
01288                 if (pGuideline != NULL && !DoTranslateGuideline(pGuideline,pGuidelineParam->NewOrdinate))
01289                     FailAndExecute();
01290                 else
01291                     BroadcastGuidelineChanges(pSpread->FindFirstGuideLayer());
01292 
01293                 End();
01294             }
01295             UndoIDS = _R(IDS_OPMOVEGUIDELINE);
01296             break;
01297 
01298             //-----------------------------------
01299             case GUIDELINEOPMETHOD_NEW_DRAG:
01300             {
01301                 DocCoord PointerPos(-5000,-5000);
01302                 DoAddNewGuideline(NULL,PointerPos,pGuidelineParam->Type);
01303             }
01304             UndoIDS = _R(IDS_OPNEWGUIDELINE);
01305             break;
01306 
01307             //-----------------------------------
01308             case GUIDELINEOPMETHOD_NEW_IMMEDIATE:
01309             {
01310                 pSpread = Document::GetSelectedSpread();
01311 
01312                 if (!DoNewGuideline(NULL,NEXT,pGuidelineParam->Type,pGuidelineParam->NewOrdinate))
01313                     FailAndExecute();
01314                 else
01315                     BroadcastGuidelineChanges(pSpread->FindFirstGuideLayer());
01316 
01317                 End();
01318             }
01319             UndoIDS = _R(IDS_OPNEWGUIDELINE);
01320             break;
01321 
01322             //-----------------------------------
01323             case GUIDELINEOPMETHOD_CREATE_GUIDE_LAYER:
01324             {
01325                 pSpread = Document::GetSelectedSpread();
01326                 Layer* pGuideLayer = DoCreateGuideLayer();
01327 
01328                 if (pGuideLayer == NULL)
01329                     FailAndExecute();
01330                 else
01331                     BroadcastGuidelineChanges(pGuideLayer);
01332 
01333                 End();
01334             }
01335             UndoIDS = _R(IDS_OPCREATEGUIDELAYER);
01336             break;
01337 
01338             //-----------------------------------
01339             case GUIDELINEOPMETHOD_DELETE:
01340             {
01341                 pSpread = Document::GetSelectedSpread();
01342 
01343                 if (!DoDeleteListOfGuidelines(pGuidelineParam->pGuidelineList))
01344                     FailAndExecute();
01345                 else
01346                     BroadcastGuidelineChanges(pSpread->FindFirstGuideLayer());
01347 
01348                 End();
01349 
01350             }
01351             UndoIDS = _R(IDS_OPDELETESELECTEDGUIDELINES);       // ********* NEW RESOURCE STRING!!!!!!
01352             break;
01353             //-----------------------------------
01354             default:
01355                 ERROR3_PF(("Unknown OpGuideline method : %d",pGuidelineParam->Method));
01356                 break;
01357         }
01358     }
01359 }
01360 
01361 /***********************************************************************************************
01362 
01363 >   void OpGuideline::DoAddNewGuideline(Spread* pSpread,DocCoord PointerPos,GuidelineType TheType)
01364 
01365     Author:     Mark_Neves (Xara Group Ltd) <camelotdev@xara.com>
01366     Created:    7/9/95
01367     Inputs:     pThisSpread       = ptr to spread drag started in
01368                 PointerPos        = coord of point clicked
01369                 TheType           = The type of guideline
01370     Outputs:    -
01371     Returns:    -
01372     Purpose:    Starts a drag to add a new guideline to the document
01373     SeeAlso:    UndoableOperation
01374         
01375 ***********************************************************************************************/
01376 
01377 void OpGuideline::DoAddNewGuideline(Spread* pSpread,DocCoord PointerPos,GuidelineType TheType)
01378 {
01379     Type = TheType;
01380 
01381     DoDrag(pSpread,PointerPos);
01382 }
01383 
01384 /***********************************************************************************************
01385 
01386 >   void OpGuideline::DoMoveGuideline(Spread* pSpread,DocCoord PointerPos,NodeGuideline* pGuideline)
01387 
01388     Author:     Mark_Neves (Xara Group Ltd) <camelotdev@xara.com>
01389     Created:    7/9/95
01390     Inputs:     pThisSpread       = ptr to spread drag started in
01391                 PointerPos        = coord of point clicked
01392                 pGuideline        = the guideline to move
01393     Outputs:    -
01394     Returns:    -
01395     Purpose:    Starts a drag to add a new guideline to the document
01396     SeeAlso:    UndoableOperation
01397         
01398 ***********************************************************************************************/
01399 
01400 void OpGuideline::DoMoveGuideline(Spread* pSpread,DocCoord PointerPos,NodeGuideline* pGuideline)
01401 {
01402     pDraggedGuideline = pGuideline;
01403     Type              = pDraggedGuideline->GetType();
01404 
01405     DoDrag(pSpread,PointerPos);
01406 }
01407 
01408 
01409 /***********************************************************************************************
01410 
01411 >   void OpGuideline::DoDrag(Spread* pThisSpread,DocCoord PointerPos)
01412 
01413     Author:     Mark_Neves (Xara Group Ltd) <camelotdev@xara.com>
01414     Created:    7/9/95
01415     Inputs:     pThisSpread       = ptr to spread drag started in (NULL means get selected spread)
01416                 PointerPos        = coord of point clicked
01417     Outputs:    -
01418     Returns:    -
01419     Purpose:    Starts a drag for a new or existing guideline
01420     SeeAlso:    DoMoveGuideline(), DoAddNewGuideline()
01421         
01422 ***********************************************************************************************/
01423 
01424 void OpGuideline::DoDrag(Spread* pThisSpread,DocCoord PointerPos)
01425 {
01426     pSpread = pThisSpread;
01427 
01428     if (pSpread == NULL)
01429         pSpread = Document::GetSelectedSpread();
01430 
01431     ERROR3IF(pSpread == NULL,"pSpread == NULL");
01432     if (pSpread == NULL)
01433     {
01434         End();
01435         return;
01436     }
01437 
01438     SetOrdinate(PointerPos);
01439 
01440     RenderMyDragBlobs();
01441 
01442     LeaveCopy = KeyPress::IsKeyPressed(CAMKEY(ADD));
01443 
01444     if (pCursor == NULL)
01445     {
01446         ToolListItem* pItem = Tool::Find(TOOLID_SELECTOR);
01447 
01448         if (pItem != NULL)
01449         {
01450             Tool* pTool = pItem->m_pTool;
01451 
01452             if (pTool != NULL)
01453             {
01454                 if (Type == GUIDELINE_HORZ)
01455                     pCursor = new Cursor(pTool,_R(IDCSR_SEL_HGUIDE));
01456                 else
01457                     pCursor = new Cursor(pTool,_R(IDCSR_SEL_VGUIDE));
01458 
01459                 if (pCursor != NULL)
01460                     CursorStackID = CursorStack::GPush(pCursor);
01461             }
01462         }
01463     }
01464 
01465     UpdateStatusLineAndPointer();
01466 
01467     // Tell the Dragging system that we need drags to happen
01468     StartDrag( DRAGTYPE_DEFERSCROLL );
01469 }
01470     
01471 /***********************************************************************************************
01472 
01473 >   virtual void OpGuideline::DragPointerMove( DocCoord PointerPos, ClickModifiers ClickMods, Spread*, BOOL bSolidDrag)
01474 
01475     Author:     Mark_Neves (Xara Group Ltd) <camelotdev@xara.com>
01476     Created:    7/9/95
01477     Inputs:     PointerPos = coord of the pointer
01478                 ClickMods  = info on the click modifiers
01479                 pSpread    = ptr to spread 
01480     Outputs:    -
01481     Returns:    -
01482     Purpose:    Responds to a mouse move during a drag of a guideline
01483     SeeAlso:    UndoableOperation
01484         
01485 ***********************************************************************************************/
01486 
01487 void OpGuideline::DragPointerMove( DocCoord PointerPos, ClickModifiers ClickMods, Spread*, BOOL bSolidDrag)
01488 {
01489     // First Rub out the old box
01490     RenderMyDragBlobs();
01491 
01492     DocView::SnapCurrent(pSpread,&PointerPos);
01493 
01494     SetOrdinate(PointerPos);
01495 
01496     // Render the new drag box
01497     RenderMyDragBlobs();
01498 
01499     UpdateStatusLineAndPointer();
01500 }
01501 
01502 
01503 /***********************************************************************************************
01504 
01505 >   virtual void OpGuideline::DragFinished( DocCoord PointerPos, ClickModifiers ClickMods, Spread*, BOOL Success , BOOL bSolidDrag)
01506 
01507     Author:     Mark_Neves (Xara Group Ltd) <camelotdev@xara.com>
01508     Created:    7/9/95
01509     Inputs:     PointerPos = coord of the pointer
01510                 ClickMods  = info on the click modifiers
01511                 pSpread    = ptr to spread (not used)
01512                 Success    = TRUE if drag ended successfully, FALSE if drag terminated (usu. by pressing Escape)
01513     Outputs:    -
01514     Returns:    -
01515     Purpose:    Responds to the drag of a guideline ending
01516     SeeAlso:    UndoableOperation
01517         
01518 ***********************************************************************************************/
01519 
01520 void OpGuideline::DragFinished( DocCoord PointerPos, ClickModifiers ClickMods, Spread*, BOOL Success, BOOL bSolidDrag)
01521 {
01522     // First Rub out the old boxes
01523     RenderMyDragBlobs();
01524 
01525     if (Success)
01526     {
01527         DocView::SnapCurrent(pSpread,&PointerPos);
01528         SetOrdinate(PointerPos);
01529 
01530         if (pDraggedGuideline != NULL)
01531         {
01532             if (IsMouseOverRuler())
01533             {
01534                 UndoIDS = _R(IDS_OPDELETEGUIDELINE);
01535                 Success = DoDeleteGuideline(pDraggedGuideline);
01536             }
01537             else
01538                 Success = DoTranslateGuideline(pDraggedGuideline,Ordinate);
01539         }
01540         else
01541             Success = !IsMouseOverRuler() && DoNewGuideline(NULL,NEXT,Type,Ordinate);
01542     }
01543 
01544     // End the Drag
01545     EndDrag();
01546 
01547     // Restore cursor
01548     if (CursorStackID != GUIDE_CURSORID_UNSET)
01549     {
01550         CursorStack::GPop(CursorStackID);
01551         CursorStackID = GUIDE_CURSORID_UNSET;
01552     }
01553 
01554     if (pCursor != NULL)
01555     {
01556         delete pCursor;
01557         pCursor = NULL;
01558     }
01559 
01560     if (!Success)
01561         FailAndExecute();
01562     else
01563         BroadcastGuidelineChanges(pSpread->FindFirstGuideLayer());
01564     // End the op
01565     End();
01566 }
01567 
01568 /***********************************************************************************************
01569 
01570 >   void OpGuideline::UpdateStatusLineAndPointer()
01571 
01572     Author:     Mark_Neves (Xara Group Ltd) <camelotdev@xara.com>
01573     Created:    12/10/95
01574     Inputs:     -
01575     Outputs:    -
01576     Returns:    -
01577     Purpose:    Makes sure the status line AND pointer are correct during a drag
01578     SeeAlso:    UndoableOperation
01579         
01580 ***********************************************************************************************/
01581 
01582 void OpGuideline::UpdateStatusLineAndPointer()
01583 {
01584 //  if (pCursor != NULL && CursorStackID != GUIDE_CURSORID_UNSET)
01585 //      CursorStack::GSetTop(pCursor,CursorStackID);
01586 
01587     // Which status help should we display?
01588     UINT32 IDS = _R(IDS_DRAGDELETEGUIDE);
01589 
01590     if (!IsMouseOverRuler())
01591     {
01592         if (CanLeaveCopy())
01593         {
01594             if (Type == GUIDELINE_HORZ)
01595                 IDS = _R(IDS_DRAGCOPYHORZGUIDE);
01596             else
01597                 IDS = _R(IDS_DRAGCOPYVERTGUIDE);
01598         }
01599         else
01600         {
01601             if (Type == GUIDELINE_HORZ)
01602                 IDS = _R(IDS_SELHORZGUIDE);
01603             else
01604                 IDS = _R(IDS_SELVERTGUIDE);
01605         }
01606     }
01607 
01608     if (IDS != CurrentStatusHelp)
01609     {
01610         // put up some status line help
01611 
01612         CurrentStatusHelp = IDS;
01613         String_256 Str(IDS);
01614 
01615         StatusLine* pStatusLine=GetApplication()->GetpStatusLine();
01616         if (pStatusLine!=NULL)
01617             pStatusLine->UpdateText(&Str,STATUSLINE_SELDESC_STATBAR);
01618     }
01619 }
01620 
01621 /***********************************************************************************************
01622 
01623 >   virtual BOOL OpGuideline::DragKeyPress(KeyPress* pKeyPress, BOOL bSolidDrag)
01624 
01625     Author:     Mark_Neves (Xara Group Ltd) <camelotdev@xara.com>
01626     Created:    11/10/95
01627     Inputs:     pKeyPress = ptr to keypress object
01628     Outputs:    -
01629     Returns:    -
01630     Purpose:    Responds to a keypress during the drag
01631     SeeAlso:    DragFinished
01632         
01633 ***********************************************************************************************/
01634 
01635 BOOL OpGuideline::DragKeyPress(KeyPress* pKeyPress, BOOL bSolidDrag)
01636 {
01637     BOOL Processed = FALSE;
01638     switch (pKeyPress->GetVirtKey())
01639     {
01640         case CAMKEY(ADD):
01641             if (!pKeyPress->IsModified() && pKeyPress->IsPress() && !pKeyPress->IsRepeat())
01642             {
01643                 LeaveCopy = !LeaveCopy;
01644                 UpdateStatusLineAndPointer();
01645                 Processed = TRUE;
01646             }
01647             break;
01648 
01649         case CAMKEY(CONTROL):
01650             UpdateStatusLineAndPointer();
01651             Processed = TRUE;
01652             break;
01653     }
01654     return Processed;
01655 }
01656 
01657 /***********************************************************************************************
01658 
01659 >   static BOOL OpGuideline::IsMouseOverRuler()
01660 
01661     Author:     Mark_Neves (Xara Group Ltd) <camelotdev@xara.com>
01662     Created:    12/9/95
01663     Inputs:     -
01664     Outputs:    -
01665     Returns:    TRUE if mouse is over a ruler, FALSE otherwise
01666     Purpose:    Test to see where the mouse pointer is.
01667                 It will return TRUE if the mouse is over either ruler, or the origin gadget.
01668 
01669     SeeAlso:    OpGuideline::DragFinished()
01670         
01671 ***********************************************************************************************/
01672 
01673 BOOL OpGuideline::IsMouseOverRuler()
01674 {
01675     DocView* pDocView = DocView::GetSelected();
01676     if (pDocView != NULL)
01677     {
01678         CCamView* pCCamView = pDocView->GetConnectionToOilView();
01679         return (pCCamView->IsMouseOverRuler() != OVER_NO_RULERS);
01680     }
01681 
01682     return FALSE;
01683 }
01684 
01685 /***********************************************************************************************
01686 
01687 >   BOOL OpGuideline::DoTranslateGuideline(NodeGuideline* pGuideline,MILLIPOINT Ordinate,NodeGuideline** ppNewGuideline = NULL)
01688 
01689     Author:     Mark_Neves (Xara Group Ltd) <camelotdev@xara.com>
01690     Created:    12/9/95
01691     Inputs:     pGuideline = ptr to an existing guideline
01692                 Ordinate   = Absolute position to translate to
01693                 ppNewGuideline  = place to put ptr of translated guideline (Can be NULL)
01694 
01695     Outputs:    *ppNewGuideline = ptr to translated guideline (NULL if function fails)
01696     Returns:    TRUE if successful, FALSE otherwise
01697     Purpose:    Translates the given guideline to line up with Ordinate, undoably
01698     SeeAlso:    OpGuideline::DragFinished()
01699         
01700 ***********************************************************************************************/
01701 
01702 BOOL OpGuideline::DoTranslateGuideline(NodeGuideline* pGuideline,MILLIPOINT Ordinate,NodeGuideline** ppNewGuideline)
01703 {
01704     ERROR2IF(pGuideline == NULL,FALSE,"pGuideline is NULL");
01705 
01706     Type = pGuideline->GetType();
01707 
01708     BOOL ok = TRUE;
01709 
01710     if (ok) ok = DoNewGuideline(pGuideline,NEXT,Type,Ordinate,ppNewGuideline);
01711     if (ok) ok = DoDeleteGuideline(pGuideline,TRUE);
01712 
01713     return ok;
01714 }
01715 
01716 /***********************************************************************************************
01717 
01718 >   BOOL OpGuideline::DoNewGuideline(Node* pContext,AttachNodeDirection AttachDir,GuidelineType Type,MILLIPOINT Ordinate,NodeGuideline** ppNewGuideline = NULL)
01719 
01720     Author:     Mark_Neves (Xara Group Ltd) <camelotdev@xara.com>
01721     Created:    12/9/95
01722     Inputs:     pContext        = ptr to context node (Can be NULL)
01723                 AttachDir       = how the new guideline should be attached to the context node
01724                 Type            = type of guideline to create
01725                 Ordinate        = position of new guideline
01726                 ppNewGuideline  = place to put ptr of new guideline (Can be NULL)
01727 
01728     Outputs:    *ppNewGuideline = ptr to new guideline (NULL if function fails)
01729     Returns:    TRUE if successful, FALSE otherwise
01730     Purpose:    Creates a new guideline to line up with Ordinate, undoably
01731 
01732     SeeAlso:    OpGuideline::DragFinished()
01733         
01734 ***********************************************************************************************/
01735 
01736 BOOL OpGuideline::DoNewGuideline(Node* pContext,AttachNodeDirection AttachDir,GuidelineType Type,MILLIPOINT Ordinate,NodeGuideline** ppNewGuideline)
01737 {
01738     if (pContext == NULL)
01739     {
01740         pContext = DoCreateGuideLayer();
01741         AttachDir = LASTCHILD;
01742     }
01743 
01744     ERROR2IF(pContext == NULL,FALSE,"pContext is NULL");
01745 
01746     BOOL ok = TRUE;
01747 
01748     NodeGuideline* pNewGuideline = new NodeGuideline;
01749     ok = (pNewGuideline != NULL);
01750     if (ok)
01751     {
01752         pNewGuideline->SetType(Type);
01753         pNewGuideline->SetOrdinate(Ordinate);
01754 
01755         DocRect Rect = pNewGuideline->GetRenderRect(FALSE);
01756 
01757         if (ok) ok = DoInsertNewNode(pNewGuideline,pContext,AttachDir,FALSE,FALSE,FALSE,FALSE);
01758         if (ok) ok = DoInvalidateRegion(pSpread,Rect);
01759     }
01760 
01761     if (!ok && pNewGuideline != NULL)
01762     {
01763         delete pNewGuideline;
01764         pNewGuideline = NULL;
01765     }
01766 
01767     if (ppNewGuideline != NULL)
01768         *ppNewGuideline = pNewGuideline;
01769 
01770     return ok;
01771 }
01772 
01773 /***********************************************************************************************
01774 
01775 >   BOOL OpGuideline::DoDeleteGuideline(NodeGuideline* pGuideline,BOOL TryToLeaveCopy = FALSE)
01776 
01777     Author:     Mark_Neves (Xara Group Ltd) <camelotdev@xara.com>
01778     Created:    12/9/95
01779     Inputs:     pGuideline = ptr to an existing guideline
01780                 TryToLeaveCopy = TRUE to try and leave copy, FALSE means force delete
01781     Outputs:    -
01782     Returns:    TRUE if successful, FALSE otherwise
01783     Purpose:    Deletes the given guideline, undoably
01784     SeeAlso:    OpGuideline::DragFinished()
01785         
01786 ***********************************************************************************************/
01787 
01788 BOOL OpGuideline::DoDeleteGuideline(NodeGuideline* pGuideline,BOOL TryToLeaveCopy)
01789 {
01790     BOOL ok = TRUE;
01791 
01792     if (TryToLeaveCopy && CanLeaveCopy())
01793     {
01794         // User is trying to copy the guideline, so just set up the correct undo string
01795         UndoIDS = _R(IDS_OPCOPYGUIDELINE);
01796     }
01797     else
01798     {
01799         ERROR2IF(pGuideline == NULL,FALSE,"pGuideline is NULL");
01800 
01801         pSpread = pGuideline->FindParentSpread();
01802         ERROR2IF_PF(pSpread == NULL,FALSE,("pGuideline (0x%x) has no parent spread",pGuideline));
01803 
01804         DocRect Rect = pGuideline->GetRenderRect(FALSE);
01805 
01806         if (ok) ok = DoInvalidateRegion(pSpread,Rect);
01807         if (ok) ok = DoHideNode(pGuideline,TRUE);
01808     }
01809 
01810     return ok;
01811 }
01812 
01813 
01814 /***********************************************************************************************
01815 
01816 >   BOOL OpGuideline::CanLeaveCopy()
01817 
01818     Author:     Mark_Neves (Xara Group Ltd) <camelotdev@xara.com>
01819     Created:    11/10/95
01820     Inputs:     -
01821     Outputs:    -
01822     Returns:    TRUE if user wants to leave a copy behind, FALSE otherwise
01823     Purpose:    Sees if the user wants to leave a copy behind
01824 
01825                 TRUE is returned if the ctrl is pressed, or Numpad + has been pressed an odd number
01826                 of times during the drag
01827 
01828     SeeAlso:    OpGuideline::DragFinished()
01829         
01830 ***********************************************************************************************/
01831 
01832 BOOL OpGuideline::CanLeaveCopy()
01833 {
01834     return (LeaveCopy || KeyPress::IsConstrainPressed());
01835 }
01836 
01837 /***********************************************************************************************
01838 
01839 >   BOOL OpGuideline::DoDeleteListOfGuidelines(NodeGuideline** pGuidelineList)
01840 
01841     Author:     Mark_Neves (Xara Group Ltd) <camelotdev@xara.com>
01842     Created:    12/9/95
01843     Inputs:     pGuidelineList = ptr to a list of existing guidelines
01844     Outputs:    -
01845     Returns:    TRUE if successful, FALSE otherwise
01846     Purpose:    Deletes the guidelines in the given list, undoably
01847                 The list should be terminated by a NULL value
01848     SeeAlso:    OpGuideline::DragFinished()
01849         
01850 ***********************************************************************************************/
01851 
01852 BOOL OpGuideline::DoDeleteListOfGuidelines(NodeGuideline** pGuidelineList)
01853 {
01854     ERROR2IF(pGuidelineList == NULL,FALSE,"pGuidelineList is NULL");
01855 
01856     BOOL ok= TRUE;
01857 
01858     while (*pGuidelineList != NULL && ok)
01859     {
01860         ok = DoDeleteGuideline(*pGuidelineList);
01861         pGuidelineList++;
01862     }
01863 
01864     return ok;
01865 }
01866 
01867 /***********************************************************************************************
01868 
01869 >   Layer* OpGuideline::DoCreateGuideLayer()
01870 
01871     Author:     Mark_Neves (Xara Group Ltd) <camelotdev@xara.com>
01872     Created:    4/10/95
01873     Inputs:     -
01874     Outputs:    -
01875     Returns:    Ptr to the guide layer, or NULL one couldn't be created.
01876     Purpose:    This returns a ptr to the guide layer.
01877 
01878                 If the guide layer already exists, a ptr to it is returned.
01879 
01880                 If there isn't a guide layer, it is created and inserted into the doc tree.
01881                 If this fails the func returns NULL
01882 
01883     SeeAlso:    OpGuideline::DoNewGuideline()
01884         
01885 ***********************************************************************************************/
01886 
01887 Layer* OpGuideline::DoCreateGuideLayer()
01888 {
01889     Layer* pLayer = pSpread->FindFirstGuideLayer();
01890     if (pLayer != NULL)
01891         return pLayer;
01892 
01893     Layer* pNewLayer = Layer::CreateGuideLayer();
01894     if (pNewLayer != NULL)
01895     {
01896         // If we insert the new layer as the FIRSTCHILD then this will be behind the page.
01897         // If we insert as the last child then we will be at the front of
01898         // the stacking order. We need to insert ourselves as the node after the last page node
01899         // This used to take this approach before 4/4/97.
01900 //      Page *pLastPage = pSpread->FindLastPageInSpread();
01901         Layer *pLastLayer = pSpread->FindLastLayer();
01902         // If there is the sepcial background layer present then ensure that we insert after that
01903 //      Layer * pLayer = pSpread->FindFirstPageBackgroundLayer();
01904 //      Node * pInsertionPoint = pLastPage;
01905         Node * pInsertionPoint = pLastLayer;
01906 //      if (pLayer)
01907 //          pInsertionPoint = pLayer;
01908 
01909         // Insert the new layer as the next node after the last page.
01910         if (pLastLayer && DoInsertNewNode(pNewLayer,pInsertionPoint,NEXT,FALSE,FALSE,FALSE,FALSE))
01911         {
01912             pNewLayer->EnsureUniqueLayerID();
01913             BROADCAST_TO_ALL(SpreadMsg(pSpread,SpreadMsg::LAYERCHANGES));
01914         }
01915         else
01916         {
01917             delete pNewLayer;
01918             pNewLayer = NULL;
01919         }
01920     }
01921 
01922     return pNewLayer;
01923 }
01924 
01925 
01926 
01927 /***********************************************************************************************
01928 
01929 >   static Layer* OpGuideline::CreateGuideLayer()
01930 
01931     Author:     Mark_Neves (Xara Group Ltd) <camelotdev@xara.com>
01932     Created:    4/10/95
01933     Inputs:     -
01934     Outputs:    -
01935     Returns:    Ptr to a guide layer that's ready to be inserted into the tree
01936     Purpose:    This does everything required in creating a layer fit to be called the guide layer
01937     SeeAlso:    -
01938         
01939 ***********************************************************************************************/
01940 
01941 // WEBSTER - markn 15/1/97
01942 // Moved this static function into the Layer class, where it should be
01943 /*
01944 Layer* OpGuideline::CreateGuideLayer()
01945 {
01946     Layer* pNewLayer = new Layer;
01947     if (pNewLayer != NULL)
01948     {
01949         String_256 LayerName(_R(IDS_GUIDESLAYERNAME));
01950 
01951         pNewLayer->SetVisible(TRUE); 
01952         pNewLayer->SetLocked(FALSE); 
01953         pNewLayer->SetPrintable(FALSE); 
01954         pNewLayer->SetBackground(TRUE); 
01955         pNewLayer->SetOutline(FALSE);
01956         pNewLayer->SetGuide(TRUE);
01957         pNewLayer->SetLayerID(LayerName); 
01958 
01959         Quality Qual;
01960         Qual.SetQuality(-1);
01961         QualityAttribute QualAttr(Qual);
01962         NodeAttribute* pNodeAttr = QualAttr.MakeNode();
01963         pNodeAttr->AttachNode(pNewLayer,FIRSTCHILD);
01964     }
01965 
01966     return pNewLayer;
01967 }
01968 */
01969 
01970 /***********************************************************************************************
01971 
01972 >   void OpGuideline::SetOrdinate(DocCoord& PointerPos)
01973 
01974     Author:     Mark_Neves (Xara Group Ltd) <camelotdev@xara.com>
01975     Created:    12/9/95
01976     Inputs:     PointerPos = pos of mouse pointer
01977     Outputs:    -
01978     Returns:    -
01979     Purpose:    Sets the Ordinate member var to either the X or the Y value of PointerPos
01980                 depending on the guideline type 
01981     SeeAlso:    -
01982         
01983 ***********************************************************************************************/
01984 
01985 void OpGuideline::SetOrdinate(DocCoord& PointerPos)
01986 {
01987     if (Type == GUIDELINE_HORZ)
01988         Ordinate = PointerPos.y;
01989     else
01990         Ordinate = PointerPos.x;
01991 }
01992 
01993 /***********************************************************************************************
01994 
01995 >   void OpGuideline::RenderMyDragBlobs()
01996 
01997     Author:     Mark_Neves (Xara Group Ltd) <camelotdev@xara.com>
01998     Created:    7/9/95
01999     Inputs:     -
02000     Outputs:    -
02001     Returns:    -
02002     Purpose:    Renders the blobs associated with the current drag
02003     SeeAlso:    RenderDragBlobs()
02004         
02005 ***********************************************************************************************/
02006 
02007 void OpGuideline::RenderMyDragBlobs()
02008 {
02009     DocRect Rect;
02010     RenderDragBlobs(Rect,pSpread, FALSE);
02011     RenderOn = !RenderOn;
02012 }
02013     
02014 /***********************************************************************************************
02015 
02016 >   void OpGuideline::RenderDragBlobs(DocRect Rect,Spread* pSpread, BOOL bSolidDrag)
02017 
02018     Author:     Mark_Neves (Xara Group Ltd) <camelotdev@xara.com>
02019     Created:    7/9/95
02020     Inputs:     Rect    = region of doc being updated (NOT USED!)
02021                 pSpread = ptr to the spread being redrawn
02022     Outputs:    -
02023     Returns:    -
02024     Purpose:    Main routine for rendering the blobs associated with the current drag.
02025                 This can be called from anywhere, e.g. when the view scrolls
02026     SeeAlso:    -
02027         
02028 ***********************************************************************************************/
02029 
02030 void OpGuideline::RenderDragBlobs(DocRect Rect,Spread* pSpread, BOOL bSolidDrag)
02031 {
02032     static DocRect RenderRect;
02033 
02034     RenderRegion* pRender = DocView::RenderOnTop( NULL, pSpread, UnclippedEOR );
02035 
02036     while (pRender != NULL)
02037     {
02038         // Set line colour for dashed line
02039         pRender->SetLineColour(COLOUR_BLACK);
02040 
02041         DocCoord StartPoint(Ordinate,Ordinate);
02042         DocCoord EndPoint(Ordinate,Ordinate);
02043 
02044         if (RenderOn)
02045         {
02046             View* pView = pRender->GetRenderView();
02047             if (pView != NULL)
02048             {
02049                 RenderRect = pView->GetDocViewRect(pSpread);
02050                 RenderRect = RenderRect.ToSpread(pSpread,pView);
02051             }
02052             RenderRect.Inflate(pRender->GetScaledPixelWidth());
02053         }
02054 
02055         if (Type == GUIDELINE_HORZ)
02056         {
02057             StartPoint.x = RenderRect.lo.x;
02058             EndPoint.x   = RenderRect.hi.x;
02059         }
02060         else
02061         {
02062             StartPoint.y = RenderRect.lo.y;
02063             EndPoint.y   = RenderRect.hi.y;
02064         }
02065 
02066         pRender->DrawDashLine(StartPoint,EndPoint);
02067 
02068         // Get the Next render region
02069         pRender = DocView::GetNextOnTop(NULL);
02070     }   
02071 }
02072         
02073         
02074 /***********************************************************************************************
02075 
02076 >   virtual BOOL OpGuideline::Undo()
02077 
02078     Author:     Mark_Neves (Xara Group Ltd) <camelotdev@xara.com>
02079     Created:    4/10/95
02080     Inputs:     -
02081     Outputs:    -
02082     Returns:    TRUE if successfull, FALSE otherwise
02083     Purpose:    Called when the op is undone.
02084                 This broadcasts a 'Guidelines changed' layer message
02085     SeeAlso:    -
02086         
02087 ***********************************************************************************************/
02088 
02089 BOOL OpGuideline::Undo()
02090 {
02091     if (UndoableOperation::Undo())
02092     {
02093         BroadcastGuidelineChanges(pBroadcastLayer);
02094         return TRUE;
02095     }
02096 
02097     return FALSE;
02098 }
02099 
02100 /***********************************************************************************************
02101 
02102 >   virtual BOOL OpGuideline::Redo()
02103 
02104     Author:     Mark_Neves (Xara Group Ltd) <camelotdev@xara.com>
02105     Created:    4/10/95
02106     Inputs:     -
02107     Outputs:    -
02108     Returns:    TRUE if successfull, FALSE otherwise
02109     Purpose:    Called when the op is redone.
02110                 This broadcasts a 'Guidelines changed' layer message
02111     SeeAlso:    -
02112         
02113 ***********************************************************************************************/
02114 
02115 BOOL OpGuideline::Redo()
02116 {
02117     if (UndoableOperation::Redo())
02118     {
02119         BroadcastGuidelineChanges(pBroadcastLayer);
02120         return TRUE;
02121     }
02122 
02123     return FALSE;
02124 }
02125 
02126 /***********************************************************************************************
02127 
02128 >   static BOOL OpGuideline::Init()
02129 
02130     Author:     Mark_Neves (Xara Group Ltd) <camelotdev@xara.com>
02131     Created:    7/9/95
02132     Inputs:     -
02133     Outputs:    -
02134     Returns:    TRUE if op successfully declared, FALSE otherwise
02135     Purpose:    Registers an op desc for this op
02136     SeeAlso:    -
02137         
02138 ***********************************************************************************************/
02139 
02140 BOOL OpGuideline::Init()
02141 {
02142     return (GuidelinePropDlg::Init()    && 
02143             OpNewGuideline::Init()      &&
02144             OpSpreadOrigin::Init()      && 
02145             OpResetSpreadOrigin::Init() &&
02146 #ifndef STANDALONE
02147             OpChangeLayerColour::Init() &&
02148 #endif
02149             RegisterOpDescriptor(
02150                                 0, 
02151                                 0,
02152                                 CC_RUNTIME_CLASS(OpGuideline), 
02153                                 OPTOKEN_GUIDELINE ,
02154                                 OpGuideline::GetState,
02155                                 0,  /* help ID */
02156                                 0,  /* bubble ID */
02157                                 0   /* bitmap ID */
02158                                 ) &&
02159 
02160             RegisterOpDescriptor(
02161                                 0, 
02162                                 _R(IDS_DELETEALLGUIDELINES),
02163                                 CC_RUNTIME_CLASS(OpDeleteAllGuidelines), 
02164                                 OPTOKEN_DELETEALLGUIDELINES ,
02165                                 OpDeleteAllGuidelines::GetState,
02166                                 0,  /* help ID */
02167                                 0,  /* bubble ID */
02168                                 0   /* bitmap ID */
02169                                 ) &&
02170 
02171             RegisterOpDescriptor(
02172                                 0, 
02173                                 _R(IDS_DELETEGUIDELINE),
02174                                 CC_RUNTIME_CLASS(OpDeleteGuideline), 
02175                                 OPTOKEN_DELETEGUIDELINE ,
02176                                 OpDeleteGuideline::GetState,
02177                                 0,  /* help ID */
02178                                 0,  /* bubble ID */
02179                                 0   /* bitmap ID */
02180                                 )                               
02181             );
02182 }
02183 
02184 /***********************************************************************************************
02185 
02186 >   static OpState OpGuideline::GetState(String_256* Description, OpDescriptor*)
02187 
02188     Author:     Mark_Neves (Xara Group Ltd) <camelotdev@xara.com>
02189     Created:    7/9/95
02190     Inputs:     Description = ptr to place description of why this op can't happen
02191                 pOpDesc     = ptr to the Op Desc associated with this op
02192     Outputs:    -
02193     Returns:    An OpState object
02194     Purpose:    Func for determining the usability of this op
02195     SeeAlso:    -
02196         
02197 ***********************************************************************************************/
02198 
02199 OpState OpGuideline::GetState(String_256* Description, OpDescriptor*)
02200 {
02201     OpState State;
02202     return State;
02203 }
02204 
02205 /***********************************************************************************************
02206 
02207 >   static void OpGuideline::GetOpName(String_256* OpName)
02208 
02209     Author:     Mark_Neves (Xara Group Ltd) <camelotdev@xara.com>
02210     Created:    7/9/95
02211     Inputs:     OpName = ptr to string
02212     Outputs:    OpName contains a description of the op
02213     Returns:    -
02214     Purpose:    Returns a desc of the op.  Mainly used to fill in the menu item for the undo/redo ops. 
02215     SeeAlso:    -
02216         
02217 ***********************************************************************************************/
02218 
02219 void OpGuideline::GetOpName(String_256* OpName)
02220 {
02221     *OpName = String_256(UndoIDS);
02222 }
02223 
02224 
02225 //--------------------------------------------------------------------
02226 //--------------------------------------------------------------------
02227 
02228 /***********************************************************************************************
02229 
02230 >   OpDeleteGuideline::OpDeleteGuideline()
02231 
02232     Author:     Mark_Neves (Xara Group Ltd) <camelotdev@xara.com>
02233     Created:    5/10/95
02234     Inputs:     -
02235     Outputs:    -
02236     Returns:    -
02237     Purpose:    Default constructor
02238     SeeAlso:    UndoableOperation
02239         
02240 ***********************************************************************************************/
02241 
02242 OpDeleteGuideline::OpDeleteGuideline()
02243 {
02244     UndoIDS = _R(IDS_OPDELETEGUIDELINE);
02245 }
02246 
02247 /***********************************************************************************************
02248 
02249 >   OpDeleteGuideline::~OpDeleteGuideline()
02250 
02251     Author:     Mark_Neves (Xara Group Ltd) <camelotdev@xara.com>
02252     Created:    5/10/95
02253     Inputs:     -
02254     Outputs:    -
02255     Returns:    -
02256     Purpose:    Default destructor
02257     SeeAlso:    UndoableOperation
02258         
02259 ***********************************************************************************************/
02260 
02261 OpDeleteGuideline::~OpDeleteGuideline()
02262 {
02263 }
02264 
02265 /********************************************************************************************
02266 
02267 >   void OpDeleteGuideline::Do(OpDescriptor*)
02268 
02269     Author:     Mark_Neves (Xara Group Ltd) <camelotdev@xara.com>
02270     Created:    5/10/95
02271     Inputs:     -
02272     Outputs:    -
02273     Returns:    -
02274     Purpose:    Creates then opens the dialog 
02275     Errors:     -
02276     SeeAlso:    -
02277 
02278 ********************************************************************************************/
02279 
02280 void OpDeleteGuideline::Do(OpDescriptor*)
02281 {
02282     BOOL ok = FALSE;
02283 
02284     Spread* pSpread = Document::GetSelectedSpread();
02285 
02286     if (pGuideline != NULL)
02287         ok = DoDeleteGuideline(pGuideline);
02288 
02289     if (!ok)
02290         FailAndExecute();
02291     else
02292         BroadcastGuidelineChanges(pSpread->FindFirstGuideLayer());
02293 
02294     pGuideline = NULL;
02295 
02296     End();
02297 }
02298 
02299 /***********************************************************************************************
02300 
02301 >   static OpState OpDeleteGuideline::GetState(String_256* Description, OpDescriptor*)
02302 
02303     Author:     Mark_Neves (Xara Group Ltd) <camelotdev@xara.com>
02304     Created:    5/10/95
02305     Inputs:     Description = ptr to place description of why this op can't happen
02306                 pOpDesc     = ptr to the Op Desc associated with this op
02307     Outputs:    -
02308     Returns:    An OpState object
02309     Purpose:    Func for determining the usability of this op
02310     SeeAlso:    -
02311         
02312 ***********************************************************************************************/
02313 
02314 OpState OpDeleteGuideline::GetState(String_256* Description, OpDescriptor*)
02315 {
02316     OpState State;
02317 
02318     State.Greyed = (pGuideline == NULL);
02319 
02320     return State;
02321 }
02322 
02324 // OpNewGuideline
02325 
02326 /******************************************************************************
02327 >   OpNewGuideline::OpNewGuideline()
02328 
02329     Author:     Ed_Cornes (Xara Group Ltd) <camelotdev@xara.com>
02330     Created:    9/10/95
02331     Purpose:    Default constructor
02332 ******************************************************************************/
02333 
02334 OpNewGuideline::OpNewGuideline()
02335 {
02336     UndoIDS = _R(IDS_OPNEWGUIDELINE2UNDO);
02337 }
02338 
02339 
02340 /******************************************************************************
02341 >   OpNewGuideline::~OpNewGuideline()
02342 
02343     Author:     Ed_Cornes (Xara Group Ltd) <camelotdev@xara.com>
02344     Created:    9/10/95
02345     Purpose:    Default destructor
02346 ******************************************************************************/
02347 
02348 OpNewGuideline::~OpNewGuideline()
02349 {
02350 }
02351 
02352 
02353 /******************************************************************************
02354 >   BOOL OpResetSpreadOrigin::Init()
02355 
02356     Author:     Ed_Cornes (Xara Group Ltd) <camelotdev@xara.com>
02357     Created:    10/10/95
02358     Returns:    FALSE if fails
02359     Purpose:    Initilise OpNewGuideline
02360 ******************************************************************************/
02361 
02362 BOOL OpNewGuideline::Init()
02363 {
02364     return  RegisterOpDescriptor(
02365                                 0, 
02366                                 _R(IDS_OPNEWGUIDELINE2),
02367                                 CC_RUNTIME_CLASS(OpNewGuideline), 
02368                                 OPTOKEN_NEWGUIDELINE2 ,
02369                                 OpNewGuideline::GetState,
02370                                 0,  /* help ID */
02371                                 0,  /* bubble ID */
02372                                 0   /* bitmap ID */
02373                                 );
02374 }
02375 
02376 
02377 /*****************************************************************************
02378 >   void OpNewGuideline::Do(OpDescriptor* pOpDesc)
02379 
02380     Author:     Ed_Cornes (Xara Group Ltd) <camelotdev@xara.com>
02381     Created:    9/10/95
02382     Inputs:     pOpDesc - 
02383     Purpose:    sets up param block and invokes OpGuideline::DoWithParams() 
02384 ******************************************************************************/
02385 
02386 void OpNewGuideline::Do(OpDescriptor* pOpDesc)
02387 {
02388     Spread* pSpread = Document::GetSelectedSpread();
02389     if (pOpDesc!=NULL && pSpread!=NULL && NewGuidelineParam.Method==GUIDELINEOPMETHOD_NEW_IMMEDIATE)
02390     {
02391 //      GuidelineType Type     = NewGuidelineParam.Type;
02392         DocCoord      GuidePos = DocCoord(NewGuidelineParam.NewOrdinate, NewGuidelineParam.NewOrdinate);
02393         DoWithParam(pOpDesc,&NewGuidelineParam);
02394 
02395         NewGuidelineParam.Method = GUIDELINEOPMETHOD_INVALID;   // reset static param block
02396     }
02397     else
02398     {
02399         ERROR3("OpNewGuideline::Do() - invalid Method or pOpDesc==NULL or no selected spread");
02400         FailAndExecute();
02401         End();
02402     }
02403 }
02404 
02405 
02406 /******************************************************************************
02407 >   static void OpNewGuideline::SetNewGuidelineParam(GuidelineType Type, MILLIPOINT pos)
02408 
02409     Author:     Ed_Cornes (Xara Group Ltd) <camelotdev@xara.com>
02410     Created:    9/10/95
02411     Inputs:     Type - type of guide (hoiz/vert)
02412                 Pos  - positin of guide
02413 ******************************************************************************/
02414 
02415 void OpNewGuideline::SetNewGuidelineParam(GuidelineType Type, MILLIPOINT pos)
02416 {
02417     NewGuidelineParam.Method      = GUIDELINEOPMETHOD_NEW_IMMEDIATE;
02418     NewGuidelineParam.Type        = Type;
02419     NewGuidelineParam.NewOrdinate = pos;
02420 }
02421 
02422 
02423 /******************************************************************************
02424 >   static OpState OpNewGuideline::GetState(String_256* pReasonGreyed, OpDescriptor* pOpDesc)
02425 
02426     Author:     Ed_Cornes (Xara Group Ltd) <camelotdev@xara.com>
02427     Created:    9/10/95
02428     Inputs:     pOpDesc       - 
02429     Outputs:    pReasonGreyed - 
02430     Returns:    An OpState object
02431 ******************************************************************************/
02432 
02433 OpState OpNewGuideline::GetState(String_256* pReasonGreyed, OpDescriptor* pOpDesc)
02434 {
02435     return OpState();
02436 }
02437 
02438 
02439 //--------------------------------------------------------------------
02440 //--------------------------------------------------------------------
02441 
02442 /***********************************************************************************************
02443 
02444 >   OpDeleteAllGuidelines::OpDeleteAllGuidelines()
02445 
02446     Author:     Mark_Neves (Xara Group Ltd) <camelotdev@xara.com>
02447     Created:    5/10/95
02448     Inputs:     -
02449     Outputs:    -
02450     Returns:    -
02451     Purpose:    Default constructor
02452     SeeAlso:    UndoableOperation
02453         
02454 ***********************************************************************************************/
02455 
02456 OpDeleteAllGuidelines::OpDeleteAllGuidelines()
02457 {
02458     UndoIDS = _R(IDS_OPDELETEALLGUIDELINES);
02459 }
02460 
02461 /***********************************************************************************************
02462 
02463 >   OpDeleteAllGuidelines::~OpDeleteAllGuidelines()
02464 
02465     Author:     Mark_Neves (Xara Group Ltd) <camelotdev@xara.com>
02466     Created:    5/10/95
02467     Inputs:     -
02468     Outputs:    -
02469     Returns:    -
02470     Purpose:    Default destructor
02471     SeeAlso:    UndoableOperation
02472         
02473 ***********************************************************************************************/
02474 
02475 OpDeleteAllGuidelines::~OpDeleteAllGuidelines()
02476 {
02477 }
02478 
02479 /********************************************************************************************
02480 
02481 >   void OpDeleteAllGuidelines::Do(OpDescriptor*)
02482 
02483     Author:     Mark_Neves (Xara Group Ltd) <camelotdev@xara.com>
02484     Created:    5/10/95
02485     Inputs:     -
02486     Outputs:    -
02487     Returns:    -
02488     Purpose:    Creates then opens the dialog 
02489     Errors:     -
02490     SeeAlso:    -
02491 
02492 ********************************************************************************************/
02493 
02494 void OpDeleteAllGuidelines::Do(OpDescriptor*)
02495 {
02496     BOOL ok = FALSE;
02497 
02498     Spread* pSpread = Document::GetSelectedSpread();
02499     if (pSpread != NULL)
02500     {
02501         Layer* pLayer = pSpread->FindFirstGuideLayer();
02502         if (pLayer != NULL)
02503         {
02504             ok = TRUE;
02505             Node* pNode = pLayer->FindFirstChild(CC_RUNTIME_CLASS(NodeGuideline));
02506             while (pNode != NULL)
02507             {
02508                 Node* pNextNode = pNode->FindNext(CC_RUNTIME_CLASS(NodeGuideline));
02509                 ok = ok && DoDeleteGuideline((NodeGuideline*)pNode);
02510                 pNode = pNextNode;
02511             }
02512         }
02513     }
02514 
02515     if (!ok)
02516         FailAndExecute();
02517     else
02518         BroadcastGuidelineChanges(pSpread->FindFirstGuideLayer());
02519 
02520     End();
02521 }
02522 
02523 /***********************************************************************************************
02524 
02525 >   static OpState OpDeleteAllGuidelines::GetState(String_256* Description, OpDescriptor*)
02526 
02527     Author:     Mark_Neves (Xara Group Ltd) <camelotdev@xara.com>
02528     Created:    5/10/95
02529     Inputs:     Description = ptr to place description of why this op can't happen
02530                 pOpDesc     = ptr to the Op Desc associated with this op
02531     Outputs:    -
02532     Returns:    An OpState object
02533     Purpose:    Func for determining the usability of this op
02534     SeeAlso:    -
02535         
02536 ***********************************************************************************************/
02537 
02538 OpState OpDeleteAllGuidelines::GetState(String_256* Description, OpDescriptor*)
02539 {
02540     OpState State(FALSE,TRUE);      // Greyed out by default
02541 
02542     Spread* pSpread = Document::GetSelectedSpread();
02543     if (pSpread != NULL)
02544     {
02545         Layer* pLayer = pSpread->FindFirstGuideLayer();
02546         if (pLayer != NULL)
02547         {
02548             Node* pNode = pLayer->FindFirstChild(CC_RUNTIME_CLASS(NodeGuideline));
02549             State.Greyed = (pNode == NULL);     // Ungrey if there are one or more guidelines
02550         }
02551     }
02552 
02553     if (State.Greyed)
02554         Description->Load(_R(IDS_OPDELETEALLGUIDESGREY));
02555 
02556     return State;
02557 }
02558 
02560 // GuidelinePropDlg - or should that be OpGuidelinePropDlg!
02561 
02562 /********************************************************************************************
02563 >   GuidelinePropDlg::GuidelinePropDlg(): DialogOp(GuidelinePropDlg::IDD, GuidelinePropDlg::Mode) 
02564 
02565     Author:     Mark_Neves (Xara Group Ltd) <camelotdev@xara.com>
02566     Created:    29/9/95
02567     Purpose:    GuidelinePropDlg constructor. Creates a non-undoable operation
02568 ********************************************************************************************/
02569 
02570 GuidelinePropDlg::GuidelinePropDlg(): DialogOp(GuidelinePropDlg::IDD, GuidelinePropDlg::Mode) 
02571 {   
02572 }        
02573 
02574 
02575 /********************************************************************************************
02576 >   MsgResult GuidelinePropDlg::Message(Msg* pMsg)
02577 
02578     Author:     Mark_Neves (Xara Group Ltd) <camelotdev@xara.com>
02579     Created:    29/9/95
02580     Inputs:     pMsg -
02581     Returns:    a message result
02582     Purpose:    Handles all the scale dialog's messages 
02583 ********************************************************************************************/
02584 
02585 MsgResult GuidelinePropDlg::Message(Msg* pMsg)
02586 {
02587     if (IS_OUR_DIALOG_MSG(pMsg))
02588     {
02589         DialogMsg* Msg = (DialogMsg*)pMsg;
02590         BOOL EndDialog = FALSE;
02591 
02592         switch (Msg->DlgMsg)
02593         {
02594             case DIM_CREATE:
02595                 ShowDetails();
02596                 SetKeyboardFocus (_R(IDC_GUIDELINEPROP_POSITION)) ;
02597                 HighlightText    (_R(IDC_GUIDELINEPROP_POSITION)) ;
02598                 break;
02599                 
02600             case DIM_COMMIT:
02601                 EndDialog = CommitValues();
02602                 if (!EndDialog)
02603                     Msg->DlgMsg = DIM_NONE;  // stop default handler from closing dialog
02604                 break;
02605 
02606             case DIM_SOFT_COMMIT:
02607                 break; 
02608 
02609             case DIM_CANCEL:
02610                 EndDialog = TRUE;
02611                 break;
02612 
02613             case DIM_LFT_BN_CLICKED:
02614                 break; 
02615 
02616             case DIM_TEXT_CHANGED:
02617                 break;
02618 
02619             default:
02620                 break;
02621         }
02622 
02623         if (EndDialog)  // Dialog communication over 
02624         {              // Isn't this pretty?
02625             Close();  // Close the dialog 
02626             End();   // Destroy dialog 
02627             return OK;
02628         }
02629     }
02630 
02631     // Pass everything on to the base class . . .
02632     return DialogOp::Message(pMsg);
02633 }  
02634 
02635 
02636 /********************************************************************************************
02637 >   OpState GuidelinePropDlg::GetState(String_256* pReasonGreyed, OpDescriptor* pOpDesc)
02638 
02639     Author:     Mark_Neves (Xara Group Ltd) <camelotdev@xara.com>
02640     Created:    29/9/95
02641     Inputs:     pOpDesc       -
02642     Outputs:    pReasonGreyed - 
02643     Returns:    op state
02644     Purpose:    GuidelinePropDlg GetState method
02645 ********************************************************************************************/
02646 
02647 OpState GuidelinePropDlg::GetState(String_256* pReasonGreyed, OpDescriptor* pOpDesc)
02648 {    
02649     OpState OpSt;
02650     return OpSt;
02651 }
02652 
02653          
02654 /********************************************************************************************
02655 >   BOOL GuidelinePropDlg::Init()
02656 
02657     Author:     Mark_Neves (Xara Group Ltd) <camelotdev@xara.com>
02658     Created:    29/9/95
02659     Returns:    FALSE if fails
02660     Purpose:    GuidelinePropDlg Init method
02661 ********************************************************************************************/
02662 
02663 BOOL GuidelinePropDlg::Init()
02664 {  
02665     return RegisterOpDescriptor(0,
02666                                 _R(IDS_OPEDITGUIDELINEPROPDLG),
02667                                 CC_RUNTIME_CLASS(GuidelinePropDlg),
02668                                 OPTOKEN_EDITGUIDELINEPROPDLG,
02669                                 GuidelinePropDlg::GetState,
02670                                 0,  // help ID
02671                                 0,  // bubble ID
02672                                 0   // bitmap ID
02673                                 )
02674         && RegisterOpDescriptor(0,
02675                                 _R(IDS_OPNEWGUIDELINEPROPDLG),
02676                                 CC_RUNTIME_CLASS(GuidelinePropDlg),
02677                                 OPTOKEN_NEWGUIDELINEPROPDLG,
02678                                 GuidelinePropDlg::GetState,
02679                                 0,  // help ID
02680                                 0,  // bubble ID
02681                                 0   // bitmap ID
02682                                 );
02683 }   
02684 
02685  
02686 /********************************************************************************************
02687 >   void GuidelinePropDlg::Do(OpDescriptor* pOpDesc)
02688 
02689     Author:     Mark_Neves (Xara Group Ltd) <camelotdev@xara.com>
02690     Created:    29/9/95
02691     Inputs:     pOpDesc - 
02692     Purpose:    Creates then opens the dialog 
02693 ********************************************************************************************/
02694 
02695 void GuidelinePropDlg::Do(OpDescriptor* pOpDesc)
02696 {
02697     if (Create()==FALSE)
02698     {
02699         InformError(0,_R(IDS_OK));
02700         End();
02701     }
02702 }
02703 
02704 
02705 /********************************************************************************************
02706 >   void GuidelinePropDlg::ShowDetails()
02707 
02708     Author:     Mark_Neves (Xara Group Ltd) <camelotdev@xara.com>
02709     Created:    29/9/95
02710     Purpose:    Shows guideline details in the dialog
02711 ********************************************************************************************/
02712 
02713 void GuidelinePropDlg::ShowDetails()
02714 {
02715     MILLIPOINT    Ordinate;
02716     GuidelineType Type;
02717     Spread*       pSpread;
02718     String_256    TitleStr("");
02719     if (Params.pGuideline!=NULL)
02720     {
02721         pSpread  = Params.pGuideline->FindParentSpread();
02722         Ordinate = Params.pGuideline->GetOrdinate();
02723         Type     = Params.pGuideline->GetType();
02724         TitleStr = String_256(_R(IDS_OPEDITGUIDELINEPROPDLGTITLE));
02725     }
02726     else
02727     {
02728         pSpread  = Document::GetSelectedSpread();
02729         Ordinate = Params.Ordinate;
02730         Type     = Params.Type;
02731         TitleStr = String_256(_R(IDS_OPNEWGUIDELINEPROPDLGTITLE));
02732     }
02733 
02734     SetTitlebarName(&TitleStr);
02735 
02736     Ordinate = NodeGuideline::ToUserOrdinate(pSpread,Ordinate,Type);
02737     SetDimensionGadgetValue(_R(IDC_GUIDELINEPROP_POSITION),Ordinate,pSpread);
02738 
02739     UINT32 IDS = (Type==GUIDELINE_HORZ) ? _R(IDS_HORIZONTAL) : _R(IDS_VERTICAL);
02740     String_256 Str(IDS);
02741     SetStringGadgetValue(_R(IDC_GUIDELINEPROP_TYPE),IDS);
02742 }
02743 
02744 
02745 /********************************************************************************************
02746 >   BOOL GuidelinePropDlg::CommitValues()
02747 
02748     Author:     Mark_Neves (Xara Group Ltd) <camelotdev@xara.com>
02749     Created:    29/9/95
02750     Returns:    TRUE if values excepted, FALSE otherwise
02751     Purpose:    Called when the OK button is selected
02752 ********************************************************************************************/
02753 
02754 BOOL GuidelinePropDlg::CommitValues()
02755 {
02756     OpGuidelineParam GuidelineParam;
02757 
02758     BOOL ok;
02759     MILLIPOINT Ordinate = GetDimensionGadgetValue(_R(IDC_GUIDELINEPROP_POSITION),Document::GetSelectedSpread(),&ok);
02760 
02761     if (!ok)
02762         return FALSE;
02763 
02764     if (Params.pGuideline != NULL)
02765     {
02766         GuidelineParam.Method      = GUIDELINEOPMETHOD_MOVE_IMMEDIATE;
02767         GuidelineParam.pGuideline  = Params.pGuideline;
02768         GuidelineParam.NewOrdinate = NodeGuideline::ToSpreadOrdinate(Params.pGuideline->FindParentSpread(),Ordinate,Params.pGuideline->GetType());
02769     }
02770     else
02771     {
02772         GuidelineParam.Method      = GUIDELINEOPMETHOD_NEW_IMMEDIATE;
02773         GuidelineParam.Type        = Params.Type;
02774         GuidelineParam.NewOrdinate = NodeGuideline::ToSpreadOrdinate(Document::GetSelectedSpread(),Ordinate,Params.Type);
02775     }
02776 
02777     OpDescriptor* pOpDesc = OpDescriptor::FindOpDescriptor(OPTOKEN_GUIDELINE);
02778     ERROR3IF(pOpDesc == NULL,"FindOpDescriptor(OPTOKEN_GUIDELINE) failed");
02779 
02780     if (pOpDesc != NULL)
02781         pOpDesc->Invoke(&GuidelineParam);
02782 
02783     return TRUE;
02784 }
02785 
02786 
02787 /******************************************************************************
02788 >   static void GuidelinePropDlg::SetNewGuidelineParams(GuidelineType type, MILLIPOINT pos)
02789 
02790     Author:     Ed_Cornes (Xara Group Ltd) <camelotdev@xara.com>
02791     Created:    9/10/95
02792     Inputs:     Type - type of guide (hoiz/vert)
02793                 pos  - position of guide
02794     Purpose:    Set up param block for guideline property dialog
02795 ******************************************************************************/
02796 
02797 void GuidelinePropDlg::SetNewGuidelineParams(GuidelineType type, MILLIPOINT pos)
02798 {
02799     Params.pGuideline = NULL;
02800     Params.Type       = type;
02801     Params.Ordinate   = pos;
02802 }
02803 
02804 
02805 /******************************************************************************
02806 >   static void GuidelinePropDlg::SetEditGuidelineParams(NodeGuideline* pGuide)
02807 
02808     Author:     Ed_Cornes (Xara Group Ltd) <camelotdev@xara.com>
02809     Created:    9/10/95
02810     Inputs:     pGuide - guide to edit
02811     Purpose:    Set up param block for guideline property dialog
02812 ******************************************************************************/
02813 
02814 void GuidelinePropDlg::SetEditGuidelineParams(NodeGuideline* pGuide)
02815 {
02816     ERROR3IF(pGuide==NULL,"GuidelinePropDlg::SetEditGuidelineParam() - pGuide==NULL");
02817     Params.pGuideline = pGuide;
02818     Params.Type       = GUIDELINE_NOTYPE;
02819     Params.Ordinate   = 0;
02820 }
02821 
02822 
02824 // OpSpreadOrigin
02825 
02826 /********************************************************************************************
02827 
02828 >   OpSpreadOrigin::OpSpreadOrigin()
02829 
02830     Author:     Mark_Neves (Xara Group Ltd) <camelotdev@xara.com>
02831     Created:    6/10/95
02832     Inputs:     - 
02833     Outputs:    -
02834     Returns:    -
02835     Purpose:    Default constructor
02836     Errors:     -
02837     SeeAlso:    -
02838 
02839 ********************************************************************************************/
02840 
02841 OpSpreadOrigin::OpSpreadOrigin()
02842 {
02843     RenderOn = TRUE;
02844 }
02845 
02846 /********************************************************************************************
02847 
02848 >   OpSpreadOrigin::~OpSpreadOrigin()
02849 
02850     Author:     Mark_Neves (Xara Group Ltd) <camelotdev@xara.com>
02851     Created:    6/10/95
02852     Inputs:     - 
02853     Outputs:    -
02854     Returns:    -
02855     Purpose:    Default destructor
02856     Errors:     -
02857     SeeAlso:    -
02858 
02859 ********************************************************************************************/
02860 
02861 OpSpreadOrigin::~OpSpreadOrigin()
02862 {
02863 }
02864 
02865 /***********************************************************************************************
02866 
02867 >   void OpSpreadOrigin::Do(OpDescriptor* pOpDesc)
02868 
02869     Author:     Mark_Neves (Xara Group Ltd) <camelotdev@xara.com>
02870     Created:    6/10/95
02871     Inputs:     pOpDesc = ptr op desc
02872     Outputs:    -
02873     Returns:    -
02874     Purpose:    This func starts a drag that will end up setting the spread origin
02875     SeeAlso:    DoAddNewGuideline(), OilRuler::OnLButtonDown()
02876         
02877 ***********************************************************************************************/
02878 
02879 void OpSpreadOrigin::Do(OpDescriptor* pOpDesc)
02880 {
02881     DocCoord StartPos(-5000,-5000);
02882 
02883     DoDrag(NULL,StartPos);
02884 }
02885 
02886 /***********************************************************************************************
02887 
02888 >   void OpSpreadOrigin::DoDrag(Spread* pThisSpread,DocCoord PointerPos)
02889 
02890     Author:     Mark_Neves (Xara Group Ltd) <camelotdev@xara.com>
02891     Created:    6/10/95
02892     Inputs:     pThisSpread       = ptr to spread drag started in (NULL means get selected spread)
02893                 PointerPos        = coord of point clicked
02894     Outputs:    -
02895     Returns:    -
02896     Purpose:    Starts a drag for the origin
02897     SeeAlso:    -
02898         
02899 ***********************************************************************************************/
02900 
02901 void OpSpreadOrigin::DoDrag(Spread* pThisSpread,DocCoord PointerPos)
02902 {
02903     pSpread = pThisSpread;
02904 
02905     if (pSpread == NULL)
02906         pSpread = Document::GetSelectedSpread();
02907 
02908     ERROR3IF(pSpread == NULL,"pSpread == NULL");
02909     if (pSpread == NULL)
02910     {
02911         End();
02912         return;
02913     }
02914 
02915     CurrentOrigin = PointerPos;
02916 
02917     RenderMyDragBlobs();
02918 
02919     // put up some status line help
02920     StatusLine* pStatusLine=GetApplication()->GetpStatusLine();
02921     if (pStatusLine!=NULL)
02922     {
02923         String_256 temp(_R(IDS_OPSPREADORIGINDRAG));
02924         pStatusLine->UpdateText(&temp,STATUSLINE_SELDESC_STATBAR);
02925     }
02926     
02927     // Tell the Dragging system that we need drags to happen
02928     StartDrag( DRAGTYPE_DEFERSCROLL );
02929 }
02930 
02931 /***********************************************************************************************
02932 
02933 >   virtual void OpSpreadOrigin::DragPointerMove( DocCoord PointerPos, ClickModifiers ClickMods, Spread*, BOOL bSolidDrag)
02934 
02935     Author:     Mark_Neves (Xara Group Ltd) <camelotdev@xara.com>
02936     Created:    6/10/95
02937     Inputs:     PointerPos = coord of the pointer
02938                 ClickMods  = info on the click modifiers
02939                 pSpread    = ptr to spread 
02940     Outputs:    -
02941     Returns:    -
02942     Purpose:    Responds to a mouse move during a drag of the origin
02943     SeeAlso:    UndoableOperation
02944         
02945 ***********************************************************************************************/
02946 
02947 void OpSpreadOrigin::DragPointerMove( DocCoord PointerPos, ClickModifiers ClickMods, Spread*, BOOL bSolidDrag)
02948 {
02949     // First Rub out the old box
02950     RenderMyDragBlobs();
02951 
02952     DocView::SnapCurrent(pSpread,&PointerPos);
02953 
02954     CurrentOrigin = PointerPos;
02955 
02956     // Render the new drag box
02957     RenderMyDragBlobs();
02958 }
02959 
02960 
02961 /***********************************************************************************************
02962 
02963 >   virtual void OpSpreadOrigin::DragFinished(DocCoord PointerPos, ClickModifiers ClickMods, Spread*, BOOL Success, BOOL bSolidDrag)
02964 
02965     Author:     Mark_Neves (Xara Group Ltd) <camelotdev@xara.com>
02966     Created:    6/10/95
02967     Inputs:     PointerPos = coord of the pointer
02968                 ClickMods  = info on the click modifiers
02969                 pSpread    = ptr to spread (not used)
02970                 Success    = TRUE if drag ended successfully, FALSE if drag terminated (usu. by pressing Escape)
02971     Outputs:    -
02972     Returns:    -
02973     Purpose:    Responds to the drag of a guideline ending
02974     SeeAlso:    UndoableOperation
02975         
02976 ***********************************************************************************************/
02977 
02978 void OpSpreadOrigin::DragFinished(DocCoord PointerPos, ClickModifiers ClickMods, Spread*, BOOL Success, BOOL bSolidDrag)
02979 {
02980     // First Rub out the old boxes
02981     RenderMyDragBlobs();
02982 
02983     Success = (Success && !OpGuideline::IsMouseOverRuler());
02984 
02985     if (Success)
02986     {
02987         DocView::SnapCurrent(pSpread,&PointerPos);
02988         CurrentOrigin = PointerPos;
02989 
02990         Success = DoChangeOrigin(pSpread,CurrentOrigin);
02991     }
02992 
02993     if (!Success)
02994         FailAndExecute();
02995 
02996     // End the op & Drag
02997     End();
02998     EndDrag();
02999 }
03000 
03001 /***********************************************************************************************
03002 >   BOOL OpSpreadOrigin::DoChangeOrigin(Spread* pSpread, DocCoord NewOrigin)
03003 
03004     Author:     Ed_Cornes (Xara Group Ltd) <camelotdev@xara.com>
03005     Created:    8/10/95
03006     Inputs:     pSpread    = ptr to spread
03007                 NewOrigin  = new origin for the spread
03008     Returns:    FALSE if fails
03009     Purpose:    Undoably set a new grid/user origin
03010 ***********************************************************************************************/
03011 
03012 BOOL OpSpreadOrigin::DoChangeOrigin(Spread* pSpread, DocCoord NewOrigin)
03013 {
03014     ERROR2IF(pSpread==NULL,FALSE,"OpSpreadOrigin::DoChangeOrigin() - pSpread==NULL");
03015 
03016     NodeGrid* pDefaultGrid = pSpread->FindFirstDefaultGridInSpread();
03017     ERROR2IF(pDefaultGrid==NULL,FALSE,"OpSpreadOrigin::DoChangeOrigin() - FindFirstDefaultGrid() failed");
03018 
03019     // if no change in origin, just return without inserting an op
03020     MILLIPOINT x,y;
03021     pDefaultGrid->GetOrigin(&x,&y);     // call me stupid but couldn't this return a DocCoord!
03022     if (DocCoord(x,y)==NewOrigin)
03023         return TRUE;
03024 
03025     // cunningly (NOT) OpGridResize expects the origin to be page relative!
03026     DocCoord NewPageRelativeOrigin;
03027     pSpread->SpreadCoordToPagesCoord(&NewPageRelativeOrigin,NewOrigin);
03028 
03029     // Force the origin to snap to a pixel boundary.
03030     NewPageRelativeOrigin.x = ((NewPageRelativeOrigin.x + 375) / 750) * 750;
03031     NewPageRelativeOrigin.y = ((NewPageRelativeOrigin.y + 375) / 750) * 750;
03032 
03033     // set up a complete set of grid params with new origin
03034     // (would be nice to have them all default to 'no change' and only specify the new ones but that would be far to obvious!)
03035     GridResizeInfo GridParams;
03036     GridParams.pSpread          = pSpread;
03037     GridParams.OriginX          = NewPageRelativeOrigin.x;
03038     GridParams.OriginY          = NewPageRelativeOrigin.y;
03039     GridParams.GridDivisions    = pDefaultGrid->GetDivisions();
03040     GridParams.GridSubDivisions = pDefaultGrid->GetSubdivisions();
03041     GridParams.GridUnits        = pDefaultGrid->GetUnits();
03042     GridParams.TypeOfGrid       = pDefaultGrid->GetGridType();
03043 //  GridParams.GridSpacing  // this seems to be 'MainStep' which is also determined from Divisions and Units
03044 
03045     return DoResizeGrid(&GridParams);
03046 }
03047 
03048 
03049 /***********************************************************************************************
03050 
03051 >   void OpSpreadOrigin::RenderMyDragBlobs()
03052 
03053     Author:     Mark_Neves (Xara Group Ltd) <camelotdev@xara.com>
03054     Created:    6/10/95
03055     Inputs:     -
03056     Outputs:    -
03057     Returns:    -
03058     Purpose:    Renders the blobs associated with the current drag
03059     SeeAlso:    RenderDragBlobs()
03060         
03061 ***********************************************************************************************/
03062 
03063 void OpSpreadOrigin::RenderMyDragBlobs()
03064 {
03065     DocRect Rect;
03066     RenderDragBlobs(Rect,pSpread, FALSE);
03067     RenderOn = !RenderOn;
03068 }
03069     
03070 /***********************************************************************************************
03071 
03072 >   void OpSpreadOrigin::RenderDragBlobs(DocRect Rect,Spread* pSpread, BOOL bSolidDrag)
03073 
03074     Author:     Mark_Neves (Xara Group Ltd) <camelotdev@xara.com>
03075     Created:    6/10/95
03076     Inputs:     Rect    = region of doc being updated (NOT USED!)
03077                 pSpread = ptr to the spread being redrawn
03078     Outputs:    -
03079     Returns:    -
03080     Purpose:    Main routine for rendering the blobs associated with the current drag.
03081                 This can be called from anywhere, e.g. when the view scrolls
03082     SeeAlso:    -
03083         
03084 ***********************************************************************************************/
03085 
03086 void OpSpreadOrigin::RenderDragBlobs(DocRect Rect,Spread* pSpread, BOOL bSolidDrag)
03087 {
03088     static DocRect RenderRect;
03089 
03090     RenderRegion* pRender = DocView::RenderOnTop( NULL, pSpread, UnclippedEOR );
03091 
03092     DocCoord Start;
03093     DocCoord End;
03094 
03095     while (pRender != NULL)
03096     {
03097         pRender->SetLineColour(COLOUR_BLACK);
03098         pRender->SetLineWidth(pRender->GetScaledPixelWidth());
03099 
03100         if (RenderOn)
03101         {
03102             View* pView = pRender->GetRenderView();
03103             if (pView != NULL)
03104             {
03105                 RenderRect = pView->GetDocViewRect(pSpread);
03106                 RenderRect = RenderRect.ToSpread(pSpread,pView);
03107             }
03108             RenderRect.Inflate(pRender->GetScaledPixelWidth());
03109         }
03110 
03111         Start = DocCoord(CurrentOrigin.x,RenderRect.lo.y);
03112         End   = DocCoord(CurrentOrigin.x,RenderRect.hi.y);
03113         pRender->DrawDashLine(Start,End);
03114 
03115         Start = DocCoord(RenderRect.lo.x,CurrentOrigin.y);
03116         End   = DocCoord(RenderRect.hi.x,CurrentOrigin.y);
03117         pRender->DrawDashLine(Start,End);
03118 
03119         // Get the Next render region
03120         pRender = DocView::GetNextOnTop(NULL);
03121     }   
03122 }
03123 
03124 /***********************************************************************************************
03125 
03126 >   static BOOL OpSpreadOrigin::Init()
03127 
03128     Author:     Mark_Neves (Xara Group Ltd) <camelotdev@xara.com>
03129     Created:    6/10/95
03130     Inputs:     -
03131     Outputs:    -
03132     Returns:    TRUE if op successfully declared, FALSE otherwise
03133     Purpose:    Registers an op desc for this op
03134     SeeAlso:    -
03135         
03136 ***********************************************************************************************/
03137 
03138 BOOL OpSpreadOrigin::Init()
03139 {
03140     return RegisterOpDescriptor(0, 
03141                                 _R(IDS_OPSPREADORIGIN),
03142                                 CC_RUNTIME_CLASS(OpSpreadOrigin), 
03143                                 OPTOKEN_SPREADORIGIN ,
03144                                 OpSpreadOrigin::GetState,
03145                                 0,  /* help ID */
03146                                 0,  /* bubble ID */
03147                                 0   /* bitmap ID */
03148                                 );
03149 }
03150 
03151 
03152 /***********************************************************************************************
03153 
03154 >   static OpState OpSpreadOrigin::GetState(String_256* Description, OpDescriptor*)
03155 
03156     Author:     Mark_Neves (Xara Group Ltd) <camelotdev@xara.com>
03157     Created:    6/10/95
03158     Inputs:     Description = ptr to place description of why this op can't happen
03159                 pOpDesc     = ptr to the Op Desc associated with this op
03160     Outputs:    -
03161     Returns:    An OpState object
03162     Purpose:    Func for determining the usability of this op
03163     SeeAlso:    -
03164         
03165 ***********************************************************************************************/
03166 
03167 OpState OpSpreadOrigin::GetState(String_256* Description, OpDescriptor*)
03168 {
03169     OpState State;
03170     return State;
03171 }
03172 
03173 
03175 // OpResetSpreadOrigin
03176 
03177 /******************************************************************************
03178 >   OpResetSpreadOrigin::OpResetSpreadOrigin()
03179 
03180     Author:     Ed_Cornes (Xara Group Ltd) <camelotdev@xara.com>
03181     Created:    10/10/95
03182     Purpose:    Default constructor
03183 ******************************************************************************/
03184 
03185 OpResetSpreadOrigin::OpResetSpreadOrigin()
03186 {
03187 }
03188 
03189 
03190 /******************************************************************************
03191 >   BOOL OpResetSpreadOrigin::Init()
03192 
03193     Author:     Ed_Cornes (Xara Group Ltd) <camelotdev@xara.com>
03194     Created:    10/10/95
03195     Returns:    FALSE if fails
03196     Purpose:    Initilise OpResetSpreadOrigin
03197 ******************************************************************************/
03198 
03199 BOOL OpResetSpreadOrigin::Init()
03200 {
03201     return RegisterOpDescriptor(0, 
03202                                 _R(IDS_OPRESETSPREADORIGIN),
03203                                 CC_RUNTIME_CLASS(OpResetSpreadOrigin), 
03204                                 OPTOKEN_RESETSPREADORIGIN ,
03205                                 OpResetSpreadOrigin::GetState,
03206                                 0,  /* help ID */
03207                                 0,  /* bubble ID */
03208                                 0   /* bitmap ID */
03209                                 );
03210 }
03211 
03212 
03213 /*****************************************************************************
03214 >   void OpResetSpreadOrigin::Do(OpDescriptor* pOpDesc)
03215 
03216     Author:     Ed_Cornes (Xara Group Ltd) <camelotdev@xara.com>
03217     Created:    10/10/95
03218     Inputs:     pOpDesc - not used
03219     Purpose:    Sets up params to set origin to page origin
03220                 and invokes OpSpreadOrigin::DoChangeOrigin()
03221 ******************************************************************************/
03222 
03223 void OpResetSpreadOrigin::Do(OpDescriptor* pOpDesc)
03224 {
03225     Spread* pSpread = Document::GetSelectedSpread();
03226     ERROR3IF(pSpread==NULL,"OpResetSpreadOrigin::Do() - no seleted spread");
03227     DocCoord PageOrigin(0,0);
03228     BOOL ok = (pSpread!=NULL);
03229     if (ok) ok = pSpread->PagesCoordToSpreadCoord(&PageOrigin,DocCoord(0,0));
03230     if (ok) ok = DoChangeOrigin(pSpread,PageOrigin);
03231 
03232     if (!ok)
03233         FailAndExecute();
03234     End();
03235 }
03236 
03237 
03238 /******************************************************************************
03239 >   static OpState OpResetSpreadOrigin::GetState(String_256* pReasonGreyed, OpDescriptor* pOpDesc)
03240 
03241     Author:     Ed_Cornes (Xara Group Ltd) <camelotdev@xara.com>
03242     Created:    10/10/95
03243     Inputs:     pOpDesc       - 
03244     Outputs:    pReasonGreyed - 
03245     Returns:    An OpState object
03246 ******************************************************************************/
03247 
03248 OpState OpResetSpreadOrigin::GetState(String_256* pReasonGreyed, OpDescriptor* pOpDesc)
03249 {
03250     OpState state(FALSE,TRUE);  // assume it will be greyed - for returning errors
03251 
03252     Spread* pSpread = Document::GetSelectedSpread();
03253     if (pSpread!=NULL)
03254     {
03255         DocCoord UserOrigin = UserCoord(0,0).ToSpread(pSpread);
03256         DocCoord PageOrigin(0,0);
03257         if (pSpread->PagesCoordToSpreadCoord(&PageOrigin,DocCoord(0,0))!=FALSE)
03258             state.Greyed = (UserOrigin==PageOrigin);
03259     }
03260     else
03261         ERROR3("OpResetSpreadOrigin::GetState() - no seleted spread");
03262 
03263     if (state.Greyed && pReasonGreyed!=NULL)
03264         pReasonGreyed->Load(_R(IDS_OPRESETSPREADORIGINGREY));
03265 
03266     return state;
03267 }
03268 #endif

Generated on Sat Nov 10 03:45:29 2007 for Camelot by  doxygen 1.4.4