bevtool.h

Go to the documentation of this file.
00001 // $Id: bevtool.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 // The FreeHand Tool
00099 // Created by Rik on 2/9/93
00100 
00101 
00102 
00103 #ifndef INC_BEVELTOOL
00104 #define INC_BEVELTOOL
00105 
00106 #ifdef BUILDSHADOWS
00107 
00108 //#include "tool.h" - in camtypes.h [AUTOMATICALLY REMOVED]
00109 //#include "selop.h" - in camtypes.h [AUTOMATICALLY REMOVED]
00110 //#include "doccoord.h" - in camtypes.h [AUTOMATICALLY REMOVED]
00111 #include "wrkrect.h"
00112 //#include "binds.h" - in camtypes.h [AUTOMATICALLY REMOVED]
00113 #include "bevinfo.h"
00114 //#include "clikmods.h" - in camtypes.h [AUTOMATICALLY REMOVED]
00115 #include "dragtool.h"
00116 
00117 class Cursor;
00118 class BevelInfoBarOp;
00119 class NodeBevelController;
00120 class OpDragCreateBevel;
00121 class AttrJoinType;
00122 
00123 #define OPTOKEN_DRAGBEVEL _T("DragBevel")
00124 
00125 /********************************************************************************************
00126 
00127 >   class OpDragBevel : public SelOperation
00128 
00129     Author:     David_McClarnon (Xara Group Ltd) <camelotdev@xara.com>
00130     Created:    26/8/99
00131     Purpose:    Copy of the blend nodes operation in blndtool.h
00132 
00133 ********************************************************************************************/
00134 
00135 class OpDragBevel : public SelOperation
00136 {
00137 CC_DECLARE_DYNCREATE(OpDragBevel);
00138 
00139 public:
00140     // Construction/Destruction
00141     OpDragBevel();                     
00142     ~OpDragBevel();
00143 
00144     // The all important Do functions
00145     BOOL DoDrag(BevelInfoBarOp * pOp, DocCoord & PointerPos, BOOL bDragOnBlob,
00146         DocRect *pBlobRect = NULL);
00147     virtual BOOL SnappingDrag() { return FALSE; }
00148     
00149     // Virtual functions needed for the dragging operations to work
00150     virtual void DragPointerMove( DocCoord PointerPos, ClickModifiers ClickMods, Spread*, BOOL bSolidDrag);
00151     virtual void DragFinished(  DocCoord PointerPos, 
00152                                 ClickModifiers ClickMods, Spread*, 
00153                                 BOOL Success, BOOL bSolidDrag);
00154 
00155     // sets up the dragging information necessary to render the drag blobs
00156     BOOL SetupDragInfo();
00157 
00158     // Some Render functions to will draw the EORed drag box
00159     void RenderDragBlobs(INT32 Width,Spread* pSpread,BOOL bKeepDirections=FALSE);
00160 
00161     // Some Render functions to will draw the EORed drag box
00162     void RenderDragBlobs(DocRect Rect,Spread* pSpread, BOOL bSolidDrag);
00163         
00164     // These functions required for the OpDescriptor class
00165     static BOOL Declare();
00166     static OpState GetState(String_256* Description, OpDescriptor*);
00167 
00168     void GetOpName(String_256* OpName);
00169 
00170 private:
00171     
00172     BevelInfoBarOp * m_pBarOp;
00173 
00174     BOOL m_bHasDragged;
00175     DocCoord m_LastPointerPos;
00176     DocCoord m_ThisPointerPos;
00177 
00178     DocRect m_BlobRect;
00179 
00180     // the selection's inside bounding rect to be contoured
00181     DocRect m_SelRect;
00182 
00183     // the summed path of all nodes
00184     Path * m_pPathList;
00185     UINT32 m_NumPaths;
00186     LineWidthAttribute** m_pPathLineWidthList; // MRH
00187 
00188     // whether each path is inner or outer
00189     BOOL * m_pPathOuterList;
00190 
00191     // the start indexes of paths which are to be summed together
00192     UINT32 * m_pSetList;
00193     UINT32 m_NumSets;
00194 
00195     BOOL m_bDragStartedOnBlob;
00196 
00197 //  INT32 m_Flatness;
00198     double m_Flatness;
00199 
00200     JointType m_JoinType;
00201 
00202     // Karim 11/05/2000
00203     // Tests whether a specific node should have its outline taken into account when
00204     // the user drags a bevel.
00205     BOOL NodeCanBeDragBevelled(Node* pSubNode, Node* pNode, BOOL bBevelNodesExist);
00206 
00207     void AlterPointerPosToAccountForBlob(DocCoord * pPoint);
00208 
00209     // in dragging, we have the starting width and also the calculated width
00210     // from the pointers starting position. Thus, when dragging we calculate the
00211     // offset of the pointer from the original starting drag width, and apply
00212     // this offset to the original width to give the width to render the drag blobs
00213     // to.
00214     
00215     // the starting width to use
00216     MILLIPOINT m_OriginalWidth;
00217 
00218     // the starting drag width to use when calculating the offset of the pointer
00219     MILLIPOINT m_StartDragWidth;
00220 
00221 
00222 };
00223 
00224 /********************************************************************************************
00225 >   class BevelBlob : public ListItem
00226 
00227     Author:     David_McClarnon (Xara Group Ltd) <camelotdev@xara.com>
00228     Created:    10/3/99
00229     Purpose:    It renders the bevel tool blob (i,e, light angle) per attribute
00230 ********************************************************************************************/
00231 
00232 class BevelBlob : public ListItem
00233 {
00234 CC_DECLARE_MEMDUMP(BevelBlob);
00235 public:
00236     BevelBlob();
00237     ~BevelBlob();
00238 
00239     // adds an attribute to my list
00240     BOOL AddNode(NodeBevelController * pAttr);
00241 
00242     // access functions
00243     // sets the angle for the blob and also sets all the angles in my bevel controller
00244     // list's angles too, if SetList is TRUE
00245     void SetAngle(INT32 Angle, BOOL bSetList = TRUE);
00246     void SetTilt(INT32 Angle, BOOL bSetList = TRUE);
00247 
00248     INT32  GetAngle()                        { return m_BlobAngle;  }
00249     BOOL AmDragging()                    { return m_bDragging;  }
00250 
00251     // blob rendering stuff
00252     void RenderBlob(RenderRegion* pRegion);
00253 
00254     DocRect GetRect()                { return m_BevelNodeListRect; }
00255 
00256     // checks the attributes to see if I'm still valid
00257     BOOL IsBlobValid();
00258 
00259     // returns TRUE for a click on my blob
00260     BOOL HitTest(const DocCoord &dc);
00261 
00262     // calculates my angle depending on the given doc-coord
00263     // used to do drags
00264     void CalculateAngle(const DocCoord &dc, BOOL Constrain = FALSE);
00265 
00266     List * GetList() { return &m_BevelNodeList; }
00267 
00268     // renders the nodes with the given light angle (used in dragging)
00269     void RenderNodes();
00270 
00271     // changes the contrast variables for all the nodes in the list
00272     void ChangeContrast(INT32 NewContrast);
00273 
00274 protected:
00275     // list of the attributes that I affect
00276     List m_BevelNodeList;
00277 
00278 private:
00279     INT32 m_BlobAngle;
00280     DocRect m_BevelNodeListRect;
00281     DocRect m_BlobDocRect;
00282     DocCoord m_BlobCentre;
00283     BOOL m_bDragging;
00284 } ;
00285 
00286 /********************************************************************************************
00287 >   class BevelTool : public Tool_v1
00288 
00289     Author:     David_McClarnon (Xara Group Ltd) <camelotdev@xara.com>
00290     Created:    9/1/99
00291     Purpose:    Handles the bevelling tool
00292 ********************************************************************************************/
00293 
00294 class CCAPI BevelTool : public DragTool
00295 {
00296 // Give my name in memory dumps
00297 CC_DECLARE_MEMDUMP(BevelTool);
00298 
00299 public:
00300     BevelTool();
00301     ~BevelTool();
00302     BOOL Init();
00303     void Describe(void* InfoPtr);
00304     UINT32 GetID();
00305     
00306     // Event Handlers
00307     virtual void SelectChange(BOOL);
00308     virtual void OnClick( DocCoord, ClickType, ClickModifiers, Spread* );
00309     virtual void OnMouseMove(DocCoord Pos, Spread* pSpread, ClickModifiers ClickMods);
00310     virtual BOOL GetStatusLineText(String_256* ptext, Spread*, DocCoord, ClickModifiers);
00311 
00312     // Rendering the blobs functions
00313     virtual void RenderToolBlobs(Spread*, DocRect*);
00314 
00315     // renders a single blob (EORed)
00316     void RenderBlob(BevelBlob * pBlob);
00317 
00318     // makes sure the blob list is regenerated on the next RenderToolBlobsOn
00319     void RegenerateBlobsOnNextRender() { m_bRegenBlobsOnNextRender = TRUE; }
00320 
00321     // removes the blobs which exist, re-sets up the blob list and re-renders them
00322     void InvalidateToolBlobs();
00323 
00324     void SetupSelectionBlobs();
00325 
00326     // clears the tool's blob list
00327     void ClearToolBlobList() { m_BevelBlobList.DeleteAll(); }
00328     
00329     // sets all the tool blob angles (removes the blobs & then re-renders them with
00330     // the new angle - used by the info bar for the light angle slider changing)
00331     void ChangeBlobAngles(INT32 Angle);
00332     void ChangeBlobTilts(INT32 Tilt);
00333 
00334     static BOOL AmActive() { return m_bActive; }
00335 
00336     DocRect GetBlobRect() { return m_BlobListBounds; }
00337 
00338     BOOL AreToolBlobsRenderedOnSelection();
00339 
00340     // clears and then re-sets up the list of blobs
00341     // returns FALSE for no selection
00342     BOOL SetupBlobList();
00343 
00344     // this selects bevel controller nodes if just the children are selected (like
00345     // if the user has just a text object selected, but not its parent controller)
00346     // needs to be public otherwise the infobar can't use it
00347     void DoSelectBevelNodesFromChildren();
00348 
00349     // access functions to the blob list to tell if 'many' should be displayed
00350     // for particular attributes in multiple selections
00351     BOOL AreManyBevelTypes();
00352     BOOL AreManyBevelDirections();
00353     BOOL AreManyBevelIndents();
00354     BOOL AreManyBevelContrasts();
00355     BOOL AreManyBevelLightAngles();
00356     BOOL AreManyBevelLightTilts();
00357 
00358     static void DisplayStatusBarHelp(UINT32 StatusIDX);
00359 
00360     // re-renders the bevel nodes when a contrast change occurs - used in interactive dragging
00361     void ChangeContrastAndReRender(INT32 NewContrast);
00362 
00363     INT32 CalculateBevelWidth(DocRect &Rect, DocCoord &PointerPos);
00364 
00365     // static drag bevel op
00366     static OpDragBevel *m_pDragBevelOp;
00367 
00368     // enables/disables blob rendering
00369     void SetBlobRendering(BOOL b)
00370     {
00371         if (b)
00372             m_bDisableBlobRendering = FALSE;
00373         else
00374             m_bDisableBlobRendering = TRUE;
00375     }
00376 
00377 protected:
00378     // Helper functions
00379     // Functions to load, remove and change the active cursor
00380     BOOL LoadCursors();
00381     void RemoveCursors();
00382     void ChangeCursor(Cursor* pCursor);
00383 
00384 protected:
00385     static  TCHAR* FamilyName;  // The Tools Family Name
00386     static  TCHAR* ToolName;        // The Tool Name
00387     static  TCHAR* Purpose;     // What the tool is for
00388     static  TCHAR* Author;      // Who wrote it
00389 
00390     // The status line text
00391     String_256 StatusMsg;
00392 
00393     // The tools cursor
00394     Cursor* pNormalCursor;              // The normal cursor
00395     Cursor* pActiveCursor;              // The normal cursor
00396     Cursor* pMouseOverCursor;           // The selection cursor (for arrow blobs)
00397     Cursor* pSizeCursor;                // The selection cursor (for size blobs)
00398     INT32 CurrentCursorID;              // ID of the current cursor on the stack
00399 
00400     static BevelInfoBarOp * pBevelInfoBarOp; // my info bar
00401 
00402     // the list of blobs
00403     List m_BevelBlobList;
00404 
00405     DocRect m_BlobListBounds;
00406 
00407     // recalculates the bounding rects of selected nodes inside of the document
00408     void RecalculateSelectionBoundingBoxes(BOOL bForceRedraw=TRUE);
00409 
00410     static BOOL m_bActive;
00411 
00412     BOOL m_bRegenBlobsOnNextRender;
00413 
00414     FIXED16 m_LastZoom;
00415 
00416     BOOL m_bDisableBlobRendering;
00417 private:
00418 
00419     // Status line text ID
00420     static UINT32   StatusID;
00421 
00422     // the blobs' coordinates for drag create bevels or changing bevel widths
00423     DocCoord m_BlobPoints[8];
00424 
00425     // returns TRUE if the point is over a selection blob
00426     BOOL IsPointOverSelectionBlob(DocCoord &Point, DocRect * pRect);
00427 
00428     void InformWarningContourExistsInSelection();
00429 
00430 };
00431 
00432 #endif  //INC_FREEHAND
00433 #endif
00434 
00435 
00436 

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