guides.h

Go to the documentation of this file.
00001 // $Id: guides.h 1282 2006-06-09 09:46:49Z alex $
00002 /* @@tag:xara-cn@@ DO NOT MODIFY THIS LINE
00003 ================================XARAHEADERSTART===========================
00004  
00005                Xara LX, a vector drawing and manipulation program.
00006                     Copyright (C) 1993-2006 Xara Group Ltd.
00007        Copyright on certain contributions may be held in joint with their
00008               respective authors. See AUTHORS file for details.
00009 
00010 LICENSE TO USE AND MODIFY SOFTWARE
00011 ----------------------------------
00012 
00013 This file is part of Xara LX.
00014 
00015 Xara LX is free software; you can redistribute it and/or modify it
00016 under the terms of the GNU General Public License version 2 as published
00017 by the Free Software Foundation.
00018 
00019 Xara LX and its component source files are distributed in the hope
00020 that it will be useful, but WITHOUT ANY WARRANTY; without even the
00021 implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
00022 See the GNU General Public License for more details.
00023 
00024 You should have received a copy of the GNU General Public License along
00025 with Xara LX (see the file GPL in the root directory of the
00026 distribution); if not, write to the Free Software Foundation, Inc., 51
00027 Franklin St, Fifth Floor, Boston, MA  02110-1301 USA
00028 
00029 
00030 ADDITIONAL RIGHTS
00031 -----------------
00032 
00033 Conditional upon your continuing compliance with the GNU General Public
00034 License described above, Xara Group Ltd grants to you certain additional
00035 rights. 
00036 
00037 The additional rights are to use, modify, and distribute the software
00038 together with the wxWidgets library, the wxXtra library, and the "CDraw"
00039 library and any other such library that any version of Xara LX relased
00040 by Xara Group Ltd requires in order to compile and execute, including
00041 the static linking of that library to XaraLX. In the case of the
00042 "CDraw" library, you may satisfy obligation under the GNU General Public
00043 License to provide source code by providing a binary copy of the library
00044 concerned and a copy of the license accompanying it.
00045 
00046 Nothing in this section restricts any of the rights you have under
00047 the GNU General Public License.
00048 
00049 
00050 SCOPE OF LICENSE
00051 ----------------
00052 
00053 This license applies to this program (XaraLX) and its constituent source
00054 files only, and does not necessarily apply to other Xara products which may
00055 in part share the same code base, and are subject to their own licensing
00056 terms.
00057 
00058 This license does not apply to files in the wxXtra directory, which
00059 are built into a separate library, and are subject to the wxWindows
00060 license contained within that directory in the file "WXXTRA-LICENSE".
00061 
00062 This license does not apply to the binary libraries (if any) within
00063 the "libs" directory, which are subject to a separate license contained
00064 within that directory in the file "LIBS-LICENSE".
00065 
00066 
00067 ARRANGEMENTS FOR CONTRIBUTION OF MODIFICATIONS
00068 ----------------------------------------------
00069 
00070 Subject to the terms of the GNU Public License (see above), you are
00071 free to do whatever you like with your modifications. However, you may
00072 (at your option) wish contribute them to Xara's source tree. You can
00073 find details of how to do this at:
00074   http://www.xaraxtreme.org/developers/
00075 
00076 Prior to contributing your modifications, you will need to complete our
00077 contributor agreement. This can be found at:
00078   http://www.xaraxtreme.org/developers/contribute/
00079 
00080 Please note that Xara will not accept modifications which modify any of
00081 the text between the start and end of this header (marked
00082 XARAHEADERSTART and XARAHEADEREND).
00083 
00084 
00085 MARKS
00086 -----
00087 
00088 Xara, Xara LX, Xara X, Xara X/Xtreme, Xara Xtreme, the Xtreme and Xara
00089 designs are registered or unregistered trademarks, design-marks, and/or
00090 service marks of Xara Group Ltd. All rights in these marks are reserved.
00091 
00092 
00093       Xara Group Ltd, Gaddesden Place, Hemel Hempstead, HP2 6EX, UK.
00094                         http://www.xara.com/
00095 
00096 =================================XARAHEADEREND============================
00097  */
00098 // Defines the NodeGuideline class
00099 
00100 #ifndef INC_GUIDES_H
00101 #define INC_GUIDES_H
00102 
00103 //#include "ink.h" - in camtypes.h [AUTOMATICALLY REMOVED]
00104 //#include "doccolor.h" - in camtypes.h [AUTOMATICALLY REMOVED]
00105 //#include "undoop.h" - in camtypes.h [AUTOMATICALLY REMOVED]
00106 #include "snap.h"
00107 //#include "dialogop.h"
00108 #if !defined(EXCLUDE_FROM_RALPH)
00109 #include "optsgrid.h"
00110 #endif
00111 
00112 class RenderRegion;
00113 class Spread;
00114 class ContextMenu;
00115 class KeyPress;
00116 
00117 /***********************************************************************************************
00118 
00119 >    class NodeGuideline : public NodeRenderableInk
00120 
00121      Author:        Mark_Neves (Xara Group Ltd) <camelotdev@xara.com>
00122      Created:       5/9/95
00123      Base Classes:  NodeRenderableInk
00124      Purpose:       Defines the NodeGuideline Class
00125 
00126      SeeAlso:       NodeRenderableInk
00127     
00128 ***********************************************************************************************/
00129 
00130 class NodeGuideline : public NodeRenderableInk
00131 {   
00132     CC_DECLARE_DYNAMIC( NodeGuideline ) 
00133 
00134 public:  
00135     NodeGuideline(); 
00136 
00137     virtual String Describe(BOOL Plural, BOOL Verbose);             
00138                    
00139     virtual SubtreeRenderState RenderSubtree(RenderRegion* pRender, Node** ppNextNode = NULL, BOOL bClip = TRUE);
00140     virtual void Render( RenderRegion* pRender );
00141     virtual DocRect GetBoundingRect(BOOL DontUseAttrs=FALSE, BOOL HitTest=FALSE);
00142     virtual BOOL OnClick( DocCoord PointerPos, ClickType Click, ClickModifiers ClickMods, Spread *pSpread );
00143     virtual BOOL OnNodePopUp(Spread* pSpread, DocCoord PointerPos, ContextMenu* pMenu);
00144     virtual void SetSelected(BOOL Status);
00145     virtual void Transform( TransformBase& Trans );
00146 
00147     virtual void PreExportRender(RenderRegion* pRegion);
00148     virtual BOOL ExportRender(RenderRegion* pRegion);
00149     virtual BOOL NeedsToExport(RenderRegion *pRender,BOOL VisibleLayersOnly = FALSE, BOOL CheckSelected = FALSE);
00150 
00151     static DocRect GetRenderRect(MILLIPOINT Ordinate,GuidelineType Type,BOOL HitTest= FALSE, RenderRegion* pRender = NULL);
00152     DocRect GetRenderRect(BOOL HitTest = FALSE, RenderRegion* pRender = NULL);
00153         
00154     #ifdef _DEBUG                         
00155     virtual void ShowDebugTreeDetails() const;   
00156     #endif
00157     
00158     virtual void GetDebugDetails(StringBase* Str);   // This is used by the Debug Tree dialog
00159                                                      // It will probably be deleted when we ship !. 
00160     virtual BOOL Snap(DocCoord* pDocCoord);
00161     virtual BOOL Snap(DocRect* pDocRect,const DocCoord& PrevCoord,const DocCoord& CurCoord);
00162 
00163     void SetType(GuidelineType NewType)  { Type = NewType; }
00164     GuidelineType GetType() { return Type; }
00165 
00166     void MakeHorzGuideline() { Type = GUIDELINE_HORZ; }
00167     void MakeVertGuideline() { Type = GUIDELINE_VERT; }
00168 
00169     // Set & Get funcs that take Spread coords
00170     void        SetOrdinate(MILLIPOINT NewOrdinate) { Ordinate = NewOrdinate; }
00171     MILLIPOINT  GetOrdinate() { return Ordinate; }
00172 
00173     // Functions for converting from Spread to UserCoords, and back again.
00174     static MILLIPOINT ToSpreadOrdinate(Spread* pSpread,MILLIPOINT UserOrdinate,GuidelineType Type);
00175     static MILLIPOINT ToUserOrdinate(Spread* pSpread,MILLIPOINT SpreadOrdinate,GuidelineType Type);
00176 
00177     virtual void PolyCopyNodeContents(NodeRenderable* pNodeCopy);
00178 
00179     // Version 2 file format functions
00180     virtual BOOL WritePreChildrenWeb(BaseCamelotFilter* pFilter);
00181     virtual BOOL WritePreChildrenNative(BaseCamelotFilter* pFilter);
00182 
00183 private:
00184     virtual Node* SimpleCopy();   
00185     void CopyNodeContents(NodeGuideline* NodeCopy);
00186 
00187     MILLIPOINT  ExtractOrdinate(DocCoord* pDocCoord);
00188     void        ReplaceOrdinate(DocCoord* pDocCoord,MILLIPOINT Ordinate);
00189     void        TranslateRect(DocRect* pDocRect,MILLIPOINT Delta);
00190 
00191     static MILLIPOINT GetScaledPixelWidth(RenderRegion* pRender = NULL);
00192 
00193     // REMEMBER TO UPDATE CopyNodeContents
00194 
00195     GuidelineType   Type;
00196     MILLIPOINT      Ordinate;
00197 };
00198 
00199 //-----------------------------------------------------------------------
00200 //-----------------------------------------------------------------------
00201 // Types of op the OpGuideline class can do
00202 
00203 enum OpGuidelineOpMethod  { GUIDELINEOPMETHOD_INVALID,              // used to invalidate static data
00204                             GUIDELINEOPMETHOD_MOVE_DRAG,            // Move the guideline via a drag
00205                             GUIDELINEOPMETHOD_NEW_DRAG,             // Create a new guideline via a drag
00206                             GUIDELINEOPMETHOD_MOVE_IMMEDIATE,       // Move the guideline immediately
00207                             GUIDELINEOPMETHOD_NEW_IMMEDIATE,        // Create a new guideline immediately
00208                             GUIDELINEOPMETHOD_DELETE,               // Deletes guidelines
00209                             GUIDELINEOPMETHOD_CREATE_GUIDE_LAYER    // Create guide layer
00210                           };
00211 
00212 // WEBSTER - markn 15/1/97
00213 // Remove the same bits Ralph removes from the guides system
00214 #ifndef WEBSTER
00215 #if !defined(EXCLUDE_FROM_RALPH)
00216 
00217 /********************************************************************************************
00218 
00219 >   class OpGuidelineParam : public OpParam
00220 
00221     Author:     Mark_Neves (Xara Group Ltd) <camelotdev@xara.com>
00222     Created:    2/10/95
00223     Purpose:    Param passed to OpGuideline::DoWithParams()
00224 
00225 ********************************************************************************************/
00226 
00227 class OpGuidelineParam : public OpParam
00228 {
00229     CC_DECLARE_MEMDUMP(OpGuidelineParam)
00230 
00231 public:
00232     OpGuidelineOpMethod Method;
00233 
00234     // for type == GUIDELINEOPMETHOD_NEW
00235     GuidelineType   Type;                   // The type of guideline to produce at the end of a drag
00236 
00237     // for type == GUIDELINEOPMETHOD_MOVE
00238     NodeGuideline*  pGuideline;             // The guideline to translate
00239     MILLIPOINT      NewOrdinate;            // The new absolute ordinate for the guideline
00240 
00241     // for type == GUIDELINEOPMETHOD_DELETE
00242     NodeGuideline** pGuidelineList;
00243 };
00244 
00245 /********************************************************************************************
00246 
00247 >   class OpGuideline : public UndoableOperation
00248 
00249     Author:     Mark_Neves (Xara Group Ltd) <camelotdev@xara.com>
00250     Created:    6/9/95
00251     Purpose:    Allows guidelines to be dragged around
00252 
00253 ********************************************************************************************/
00254 
00255 class OpGuideline : public UndoableOperation
00256 {
00257 
00258 CC_DECLARE_DYNCREATE(OpGuideline);
00259 
00260 public:
00261     #define OPTOKEN_GUIDELINE _T("Guideline")   
00262 
00263     // Construction/Destruction
00264     OpGuideline();
00265     ~OpGuideline();
00266 
00267     virtual void DoWithParam(OpDescriptor* pOpDesc,OpParam* pParam);
00268 
00269     // Virtual functions needed for the dragging operations to work
00270     virtual BOOL DragKeyPress(KeyPress* pKeyPress, BOOL bSolidDrag);
00271     virtual void DragPointerMove( DocCoord PointerPos, ClickModifiers ClickMods, Spread*, BOOL bSolidDrag);
00272     virtual void DragFinished(  DocCoord PointerPos, 
00273                                 ClickModifiers ClickMods, Spread*, 
00274                                 BOOL Success, BOOL bSolidDrag);
00275 
00276     virtual BOOL Undo();
00277     virtual BOOL Redo();
00278 
00279     // Some Render functions to will draw the EORed drag boxes
00280     void RenderMyDragBlobs();
00281     void RenderDragBlobs(DocRect Rect,Spread* pSpread, BOOL bSolidDrag);
00282         
00283     // These functions required for the OpDescriptor class
00284     static BOOL Init();
00285     static OpState GetState(String_256* Description, OpDescriptor*);
00286     void GetOpName(String_256* OpName);
00287 
00288 // WEBSTER - markn 15/1/97
00289 // Moved static function CreateGuideLayer() into the Layer class, where it should be
00290 //  static Layer* CreateGuideLayer();
00291     static BOOL IsMouseOverRuler();
00292 
00293 protected:
00294     // The all important Do functions
00295     void DoDrag(Spread* pSpread,DocCoord PointerPos);
00296 
00297     void DoAddNewGuideline(Spread* pSpread,DocCoord PointerPos,GuidelineType Type);
00298     void DoMoveGuideline(Spread* pSpread,DocCoord PointerPos,NodeGuideline* pGuideline);
00299 
00300     BOOL DoTranslateGuideline(NodeGuideline* pGuideline,MILLIPOINT Ordinate,NodeGuideline** ppNewGuideline = NULL);
00301     BOOL DoNewGuideline(Node* pContext,AttachNodeDirection AttachDir,GuidelineType Type,MILLIPOINT Ordinate,NodeGuideline** ppNewGuideline = NULL);
00302     BOOL DoDeleteGuideline(NodeGuideline* pGuideline,BOOL TryToLeaveCopy = FALSE);
00303     BOOL DoDeleteListOfGuidelines(NodeGuideline** pGuidelineList);
00304     Layer* DoCreateGuideLayer();
00305 
00306     BOOL CanLeaveCopy();
00307 
00308     void UpdateStatusLineAndPointer();
00309 
00310     void BroadcastGuidelineChanges(NodeGuideline* pGuideline);
00311     void BroadcastGuidelineChanges(Layer* pLayer);
00312 
00313     void SetOrdinate(DocCoord& PointerPos);
00314 
00315 private:
00316     OpGuidelineOpMethod OpMethod;
00317 
00318     // Stuff for dragging guidelines around
00319     Spread*         pSpread;
00320     NodeGuideline*  pDraggedGuideline;
00321     MILLIPOINT      Ordinate;
00322     GuidelineType   Type;
00323     BOOL            LeaveCopy;
00324     Cursor*         pCursor;
00325     UINT32          CurrentStatusHelp;
00326     INT32           CursorStackID;
00327 
00328     // Layer used by broadcast
00329     Layer* pBroadcastLayer;
00330 
00331     BOOL RenderOn;
00332 
00333 protected:
00334     // The ID of the op used in the undo & redo menu items
00335     UINT32 UndoIDS;
00336 };
00337 
00338 
00339 /********************************************************************************************
00340 
00341 >   class OpDeleteGuideline : public OpGuideline
00342 
00343     Author:     Mark_Neves (Xara Group Ltd) <camelotdev@xara.com>
00344     Created:    5/10/95
00345     Purpose:    Allows guides to be Deleted
00346 
00347 ********************************************************************************************/
00348 
00349 class OpDeleteGuideline : public OpGuideline
00350 {
00351 
00352 CC_DECLARE_DYNCREATE(OpDeleteGuideline);
00353 
00354 public:
00355     #define OPTOKEN_DELETEGUIDELINE _T("DeleteGuideline")
00356     
00357     // Construction/Destruction
00358     OpDeleteGuideline();
00359     ~OpDeleteGuideline();
00360 
00361     virtual void Do(OpDescriptor* pOpDesc);
00362 
00363     // These functions required for the OpDescriptor class
00364     static OpState GetState(String_256* Description, OpDescriptor*);
00365 
00366     static void SetGuideline(NodeGuideline* pThisGuideline) { pGuideline = pThisGuideline; }
00367 
00368 protected:
00369     static NodeGuideline* pGuideline;
00370 };
00371 
00372 /********************************************************************************************
00373 
00374 >   class OpDeleteAllGuidelines : public OpGuideline
00375 
00376     Author:     Mark_Neves (Xara Group Ltd) <camelotdev@xara.com>
00377     Created:    5/10/95
00378     Purpose:    Allows guides to be Deleted
00379 
00380 ********************************************************************************************/
00381 
00382 class OpDeleteAllGuidelines : public OpGuideline
00383 {
00384 
00385 CC_DECLARE_DYNCREATE(OpDeleteAllGuidelines);
00386 
00387 public:
00388     #define OPTOKEN_DELETEALLGUIDELINES _T("DeleteAllGuidelines")
00389     
00390     // Construction/Destruction
00391     OpDeleteAllGuidelines();
00392     ~OpDeleteAllGuidelines();
00393 
00394     virtual void Do(OpDescriptor* pOpDesc);
00395 
00396     // These functions required for the OpDescriptor class
00397     static OpState GetState(String_256* Description, OpDescriptor*);
00398 };
00399 
00400 
00401 /******************************************************************************
00402 >   class OpNewGuideline : public OpGuideline
00403 
00404     Author:     Ed_Cornes (Xara Group Ltd) <camelotdev@xara.com>
00405     Created:    9/10/95
00406     Purpose:    op to create a new guideline immendiately
00407 *******************************************************************************/
00408 
00409 class OpNewGuideline : public OpGuideline
00410 {
00411     CC_DECLARE_DYNCREATE(OpNewGuideline);
00412 
00413 public:
00414     #define OPTOKEN_NEWGUIDELINE2 _T("NewGuideline")
00415     
00416     OpNewGuideline();
00417     ~OpNewGuideline();
00418     static BOOL Init();
00419 
00420     virtual void Do(OpDescriptor* pOpDesc);
00421 
00422     static OpState GetState(String_256* pReasonGreyed, OpDescriptor* pOpDesc);
00423 
00424     static void SetNewGuidelineParam(GuidelineType Type, MILLIPOINT pos);
00425 
00426 protected:
00427     static OpGuidelineParam NewGuidelineParam;
00428 };
00429 
00430 
00431 /********************************************************************************************
00432 >   class OpSpreadOrigin : public OpGridResize
00433 
00434     Author:     Mark_Neves (Xara Group Ltd) <camelotdev@xara.com>
00435     Created:    6/10/95
00436     Purpose:    Allows you to drag the origin to another place
00437 ********************************************************************************************/
00438 
00439 class OpSpreadOrigin : public OpGridResize
00440 {
00441     CC_DECLARE_DYNCREATE(OpSpreadOrigin);
00442     #define OPTOKEN_SPREADORIGIN _T("SpreadOrigin") 
00443 
00444 public:
00445     OpSpreadOrigin();
00446     ~OpSpreadOrigin();
00447 
00448     virtual void Do(OpDescriptor* pOpDesc);
00449 
00450     // Virtual functions needed for the dragging operations to work
00451     virtual void DragPointerMove( DocCoord PointerPos, ClickModifiers ClickMods, Spread*, BOOL bSolidDrag);
00452     virtual void DragFinished(  DocCoord PointerPos, 
00453                                 ClickModifiers ClickMods, Spread*, 
00454                                 BOOL Success, BOOL bSolidDrag);
00455 
00456     // Some Render functions to will draw the EORed drag boxes
00457     void RenderMyDragBlobs();
00458     void RenderDragBlobs(DocRect Rect,Spread* pSpread, BOOL bSolidDrag);
00459         
00460     // These functions required for the OpDescriptor class
00461     static BOOL Init();
00462     static OpState GetState(String_256* Description, OpDescriptor*);
00463 
00464 protected:
00465     // The all important Do functions
00466     void DoDrag(Spread* pSpread,DocCoord PointerPos);
00467     BOOL DoChangeOrigin(Spread* pSpread,DocCoord NewOrigin);
00468 
00469 private:
00470     // Stuff for dragging guidelines around
00471     Spread*  pSpread;
00472     DocCoord CurrentOrigin;
00473     BOOL RenderOn;
00474 };
00475 
00476 
00477 /******************************************************************************
00478 >   class OpResetSpreadOrigin : public OpSpreadOrigin
00479 
00480     Author:     Ed_Cornes (Xara Group Ltd) <camelotdev@xara.com>
00481     Created:    10/10/95
00482     Purpose:    op to reset the spread (user and grid) origin
00483 *******************************************************************************/
00484 
00485 class OpResetSpreadOrigin : public OpSpreadOrigin
00486 {
00487     CC_DECLARE_DYNCREATE(OpResetSpreadOrigin);
00488     #define OPTOKEN_RESETSPREADORIGIN _T("ResetSpreadOrigin")
00489     
00490 public:
00491     OpResetSpreadOrigin();
00492     static BOOL Init();
00493 
00494     virtual void Do(OpDescriptor* pOpDesc);
00495     static OpState GetState(String_256* pReasonGreyed, OpDescriptor* pOpDesc);
00496 };
00497 
00498 
00499 /********************************************************************************************
00500 >   class GuidelinePropDlgParams
00501 
00502     Author:     Mark_Neves (Xara Group Ltd) <camelotdev@xara.com>
00503     Created:    29/9/95
00504     Purpose:    Parameters needed for the guideline properties dlg to function correctly
00505 ********************************************************************************************/
00506 
00507 class GuidelinePropDlgParams
00508 {
00509 public:
00510     GuidelinePropDlgParams() { pGuideline = NULL; }
00511 
00512     NodeGuideline*  pGuideline;     // Can be NULL
00513 
00514     // If pGuideline is NULL the following params are used to create a new Guideline
00515     MILLIPOINT      Ordinate;       // Ordinate in Spread coords
00516     GuidelineType   Type;           // The type of new Guideline
00517 };
00518 
00519 
00520 /********************************************************************************************
00521 >   class GuidelinePropDlg: public DialogOp
00522 
00523     Author:     Mark_Neves (Xara Group Ltd) <camelotdev@xara.com>
00524     Created:    29/9/95
00525     Purpose:    Allows the user to change the properties of a guideline
00526 ********************************************************************************************/
00527 
00528 class GuidelinePropDlg: public DialogOp
00529 {         
00530     CC_DECLARE_DYNCREATE( GuidelinePropDlg )  
00531     #define OPTOKEN_EDITGUIDELINEPROPDLG _T("EditGuidelinePropDlg")
00532     #define OPTOKEN_NEWGUIDELINEPROPDLG   _T("NewGuidelinePropDlg")
00533 
00534 public:
00535     GuidelinePropDlg();
00536     void Do(OpDescriptor*);
00537 
00538     static const INT32 IDD;
00539     static const CDlgMode Mode;
00540 
00541     static OpState GetState(String_256*, OpDescriptor*);    
00542     static BOOL Init();
00543 
00544     MsgResult Message(Msg* Message);
00545 
00546     void ShowDetails();
00547     BOOL CommitValues();
00548 
00549     static void SetNewGuidelineParams(GuidelineType type, MILLIPOINT pos);
00550     static void SetEditGuidelineParams(NodeGuideline* pGuide);
00551 
00552 private:
00553     static GuidelinePropDlgParams Params;
00554 }; 
00555 
00556 #endif
00557 #endif // WEBSTER
00558 #endif // INC_GUIDES_H

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