cntrtool.h

Go to the documentation of this file.
00001 // $Id: cntrtool.h 1386 2006-06-28 17:49:55Z 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 blend tool implementation
00099 
00100 #ifndef INC_CONTOURTOOL
00101 #define INC_CONTOURTOOL
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 "blendatt.h"
00107 //#include "selop.h" - in camtypes.h [AUTOMATICALLY REMOVED]
00108 #include "biasgdgt.h"
00109 //#include "iprofile.h" - in camtypes.h [AUTOMATICALLY REMOVED]
00110 //#include "becomea.h" - in camtypes.h [AUTOMATICALLY REMOVED]
00111 #include "bevtrap.h"
00112 #include "dragtool.h"
00113 
00114 class ContourTool;
00115 class ContourInfoBarOp;
00116 class AttrJoinType;
00117 class BlendToolRef;
00118 
00119 #define OPTOKEN_CONTOURNODES _T("ContourNode")
00120 
00121 //-----------------------------------------------------------------
00122 //-----------------------------------------------------------------
00123 //-----------------------------------------------------------------
00124 //-----------------------------------------------------------------
00125 
00126 /********************************************************************************************
00127 
00128 >   class OpContourNodes : public SelOperation
00129 
00130     Author:     David_McClarnon (Xara Group Ltd) <camelotdev@xara.com>
00131     Created:    26/8/99
00132     Purpose:    Copy of the blend nodes operation in blndtool.h
00133 
00134 ********************************************************************************************/
00135 
00136 class OpContourNodes : public SelOperation
00137 {
00138 CC_DECLARE_DYNCREATE(OpContourNodes);
00139 
00140 public:
00141     // Construction/Destruction
00142     OpContourNodes();                     
00143     ~OpContourNodes();
00144 
00145     // The all important Do functions
00146     BOOL DoDrag(ContourTool * pTool, ContourInfoBarOp * pOp, DocCoord & PointerPos, BOOL bDragOnBlob,
00147         DocRect * pBlobRect = NULL);
00148     virtual BOOL SnappingDrag() { return FALSE; }
00149     
00150     // Virtual functions needed for the dragging operations to work
00151     virtual void DragPointerMove( DocCoord PointerPos, ClickModifiers ClickMods, Spread*, BOOL bSolidDrag);
00152     virtual void DragFinished(  DocCoord PointerPos, 
00153                                 ClickModifiers ClickMods, Spread*, 
00154                                 BOOL Success, BOOL bSolidDrag);
00155 
00156     // sets up the dragging information necessary to render the drag blobs
00157     BOOL SetupDragInfo();
00158 
00159     // Some Render functions to will draw the EORed drag box
00160     void RenderDragBlobs(INT32 Width,Spread* pSpread,BOOL bKeepDirections=FALSE);
00161 
00162     // Some Render functions to will draw the EORed drag box
00163     void RenderDragBlobs(DocRect Rect,Spread* pSpread, BOOL bSolidDrag);
00164         
00165     // These functions required for the OpDescriptor class
00166     static BOOL Declare();
00167     static OpState GetState(String_256* Description, OpDescriptor*);
00168 
00169     void GetOpName(String_256* OpName);
00170 
00171     
00172 private:
00173     
00174     ContourTool * m_pTool;
00175     ContourInfoBarOp * m_pBarOp;
00176 
00177     BOOL m_bHasDragged;
00178     DocCoord m_LastPointerPos;
00179     DocCoord m_ThisPointerPos;
00180     
00181     // the rect of the blob which has been clicked on
00182     DocRect m_BlobRect;
00183 
00184     // the selection's inside bounding rect to be contoured
00185     DocRect m_SelRect;
00186 
00187     // the summed path of all nodes
00188     Path * m_pPathList;
00189     UINT32 m_NumPaths;
00190 
00191     // whether each path is inner or outer
00192     BOOL * m_pPathOuterList;
00193     AttrJoinType ** m_pPathJoinTypeList;
00194     JointType m_JoinType;
00195 
00196     // the start indexes of paths which are to be summed together
00197     UINT32 * m_pSetList;
00198     UINT32 m_NumSets;
00199 
00200     BOOL m_bDragStartedOnBlob;
00201 
00202     // the flatness to use - calculated in the setup depending on the active view
00203     INT32 m_Flatness;
00204 
00205     // Karim 10/05/2000
00206     // Tests whether a specific node should have its outline taken into account when
00207     // the user drags a contour.
00208     BOOL NodeCanBeDragContoured(Node* pSubNode, Node* pNode, BOOL bContourNodesExist);
00209 
00210     // alters pPoint to account for the fact that blobs always have the same value
00211     void AlterPointerPosToAccountForBlob(DocCoord * pPoint);
00212 
00213     // in dragging, we have the starting width and also the calculated width
00214     // from the pointers starting position. Thus, when dragging we calculate the
00215     // offset of the pointer from the original starting drag width, and apply
00216     // this offset to the original width to give the width to render the drag blobs
00217     // to.
00218     
00219     // the starting width to use
00220     MILLIPOINT m_OriginalWidth;
00221 
00222     // the starting drag width to use when calculating the offset of the pointer
00223     MILLIPOINT m_StartDragWidth;
00224 
00225 };
00226 
00227 /********************************************************************************************
00228 
00229 >   class ContourTool : public Tool_v1
00230 
00231     Author:     David_McClarnon (Xara Group Ltd) <camelotdev@xara.com> Mc
00232     Created:    4/10/94
00233     Purpose:    The Contour tool class
00234     Notes:      Copied from the blend tool
00235 
00236 ********************************************************************************************/
00237 
00238 class CCAPI ContourTool : public DragTool
00239 {
00240 // Give tool name in memory dumps
00241 CC_DECLARE_MEMDUMP(ContourTool);
00242 
00243 public:
00244     ContourTool();
00245     ~ContourTool();
00246 
00247     // Standard calls your tool must provide
00248     BOOL Init();
00249     void Describe(void* InfoPtr);
00250     UINT32 GetID() { return TOOLID_CONTOURTOOL; };
00251     
00252     // Some very common event handlers
00253     void SelectChange(BOOL isSelected);
00254     void OnClick( DocCoord, ClickType, ClickModifiers, Spread* );
00255     void OnMouseMove(DocCoord PointerPos,Spread* pSpread,ClickModifiers ClickMods);
00256     void RenderToolBlobs(Spread* pSpread,DocRect* pDocRect);
00257     BOOL GetStatusLineText(String_256* ptext, Spread*, DocCoord, ClickModifiers);
00258     BOOL OnKeyPress(KeyPress* pKeyPress);
00259 
00260     // Some useful static functions
00261     static ContourInfoBarOp*    GetContourInfoBarOp()   { return pContourInfoBarOp; }
00262     static BOOL             IsCurrent();
00263     static void             DisplayStatusBarHelp(UINT32 StatusID);
00264 
00265     static BlendToolRef*    GetPtrRefStart()    { return pRefStart; }
00266     static BlendToolRef*    GetPtrRefEnd()      { return pRefEnd; }
00267 
00268     static void UpdateRef(BlendToolRef* pRef,Spread* pSpread, DocCoord PointerPos,BOOL CheckNodeUnderPoint = TRUE);
00269     static void UpdateCursorAndStatus();
00270     static void CheckNodeRemapping(BlendToolRef* pRefStart, BlendToolRef* pRefEnd);
00271 
00272     static INT32 CalculateContourWidth(DocRect &br, DocCoord &PointerPos);
00273     static INT32 CalculateContourWidth(Node * pNode, DocCoord &PointerPos);
00274 
00275     BOOL AreToolBlobsRenderedOnSelection() { return TRUE; }
00276 
00277     void SetupToolBlobs();
00278 
00279     // TRUE for enable, FALSE for disable
00280     void SetBlobRendering(BOOL b) 
00281     { 
00282         if (b) 
00283             m_bDisableBlobRenderingFlag = FALSE;
00284         else
00285             m_bDisableBlobRenderingFlag = TRUE;
00286     }
00287 
00288     // static drag operation
00289     // public so the info bar can use it to do drag rendering
00290     static OpContourNodes *m_pOpContourNodes;
00291 
00292 private:
00293     // Private blend tool functions
00294     static NodeRenderableInk*   FindObject(Spread* pSpread, DocCoord ClickPos);
00295     static BOOL                 IsPointOverPathBlob(DocCoord* pPointerPos,BlendToolRef* pRef);
00296     static BOOL                 IsPointOverBlendBlob(DocCoord* pPointerPos,BlendToolRef* pRef);
00297 
00298     BOOL CreateCursors();                       // Create your tool's cursors in this func
00299     void DestroyCursors();                      // Destroys all blend tool cursors
00300 
00301     static ContourInfoBarOp*    pContourInfoBarOp;  // Ptr to your tool's infobar
00302 
00303     // Cursors
00304     static Cursor*  pcNormalCursor;                     // Your standard cursor to use when your tool becomes active
00305     static Cursor*  pcOverBlob;                         // cursor when I'm over a blob
00306     
00307     static Cursor*  pcCurrentCursor;                    // The cursor your tool is currently displaying
00308     static INT32        CurrentCursorID;                    // The ID of our current cursor on the stack
00309 
00310     // Status line text ID
00311     static UINT32   StatusID;
00312 
00313     // Data gathered during clicking and dragging
00314     static BlendToolRef *pRefStart;
00315     static BlendToolRef *pRefEnd;
00316 
00317     // Standard tool static vars
00318     static  TCHAR* FamilyName;              // The Tools Family Name
00319     static  TCHAR* ToolName;                    // The Tool Name
00320     static  TCHAR* Purpose;                 // What the tool is for
00321     static  TCHAR* Author;                  // Who wrote it
00322 
00323     // the blobs' coordinates for dragging
00324     DocCoord m_BlobPoints[8];
00325     
00326     // returns TRUE for whether a point is over a blob
00327     BOOL IsPointOverBlob(DocCoord &Point, DocRect *pBlobRect = NULL);
00328 
00329     BOOL m_bDisableBlobRenderingFlag;
00330     void InformWarningBevelExistsInSelection();
00331 };
00332 
00333 
00334 //-----------------------------------------------
00335 //-----------------------------------------------
00336 //-----------------------------------------------
00337 //-----------------------------------------------
00338 
00339 
00340 /********************************************************************************************
00341 
00342 >   class ContourInfoBarOp : public InformationBarOp
00343 
00344     Author:     Mark_Neves (Xara Group Ltd) <camelotdev@xara.com>
00345     Created:    4/10/94   changed 16/9/99 Diccon Yamanaka
00346     Purpose:    Class for handling the tool's information bar.
00347 
00348 ********************************************************************************************/
00349 
00350 class ContourInfoBarOp : public InformationBarOp
00351 {
00352     CC_DECLARE_DYNCREATE( ContourInfoBarOp )
00353 public:
00354     ContourInfoBarOp() 
00355     {   
00356         DlgResID = _R(IDD_CONTOURINFOBAR);
00357         m_DetachBlendPath = FALSE; 
00358         m_EditBlendSteps = TRUE; 
00359         m_BlendAntiAlias = TRUE; 
00360         m_OneToOne = FALSE; 
00361         m_Tangential = FALSE; 
00362         m_BlendedOnCurve = FALSE;
00363         m_bUpdateState = TRUE; 
00364         m_pTool = NULL;
00365         m_bDragging = FALSE;
00366         m_LastDragWidth = 0;
00367         m_bInsetPath = FALSE;
00368         m_bOuterIsSelected = TRUE;
00369     }
00370 
00371     virtual void UpdateState();     // Overrides the empty function in InformationBarOp
00372 
00373     MsgResult   Message(Msg* Msg);  // All messages to the info bar come through here
00374 
00375     // sets the slider & the edit control values
00376     void SetSliderValue(UINT32 Width, BOOL bMany);
00377 
00378     // enables or diables the update state message
00379     void SetUpdateState(BOOL bUpdateState) { m_bUpdateState = bUpdateState; }
00380 
00381     ContourTool * m_pTool;
00382 
00383     BOOL m_BetweenViews; // added sjk 22/11/00 to stop extra msgs between view changes
00384 
00385 private:
00386 
00387     void ChangeBitmapButtonState(CGadgetID GadgetID, BOOL* CurrentState); //DY 13/9/99 function to change the state of a bitmap button, 
00388     void InitialiseObjectGainGadget(CGadgetID GadgetID, UINT32 BubbleID, UINT32 StatusID)
00389     {
00390              m_BiasGainObjectGadget.Init(this, GadgetID, BubbleID, StatusID);   // DY 16/9/99
00391     };
00392     
00393     void InitialiseAttrGainGadget(CGadgetID GadgetID, UINT32 BubbleID, UINT32 StatusID)
00394     {
00395         m_BiasGainAttrGadget.Init(this, GadgetID, BubbleID, StatusID);
00396     };   // DY 16/9/99
00397     
00398     void ChangeProfile(CProfileBiasGain* Profile, CGadgetID GadgetID);
00399     void ChangeProfileOnIdle(CProfileBiasGain* Profile, CGadgetID GadgetID);
00400 
00401     BOOL m_DetachBlendPath;
00402     BOOL m_EditBlendSteps;   //DY 13/9/99 this is really ugly but I can't get 
00403                              // get any sense out of interrogating the 
00404                               // gadgets directly
00405     BOOL m_BlendAntiAlias;
00406     BOOL m_OneToOne;
00407     BOOL m_Tangential;
00408     BOOL m_BlendedOnCurve;
00409 
00410     Spread* m_BlobsSpread;
00411 public:
00412 
00413     CBiasGainGadget  m_BiasGainObjectGadget;  // the profile gadget added 16/9/99
00414     CBiasGainGadget  m_BiasGainAttrGadget;  // the profile gadget added 16/9/99
00415 
00416     BOOL GetInsetPathFlag() { return m_bInsetPath; }
00417 
00418 private:
00419     
00420     // whether the inner, outer or neither of the two buttons are selected
00421     BOOL m_bOuterIsSelected;
00422     BOOL m_bInnerIsSelected;
00423 
00424     void DealWithContourOuterClick();
00425     void DealWithContourInnerClick();
00426     void DealWithWidthChange(UINT32 Width);
00427     void DealWithInsetPathClick();
00428 
00429     BOOL ConvertValueToString(String_256 &In, const INT32 value, UnitType type=NOTYPE);
00430     BOOL ConvertStringToValue(CGadgetID ID,INT32 &value);
00431 
00433     // Karim 11/09/2000
00434     // New methods to support the new join-type infobar buttons.
00435 
00436     void HandleJoinTypeMitreClicked();
00437     void HandleJoinTypeRoundClicked();
00438     void HandleJoinTypeBevelClicked();
00439     void ChangeJoinType(JointType jt);
00440     void UpdateJoinTypeControls();
00441     void EnableDisableJoinTypeControls();
00442 
00444 
00445     CProfileBiasGain* GetProfileFromSelection (CGadgetID ProfileGadgetID, BOOL* bMany, BOOL* bAllSameType);
00446 
00447     // enables the update state message
00448     BOOL m_bUpdateState;
00449 
00450     // whether we are dragging or not
00451     BOOL m_bDragging;
00452 
00453     // the last width which the blobs were rendered with so we can hence remove them
00454     MILLIPOINT m_LastDragWidth;
00455 
00456     // functions to get & retrieve the value in the logaritmic slider (for widths)
00457     MILLIPOINT GetSliderLogValue();
00458     BOOL SetSliderLogValue(MILLIPOINT Width);
00459 
00460     void UpdateGadgetHelp();
00461 
00462     BOOL m_bInsetPath;
00463 
00464     BOOL CheckForBevels();
00465 };
00466 
00467 /***********************************************************************************************
00468 
00469 >   class ContourDragBecomeA : public BecomeA
00470 
00471     Author:     David_McClarnon (Xara Group Ltd) <camelotdev@xara.com> Mc
00472     Created:    2/12/99
00473     Purpose:    This is used to turn all nodes which are to be contoured into a single path for
00474                 dragging
00475 
00476 ***********************************************************************************************/
00477 class ContourDragBecomeA : public BecomeA
00478 {
00479 public:
00480     // constructor
00481     ContourDragBecomeA(BecomeAReason Reason,
00482                     CCRuntimeClass* pClass, 
00483                     UndoableOperation* pOp, 
00484                     BOOL Sel,
00485                     Path * pPathList,
00486                     UINT32 NumPaths,
00487                     BOOL IncludeLineWidths = FALSE) : BecomeA(Reason, pClass, pOp, Sel)
00488     {
00489         m_pPathList = pPathList;
00490         m_NumPaths = NumPaths;
00491         m_Count = 0;
00492         m_IncludeLineWidths = IncludeLineWidths;
00493 
00494         // we're only interested in the silhouette.
00495         fSilhouette = TRUE;
00496     }
00497 
00498     // passback function
00499     virtual BOOL PassBack(NodeRenderableInk* pNewNode,NodeRenderableInk* pCreatedByNode,
00500         CCAttrMap* pAttrMap);
00501 
00502 //  UINT32 GetCount() { return m_Count; }
00503 
00504 private:
00505 
00506     // path list
00507     Path * m_pPathList;
00508 
00509     // number of paths
00510     UINT32 m_NumPaths;
00511     
00512     // count variable to keep track of which path we're currently addressing
00513 //  UINT32 m_Count;
00514 
00515     BOOL m_IncludeLineWidths;
00516 } ;
00517 
00518 
00519 
00520     
00521 
00522 /********************************************************************************************
00523 
00524 >   class ContourInfoBarOpCreate : public BarCreate
00525 
00526     Author:     Mark_Neves (Xara Group Ltd) <camelotdev@xara.com>
00527     Created:    4/10/94
00528     Purpose:    Class for creating ContourInfoBarOps.
00529                 Derived classes of BarCreate are used by DialogBarOp::ReadBarsFromFile()
00530 
00531 ********************************************************************************************/
00532 
00533 class ContourInfoBarOpCreate : public BarCreate
00534 {
00535 public:
00536     DialogBarOp* Create() { return (new ContourInfoBarOp); }
00537 };
00538 
00539 
00540 
00541 #endif // INC_CONTOURTOOL

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