moldtool.h

Go to the documentation of this file.
00001 // $Id: moldtool.h 1282 2006-06-09 09:46:49Z alex $
00002 /* @@tag:xara-cn@@ DO NOT MODIFY THIS LINE
00003 ================================XARAHEADERSTART===========================
00004  
00005                Xara LX, a vector drawing and manipulation program.
00006                     Copyright (C) 1993-2006 Xara Group Ltd.
00007        Copyright on certain contributions may be held in joint with their
00008               respective authors. See AUTHORS file for details.
00009 
00010 LICENSE TO USE AND MODIFY SOFTWARE
00011 ----------------------------------
00012 
00013 This file is part of Xara LX.
00014 
00015 Xara LX is free software; you can redistribute it and/or modify it
00016 under the terms of the GNU General Public License version 2 as published
00017 by the Free Software Foundation.
00018 
00019 Xara LX and its component source files are distributed in the hope
00020 that it will be useful, but WITHOUT ANY WARRANTY; without even the
00021 implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
00022 See the GNU General Public License for more details.
00023 
00024 You should have received a copy of the GNU General Public License along
00025 with Xara LX (see the file GPL in the root directory of the
00026 distribution); if not, write to the Free Software Foundation, Inc., 51
00027 Franklin St, Fifth Floor, Boston, MA  02110-1301 USA
00028 
00029 
00030 ADDITIONAL RIGHTS
00031 -----------------
00032 
00033 Conditional upon your continuing compliance with the GNU General Public
00034 License described above, Xara Group Ltd grants to you certain additional
00035 rights. 
00036 
00037 The additional rights are to use, modify, and distribute the software
00038 together with the wxWidgets library, the wxXtra library, and the "CDraw"
00039 library and any other such library that any version of Xara LX relased
00040 by Xara Group Ltd requires in order to compile and execute, including
00041 the static linking of that library to XaraLX. In the case of the
00042 "CDraw" library, you may satisfy obligation under the GNU General Public
00043 License to provide source code by providing a binary copy of the library
00044 concerned and a copy of the license accompanying it.
00045 
00046 Nothing in this section restricts any of the rights you have under
00047 the GNU General Public License.
00048 
00049 
00050 SCOPE OF LICENSE
00051 ----------------
00052 
00053 This license applies to this program (XaraLX) and its constituent source
00054 files only, and does not necessarily apply to other Xara products which may
00055 in part share the same code base, and are subject to their own licensing
00056 terms.
00057 
00058 This license does not apply to files in the wxXtra directory, which
00059 are built into a separate library, and are subject to the wxWindows
00060 license contained within that directory in the file "WXXTRA-LICENSE".
00061 
00062 This license does not apply to the binary libraries (if any) within
00063 the "libs" directory, which are subject to a separate license contained
00064 within that directory in the file "LIBS-LICENSE".
00065 
00066 
00067 ARRANGEMENTS FOR CONTRIBUTION OF MODIFICATIONS
00068 ----------------------------------------------
00069 
00070 Subject to the terms of the GNU Public License (see above), you are
00071 free to do whatever you like with your modifications. However, you may
00072 (at your option) wish contribute them to Xara's source tree. You can
00073 find details of how to do this at:
00074   http://www.xaraxtreme.org/developers/
00075 
00076 Prior to contributing your modifications, you will need to complete our
00077 contributor agreement. This can be found at:
00078   http://www.xaraxtreme.org/developers/contribute/
00079 
00080 Please note that Xara will not accept modifications which modify any of
00081 the text between the start and end of this header (marked
00082 XARAHEADERSTART and XARAHEADEREND).
00083 
00084 
00085 MARKS
00086 -----
00087 
00088 Xara, Xara LX, Xara X, Xara X/Xtreme, Xara Xtreme, the Xtreme and Xara
00089 designs are registered or unregistered trademarks, design-marks, and/or
00090 service marks of Xara Group Ltd. All rights in these marks are reserved.
00091 
00092 
00093       Xara Group Ltd, Gaddesden Place, Hemel Hempstead, HP2 6EX, UK.
00094                         http://www.xara.com/
00095 
00096 =================================XARAHEADEREND============================
00097  */
00098 // Header for the mould tool implementation
00099 
00100 #ifndef INC_MOULDTOOL
00101 #define INC_MOULDTOOL
00102 
00103 //#include "tool.h" - in camtypes.h [AUTOMATICALLY REMOVED]
00104 //#include "doccoord.h" - in camtypes.h [AUTOMATICALLY REMOVED]
00105 //#include "bars.h" - in camtypes.h [AUTOMATICALLY REMOVED]
00106 #include "nodemold.h"
00107 #include "moldedit.h"
00108 //#include "ops.h" - in camtypes.h [AUTOMATICALLY REMOVED]
00109 #include "dragtool.h"
00110 
00111 class Cursor;
00112 class Spread;
00113 class MouldInfoBarOp;
00114 class CCAttrMap;
00115 
00116 #define OPTOKEN_CREATENEWMOULD          _T("CreateMould")
00117 #define OPTOKEN_REMOVEMOULD             _T("RemoveMould")
00118 #define OPTOKEN_COPYMOULD               _T("CopyMould")
00119 #define OPTOKEN_PASTEENVELOPE           _T("PasteEnvelope")
00120 #define OPTOKEN_PASTEPERSPECTIVE        _T("PastePerspective")
00121 #define OPTOKEN_TOGGLEMOULDGRID         _T("ToggleMouldGrid")
00122 #define OPTOKEN_DETACHMOULD             _T("DetachMould")
00123 #define OPTOKEN_ROTATEMOULD             _T("RotateMould")
00124 #define OPTOKEN_RECTANGULARENVELOPE     _T("DefaultEnvelope")
00125 #define OPTOKEN_RECTANGULARPERSPECTIVE  _T("DefaultPerspective")
00126 
00127 typedef enum EnvelopeType {
00128     ENV_DEFAULT,
00129     ENV_CIRCULAR,
00130     ENV_ELLIPTICAL,
00131     ENV_CONCAVE,
00132     ENV_BANNER
00133 };
00134 
00135 typedef enum PerspectiveType {
00136     PER_DEFAULT,
00137     PER_LEFT,
00138     PER_RIGHT,
00139     PER_FLOOR,
00140     PER_ROOF
00141 };
00142 
00143 
00144 /********************************************************************************************
00145 
00146 >   class MouldTool : public Tool_v1
00147 
00148     Author:     Mike_Kenny (Xara Group Ltd) <camelotdev@xara.com>
00149     Created:    30/10/94
00150     Purpose:    A template tool class
00151 
00152 ********************************************************************************************/
00153 
00154 class CCAPI MouldTool : public DragTool
00155 {
00156 // Give tool name in memory dumps
00157 CC_DECLARE_MEMDUMP(MouldTool);
00158 
00159 public:
00160      MouldTool();
00161     ~MouldTool();
00162 
00163     // Standard calls your tool must provide
00164     BOOL Init();
00165     void Describe(void* InfoPtr);
00166     UINT32 GetID() { return TOOLID_MOULD; };        // defined in kernel\tool.h
00167     
00168     // Some very common event handlers
00169     virtual void SelectChange(BOOL isSelected);
00170     virtual void OnClick( DocCoord, ClickType, ClickModifiers, Spread* );
00171     virtual void OnMouseMove(DocCoord PointerPos,Spread* pSpread, ClickModifiers ClickMods);
00172     virtual void RenderToolBlobs(Spread* pSpread,DocRect* pDocRect);
00173     virtual BOOL GetStatusLineText(String_256* ptext, Spread* pSpread, DocCoord coord, ClickModifiers mods);
00174 
00175     // Some useful static functions
00176     static  MouldInfoBarOp* GetMouldInfoBarOp()  { return pMouldInfoBarOp; }
00177     static  BOOL            IsCurrentTool()      { return CurrentTool; }
00178     static  void            DisplayStatusBarHelp(UINT32 StatusID);
00179 
00180     void    CreateEnvelope(EnvelopeType EnvType);
00181     void    CreateEnvelope2x2(EnvelopeType EnvType);
00182     void    CreatePerspective(PerspectiveType PerType);
00183     void    PasteMould(MouldSpace m_space);
00184 
00185 private:
00186     BOOL    CreateCursors();                        // Create  your tool's cursors in this func
00187     void    DestroyCursors();                       // Destroy your tool's cursors in this func
00188     void    ChangeCursor(Cursor* cursor);           // Change the cursor shape
00189     Cursor* ChooseCursor(INT32);
00190     void    GenerateStatusLineText(INT32 msgres, String_256* pStatusMsg);
00191     BOOL    DetermineClickEffect(DocCoord PointerPos, Spread* pSpread, ClickModifiers ClickMods, INT32* ctype, INT32* msgres);
00192 
00193     static  BOOL            CurrentTool;        // Can be useful to keep a "is my tool current?" flag
00194     static  MouldInfoBarOp* pMouldInfoBarOp;    // Ptr to your tool's infobar
00195 
00196     Cursor* pcNormalMouldCursor;                // Your standard cursor to use when your tool becomes active
00197     Cursor* pcCurrentCursor;                    // The cursor your tool is currently displaying
00198     Cursor* pcTransOriginCursor;                // The translate perspective vanishing point cursor
00199     Cursor* pcTransCoordCursor;                 // the translate mould path coordinates cursor
00200     INT32   CurrentCursorID;                    // ID of the current cursor on the stack
00201 
00202     // Standard tool static vars
00203     static  TCHAR* FamilyName;                  // The Tools Family Name
00204     static  TCHAR* ToolName;                        // The Tool Name
00205     static  TCHAR* Purpose;                     // What the tool is for
00206     static  TCHAR* Author;                      // Who wrote it
00207 };
00208 
00209 
00210 
00211 
00212 /********************************************************************************************
00213 
00214 >   class MouldInfoBarOp : public InformationBarOp
00215 
00216     Author:     Mike_Kenny (Xara Group Ltd) <camelotdev@xara.com>
00217     Created:    30/11/94
00218     Purpose:    Class for handling the tool's information bar.
00219 
00220 ********************************************************************************************/
00221 
00222 class MouldInfoBarOp : public InformationBarOp
00223 {
00224     CC_DECLARE_DYNCREATE( MouldInfoBarOp )  
00225 
00226 public:
00227     MouldInfoBarOp();
00228     MsgResult Message(Msg* Msg);                        // All messages to the info bar come through here
00229     static  INT32 SelInfo(NodeMould**);
00230     virtual void UpdateState(); 
00231             void UpdateDefEnvButton(BOOL Selection);
00232             void UpdateDefPerButton(BOOL Selection);
00233             void UpdateDetachButton(BOOL Selection);
00234             BOOL CheckSelection();
00235             void SetTool(MouldTool*);
00236             void SetDetachState(BOOL state);
00237             BOOL GetDetachState() const { return DetachState; }
00238     
00239 private:
00240     BOOL        DetachState;
00241     BOOL        GridState;
00242     MouldTool*  pMouldTool;                             // Pointer to instance of mould tool
00243 
00244     // DMc
00245     // returns TRUE for the selection can be moulded, false otherwise
00246     // tests for any nodes with NeedParent set
00247     BOOL CanMouldSelection();
00248 };
00249     
00250 
00251 /********************************************************************************************
00252 
00253 >   class MouldInfoBarOpCreate : public BarCreate
00254 
00255     Author:     Mike_Kenny (Xara Group Ltd) <camelotdev@xara.com>
00256     Created:    30/11/94
00257     Purpose:    Class for creating MouldInfoBarOps.
00258                 Derived classes of BarCreate are used by DialogBarOp::ReadBarsFromFile()
00259 
00260 ********************************************************************************************/
00261 
00262 class MouldInfoBarOpCreate : public BarCreate
00263 {
00264 public:
00265     DialogBarOp* Create() { return (new MouldInfoBarOp); }
00266 };
00267 
00268 /***********************************************************************************************
00269 
00270 >   class CreateMouldParam : public OpParam
00271 
00272     Author:     Mike_Kenny (Xara Group Ltd) <camelotdev@xara.com>
00273     Created:    12/12/94
00274     Purpose:    The OpParam to use when Invoke()ing the CreateNewMould operation
00275 
00276 ***********************************************************************************************/
00277 
00278 class CreateMouldParam : public OpParam
00279 {
00280      CC_DECLARE_MEMDUMP(CreateMouldParam)   
00281 
00282     public:
00283         CreateMouldParam(Path* pPath, MouldSpace mSpace, BOOL FitObjects, BOOL Lock) : OpParam(0, 0) \
00284             { ParamShape = pPath; 
00285               ParamSpace = mSpace;
00286               FitSelection = FitObjects;
00287               LockAspect = Lock;
00288             }
00289 
00290         Path*       ParamShape;
00291         MouldSpace  ParamSpace;
00292         BOOL        FitSelection;
00293         BOOL        LockAspect;
00294 };
00295 
00296 
00297 
00298 
00299 /*******************************************************************************************
00300 
00301 >   class OpCreateNewMould: public OpMouldLibSel
00302 
00303     Author:     Mike_Kenny (Xara Group Ltd) <camelotdev@xara.com>
00304     Created:    12/12/94
00305     Purpose:    Creates a new mould object and all its various children to form a valid
00306                 mould structure. The operation will execute only when there is one or more
00307                 selected objects to work on. These selected objects will to all intense and
00308                 purpose dissappear from the tree. They will move from their current positions
00309                 and move inside the new mould node. 
00310 
00311 ********************************************************************************************/
00312 
00313 class OpCreateNewMould: public OpMouldLibSel
00314 {
00315     CC_DECLARE_DYNCREATE( OpCreateNewMould ) 
00316     
00317     public:
00318         OpCreateNewMould();
00319                                         
00320         static BOOL     Init();             
00321         static OpState  GetState(String_256*, OpDescriptor*);       
00322         void            GetOpName(String_256* OpName);
00323         void            DoWithParam(OpDescriptor*, OpParam*);
00324 
00325     private:
00326         BOOL AllMouldObjects(List* pNodeList);
00327 
00328     private:
00329         MouldSpace m_space;
00330 
00331 };
00332 
00333 
00334 
00335 /********************************************************************************************
00336 
00337 >   class OpRemoveMould : public OpMouldLibSel
00338 
00339     Author:     Mike_Kenny (Xara Group Ltd) <camelotdev@xara.com>
00340     Created:    18/01/95
00341     Purpose:    An undoable operation to remove the mould shape from a mould object
00342 
00343 ********************************************************************************************/
00344 
00345 class OpRemoveMould: public OpMouldLibSel
00346 {
00347     CC_DECLARE_DYNCREATE( OpRemoveMould )    
00348 
00349     public:
00350         OpRemoveMould();                                
00351         static BOOL     Init();             
00352         static OpState  GetState(String_256*, OpDescriptor*);       
00353         void            GetOpName(String_256* OpName);
00354         void            Do(OpDescriptor*);  
00355 };
00356 
00357 
00358 /********************************************************************************************
00359 
00360 >   class OpCopyMouldShape : public OpMouldLibSel
00361 
00362     Author:     Mike_Kenny (Xara Group Ltd) <camelotdev@xara.com>
00363     Created:    18/01/95
00364     Purpose:    An undoable operation to copy the mould shape to the clipboard
00365     SeeAlso:    -
00366 
00367 ********************************************************************************************/
00368 
00369 class OpCopyMouldShape: public OpMouldLibSel
00370 {
00371     CC_DECLARE_DYNCREATE( OpCopyMouldShape )    
00372 
00373     public:
00374         OpCopyMouldShape();                             
00375         static BOOL     Init();             
00376         static OpState  GetState(String_256*, OpDescriptor*);       
00377         void            GetOpName(String_256* OpName);
00378         void            Do(OpDescriptor*);  
00379 };
00380 
00381 
00382 /********************************************************************************************
00383 
00384 >   class OpPasteMouldShape : public OpMouldLibSel
00385 
00386     Author:     Mike_Kenny (Xara Group Ltd) <camelotdev@xara.com>
00387     Created:    18/01/95
00388     Purpose:    An undoable operation to paste the contents of the clipboard as a mould
00389                 shape.
00390     SeeAlso:    
00391 
00392 ********************************************************************************************/
00393 
00394 class OpPasteMouldShape: public OpMouldLibSel
00395 {
00396     CC_DECLARE_DYNCREATE( OpPasteMouldShape )    
00397 
00398     public:
00399         OpPasteMouldShape();                                
00400 
00401     protected:
00402         static BOOL FindPasteObject(Node** pReturnNode);
00403         void        Do(MouldSpace mSpace);  
00404 };
00405 
00406 
00407 
00408 /********************************************************************************************
00409 
00410 >   class OpPasteEnvelope : public OpPasteMouldShape
00411 
00412     Author:     Mike_Kenny (Xara Group Ltd) <camelotdev@xara.com>
00413     Created:    18/01/95
00414     Purpose:    An undoable operation to paste the contents of the clipboard as a mould
00415                 shape.
00416     SeeAlso:    
00417 
00418 ********************************************************************************************/
00419 
00420 class OpPasteEnvelope: public OpPasteMouldShape
00421 {
00422     CC_DECLARE_DYNCREATE( OpPasteEnvelope )    
00423 
00424     public:
00425         OpPasteEnvelope();                              
00426         static BOOL     Init();             
00427         static OpState  GetState(String_256*, OpDescriptor*);       
00428         void            GetOpName(String_256* OpName);
00429         void            Do(OpDescriptor*);  
00430 };
00431 
00432 
00433 
00434 /********************************************************************************************
00435 
00436 >   class OpPastePerspective : public OpPasteMouldShape
00437 
00438     Author:     Mike_Kenny (Xara Group Ltd) <camelotdev@xara.com>
00439     Created:    18/01/95
00440     Purpose:    An undoable operation to paste the contents of the clipboard as a mould
00441                 shape.
00442     SeeAlso:    
00443 
00444 ********************************************************************************************/
00445 
00446 class OpPastePerspective: public OpPasteMouldShape
00447 {
00448     CC_DECLARE_DYNCREATE( OpPastePerspective )    
00449 
00450     public:
00451         OpPastePerspective();                               
00452         static BOOL     Init();             
00453         static OpState  GetState(String_256*, OpDescriptor*);       
00454         void            GetOpName(String_256* OpName);
00455         void            Do(OpDescriptor*);  
00456 };
00457 
00458 
00459 /********************************************************************************************
00460 
00461 >   class OpToggleMouldGrid : public Operation
00462 
00463     Author:     Mike_Kenny (Xara Group Ltd) <camelotdev@xara.com>
00464     Created:    18/01/95
00465     Purpose:    An operation to turn a particular moulds grid on and off
00466     SeeAlso:    -
00467 
00468 ********************************************************************************************/
00469 
00470 class OpToggleMouldGrid: public Operation
00471 {
00472     CC_DECLARE_DYNCREATE( OpToggleMouldGrid )    
00473 
00474     public:
00475         OpToggleMouldGrid();                                
00476         static BOOL     Init();             
00477         static OpState  GetState(String_256*, OpDescriptor*);       
00478         void            Do(OpDescriptor*);  
00479 };
00480 
00481 
00482 /********************************************************************************************
00483 
00484 >   class OpDetachMould : public UndoableOperation
00485 
00486     Author:     Mike_Kenny (Xara Group Ltd) <camelotdev@xara.com>
00487     Created:    18/01/95
00488     Purpose:    An operation to attach and detach a mould manifold from its object
00489                 This allows the manifold to be edited on its own without the moulded objects
00490                 following. Handy for quick edits.
00491     SeeAlso:    -
00492 
00493 ********************************************************************************************/
00494 
00495 class OpDetachMould: public UndoableOperation
00496 {
00497     CC_DECLARE_DYNCREATE( OpDetachMould )    
00498 
00499     public:
00500         OpDetachMould();                                
00501         static BOOL     Init();             
00502         static OpState  GetState(String_256*, OpDescriptor*);       
00503         void            GetOpName(String_256* OpName);
00504         void            Do(OpDescriptor*);
00505 };
00506 
00507 /********************************************************************************************
00508 
00509 >   class OpRoateMould : public OpMouldLib
00510 
00511     Author:     Mike_Kenny (Xara Group Ltd) <camelotdev@xara.com>
00512     Created:    18/01/95
00513     Purpose:    An operation to rotate a set of objects within a mould manifold.
00514                 The op simply changes the start point of a mould path object by rotating
00515                 it around one logical element. The result is simply to spin the orientation
00516                 of the moulded objects within the mould shape.
00517     SeeAlso:    -
00518 
00519 ********************************************************************************************/
00520 
00521 class OpRotateMould: public OpMouldLib
00522 {
00523     CC_DECLARE_DYNCREATE( OpRotateMould )
00524 
00525     public:
00526         OpRotateMould();                                
00527         static BOOL     Init();             
00528         static OpState  GetState(String_256*, OpDescriptor*);       
00529         void            Do(OpDescriptor*);  
00530         void            GetOpName(String_256* OpName);
00531 };
00532 
00533 
00534 
00535 /***********************************************************************************************
00536 
00537 >   class MouldBecomeA: public BecomeA
00538 
00539     Author:     Mike_Kenny (Xara Group Ltd) <camelotdev@xara.com>
00540     Created:    09/02/95
00541     Purpose:    This is the class that is passed to other nodes when the mould tool is trying
00542                 to turn them into other types via their DoBecomeA() method
00543 
00544 ***********************************************************************************************/
00545 
00546 class MouldBecomeA : public BecomeA
00547 {
00548     CC_DECLARE_MEMDUMP(MouldBecomeA);
00549 
00550     public:
00551         virtual ~MouldBecomeA();
00552 
00553         MouldBecomeA(BecomeAReason Reason,
00554                      CCRuntimeClass* pClass,
00555                      UndoableOperation* pOp) : BecomeA(Reason,pClass,pOp) {pNodePath=NULL;};
00556 
00557         // This function should be called when Reason == BECOMEA_PASSBACK 
00558         virtual BOOL PassBack(  NodeRenderableInk* pNewNode, 
00559                                 NodeRenderableInk* pCreatedByNode,
00560                                 CCAttrMap* pAttrMap);
00561 
00562         NodePath* GetMouldPath() const { return pNodePath; }
00563     
00564     protected:
00565         void Destroy();
00566 
00567     private:
00568         NodePath* pNodePath;
00569 
00570 };
00571 
00572 
00573 /********************************************************************************************
00574 
00575 >   class OpRectangularEnvelope : public OpMouldLibSel
00576 
00577     Author:     Mike_Kenny (Xara Group Ltd) <camelotdev@xara.com>
00578     Created:    1/6/95
00579     Purpose:    Simple operations to handle the creation of default envelope and perspective
00580                 shapes.
00581     SeeAlso:    -
00582 
00583 ********************************************************************************************/
00584 
00585 class OpRectangularEnvelope: public OpMouldLibSel
00586 {
00587     CC_DECLARE_DYNCREATE( OpRectangularEnvelope )
00588 
00589     public:
00590         OpRectangularEnvelope();                                
00591         static BOOL     Init();             
00592         static OpState  GetState(String_256*, OpDescriptor*);       
00593         void            Do(OpDescriptor*);  
00594         void            GetOpName(String_256* OpName);
00595 };
00596 
00597 /********************************************************************************************
00598 
00599 >   class OpRectangularPerspective : public OpMouldLibSel
00600 
00601     Author:     Mike_Kenny (Xara Group Ltd) <camelotdev@xara.com>
00602     Created:    1/6/95
00603     Purpose:    Simple operations to handle the creation of default envelope and perspective
00604                 shapes.
00605     SeeAlso:    -
00606 
00607 ********************************************************************************************/
00608 
00609 class OpRectangularPerspective: public OpMouldLibSel
00610 {
00611     CC_DECLARE_DYNCREATE( OpRectangularPerspective )
00612 
00613     public:
00614         OpRectangularPerspective();                             
00615         static BOOL     Init();             
00616         static OpState  GetState(String_256*, OpDescriptor*);       
00617         void            Do(OpDescriptor*);  
00618         void            GetOpName(String_256* OpName);
00619 };
00620 
00621 
00622 #endif      // INC_MOULDTOOL

Generated on Sat Nov 10 03:47:41 2007 for Camelot by  doxygen 1.4.4