regshape.h

Go to the documentation of this file.
00001 // $Id: regshape.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 regular shape tool implementation
00099 
00100 #ifndef INC_REGSHAPETOOL
00101 #define INC_REGSHAPETOOL
00102 
00103 //#include "bars.h" - in camtypes.h [AUTOMATICALLY REMOVED]
00104 //#include "doccoord.h" - in camtypes.h [AUTOMATICALLY REMOVED]
00105 #include "nodershp.h"
00106 #include "shapeops.h"
00107 //#include "peter.h"
00108 //#include "tool.h" - in camtypes.h [AUTOMATICALLY REMOVED]
00109 //#include "viewrc.h"
00110 #include "dragtool.h"
00111 
00112 class Cursor;
00113 class Spread;
00114 class QuickShapeBaseInfoBarOp;
00115 class EditRegularShapeParam;
00116 
00117 const INT32 MAX_EDIT_FIELD_LENGTH = 5;
00118 
00119 /********************************************************************************************
00120 
00121 >   class QuickShapeBase : public Tool_v1
00122 
00123     Author:     Peter_Arnold (Xara Group Ltd) <camelotdev@xara.com>
00124     Created:    15/11/94
00125     Purpose:    The base class for the Quick shape tool family.  Not actually a tool itself
00126                 but the QuickShape, Ellipse and Rectangle tool are derived from it.
00127 
00128 ********************************************************************************************/
00129 
00130 class CCAPI QuickShapeBase : public DragTool
00131 {
00132 CC_DECLARE_MEMDUMP(QuickShapeBase);
00133 
00134 public:
00135     QuickShapeBase();
00136     ~QuickShapeBase();
00137 
00138     // Standard calls your tool must provide
00139     BOOL Init();
00140     
00141     // Some very common event handlers
00142     void SelectChange(BOOL isSelected);
00143     void OnClick( DocCoord, ClickType, ClickModifiers, Spread* );
00144     void OnMouseMove(DocCoord PointerPos,Spread* pSpread, ClickModifiers ClickMods);
00145     BOOL GetStatusLineText(String_256* ptext, Spread* pSpread, DocCoord DocPos, ClickModifiers ClickMods);
00146 
00147     // Some useful static functions
00148     QuickShapeBaseInfoBarOp*    GetInfoBar()    { return pQuickShapeBaseInfoBarOp; }
00149 
00150     enum EditModeIDS {EDITF_CENTRE, EDITF_MAJOR, EDITF_STELLATION, EDITF_CURVE, EDITF_SIZE, EDITF_ROT};
00151     EditModeIDS EditFieldMode;
00152     EditModeIDS EditFieldOptions[MAX_EDIT_FIELD_LENGTH];
00153 
00154     // Override these to return the creation settings
00155     virtual INT32 GetNumSides() = 0;
00156     virtual INT32 GetCreationMode() = 0;
00157     virtual BOOL GetPolygon() = 0;
00158     virtual BOOL GetStellation() = 0;
00159     virtual BOOL GetCurved() = 0;
00160     virtual void SetNumSides(INT32 NewValue) = 0;
00161     virtual void SetCreationMode(INT32 NewValue) = 0;
00162     virtual void SetPolygon(BOOL NewValue) = 0;
00163     virtual void SetStellation(BOOL NewValue) = 0;
00164     virtual void SetCurved(BOOL NewValue) = 0;
00165 
00166     virtual BOOL ForcePolygonToGrey() = 0;
00167     virtual BOOL ForceEllipseToGrey() = 0;
00168     virtual BOOL ForceStellationToGrey() = 0;
00169     virtual BOOL ForceCurvatureToGrey() = 0;
00170     virtual BOOL ForceNumSidesToGrey() = 0;
00171     virtual BOOL IsInterestingShape(NodeRegularShape* pShape) = 0;
00172     virtual INT32 GetShapesToAffect() =0;
00173     virtual BOOL DoesPolygonExist() = 0;
00174     virtual BOOL DoesEllipseExist() = 0;
00175     virtual BOOL DoesStellationExist() = 0;
00176     virtual BOOL DoesCurvatureExist() = 0;
00177     virtual BOOL DoesReformSidesExist() = 0;
00178     virtual BOOL DoesNumSidesExist() = 0;
00179     virtual INT32 GetCursorID() = 0;
00180     virtual INT32 GetShapeID() = 0;
00181     virtual INT32 GetShapesID() = 0;
00182     virtual BOOL CanReformEdges() {return FALSE;};
00183 
00184     virtual BOOL IsEllipse() {return FALSE;};
00185     virtual BOOL IsRectangle() {return FALSE;};
00186 
00187 protected:
00188     void DisplayStatusBarHelp(DocCoord DocPos, Spread* pSpread, ClickModifiers ClickMods);
00189     void GetCurrentStatusLineText(String_256* ptext, Spread* pSpread, DocCoord DocPos, ClickModifiers ClickMods);
00190     ShapeClickEffect DetermineClickEffect(DocCoord PointerPos, Spread* pSpread, NodeRegularShape** ReturnShape = NULL);
00191     void ExpandShapeString(StringBase* pString, INT32 StringID, BOOL Singular);
00192 
00193     QuickShapeBaseInfoBarOp* pQuickShapeBaseInfoBarOp;  // Ptr to your tool's infobar
00194 
00195     BOOL CreateCursors();                       // Create  your tool's cursors in this func
00196     void DestroyCursors();                      // Destroy your tool's cursors in this func
00197 
00198     Cursor* pcNormalCursor;                     // Your standard cursor to use when your tool becomes active
00199     Cursor* pcBlobCursor;                       // The cursor to display over shape blobs
00200     Cursor* pcEdgeCursor;                       // The cursor to display over shape path edges.
00201     Cursor* pcCurrentCursor;                    // The cursor your tool is currently displaying
00202     INT32 CurrentCursorID;
00203 
00204     // DetermineClickEffect caches its last result to avoid excessive document scanning
00205     DocCoord OldDeterminePos;
00206     Spread* OldDetermineSpread;
00207     NodeRegularShape* OldDetermineShape;
00208     ShapeClickEffect OldDetermineResult;
00209 };
00210 
00211 
00212 
00213 /********************************************************************************************
00214 
00215 >   class QuickShapeBaseInfoBarOp : public InformationBarOp
00216 
00217     Author:     Peter_Arnold (Xara Group Ltd) <camelotdev@xara.com>
00218     Created:    15/11/94
00219     Purpose:    Class for handling the Regular Shape tool's information bar.
00220 
00221 ********************************************************************************************/
00222 class QuickShapeBaseInfoBarOp : public InformationBarOp
00223 {
00224     CC_DECLARE_DYNCREATE( QuickShapeBaseInfoBarOp )  
00225 
00226 public:
00227     QuickShapeBaseInfoBarOp( QuickShapeBase *pTool = NULL, ResourceID r=_R(IDD_REGSHAPETOOLBAR) )
00228     {
00229         DlgResID = r;
00230         pQuickShapeBase = pTool;
00231         ChangeMode = FALSE;
00232         CurrentSpread = NULL;
00233         BumpAmount = 0;
00234         PreviousCurvature = FALSE;
00235         PreviousStellation = FALSE;
00236         PreviousCircular = FALSE;
00237     };              // Dummy default constructor for DYNCREATE
00238 
00239     MsgResult Message(Msg* Msg);            // All messages to the info bar come through here
00240     MsgResult DialogMessage(DialogMsg* Msg);    // Handles dialogue messages aimed at the infobar
00241     BOOL InitialiseInfobar();   
00242     BOOL SetBarFromSelection(); 
00243 
00244     // Functions to read and write the infobar status.
00245     INT32       GetCreationMode();
00246     void    SetCreationMode(INT32 NewMode);
00247 
00248     // Functions to read and write the polygon/ellipse status.
00249     BOOL    IsPolygonCreate();
00250     void    SetPolygonCreate(BOOL PolygonCreate);
00251 
00252     // Functions to read/write the stellation button.
00253     BOOL    IsStellationCreate();
00254     void    SetStellationCreate(BOOL StellationCreate);
00255 
00256     // Functions to read/write the curved button
00257     BOOL    IsCurvedCreate();
00258     void    SetCurvedCreate(BOOL CurvedCreate);
00259 
00260     // Functions to read/write the number of sides edit field
00261     INT32       GetNumSides(BOOL Error);
00262     void    SetNumSides(INT32 NumberSides);
00263 
00264     // Various other functions
00265     BOOL AreShapesSelected();
00266     void SetToolMode();
00267     void UpdateInfobar();
00268     void BuildEditMenu(BOOL UpdateImmediate = FALSE);
00269     void UpdateEditFields(NodeRegularShape* ShapeToShow = NULL, Spread* ShapeSpread = NULL);
00270     BOOL SetEdit(CGadgetID gid, INT32 nValue, BOOL PaintNow);
00271     BOOL SetEditPosition(CGadgetID gidX, CGadgetID gidY, DocCoord loc, Spread* pSpread, BOOL PaintNow);
00272     BOOL EditCommit(BOOL UpperCommit);
00273     BOOL GetFieldCoord(DocCoord* pCoord, Spread* pSpread);
00274     BOOL BumpLeft();
00275     BOOL BumpRight();
00276     BOOL BumpUp();
00277     BOOL BumpDown();
00278     void SetHelp();
00279     BOOL IsEnabled(CGadgetID gid);
00280 
00281     BOOL EditCommitCentre(BOOL UpperCommit, EditRegularShapeParam* ChangeData);
00282     BOOL EditCommitSizeAndRotation(BOOL UpperCommit, EditRegularShapeParam* ChangeData);
00283     BOOL EditCommitStellation(BOOL UpperCommit, EditRegularShapeParam* ChangeData);
00284     BOOL EditCommitCurvature(BOOL UpperCommit, EditRegularShapeParam* ChangeData);
00285     BOOL EditCommitWidthAndHeight(BOOL UpperCommit, EditRegularShapeParam* ChangeData);
00286     BOOL EditCommitRotation(BOOL UpperCommit, EditRegularShapeParam* ChangeData);
00287 
00288     double RestrictAngleZero360(double Current);
00289     double RestrictAngleMinus180(double Current);
00290 
00291     // Data members
00292     QuickShapeBase* pQuickShapeBase;
00293     BOOL    ChangeMode;
00294     Spread* CurrentSpread;
00295     INT32   BumpAmount;
00296     BOOL    PreviousCurvature;
00297     BOOL    PreviousStellation;
00298     BOOL    PreviousCircular;
00299 };
00300 
00301 /********************************************************************************************
00302 
00303 >   class QuickShapeBaseInfoBarOpCreate : public BarCreate
00304 
00305     Author:     Peter_Arnold (Xara Group Ltd) <camelotdev@xara.com>
00306     Created:    3/10/94
00307     Purpose:    Class for creating RegShapeInfoBarOps.
00308                 Derived classes of BarCreate are used by DialogBarOp::ReadBarsFromFile()
00309 
00310 ********************************************************************************************/
00311 
00312 class QuickShapeBaseInfoBarOpCreate : public BarCreate
00313 {
00314 public:
00315     DialogBarOp* Create() { return (new QuickShapeBaseInfoBarOp); }
00316 };
00317 
00318 /********************************************************************************************
00319 
00320 >   class QuickShapeTool : public QuickShapeBase
00321 
00322     Author:     Peter_Arnold (Xara Group Ltd) <camelotdev@xara.com>
00323     Created:    18/03/95
00324     Purpose:    The QuickShape tool.
00325 
00326 ********************************************************************************************/
00327 
00328 class CCAPI QuickShapeTool : public QuickShapeBase
00329 {
00330 CC_DECLARE_MEMDUMP(QuickShapeTool);
00331 
00332 public:
00333     QuickShapeTool();
00334     ~QuickShapeTool();
00335 
00336     BOOL Init();
00337     void Describe(void* InfoPtr);
00338     UINT32 GetID() { return TOOLID_REGSHAPE; };
00339 
00340     // The creation mode functions
00341     INT32 GetNumSides() {return NumSides;};
00342     INT32 GetCreationMode() {return CreationMode;};
00343     BOOL GetPolygon() {return CreatePolygons;};
00344     BOOL GetStellation() {return CreateStellated;};
00345     BOOL GetCurved() {return CreateCurved;};
00346     void SetNumSides(INT32 NewValue);
00347     void SetCreationMode(INT32 NewValue);
00348     void SetPolygon(BOOL NewValue);
00349     void SetStellation(BOOL NewValue);
00350     void SetCurved(BOOL NewValue);
00351     BOOL ForcePolygonToGrey() {return FALSE;};
00352     BOOL ForceEllipseToGrey() {return FALSE;};
00353     BOOL ForceStellationToGrey() {return FALSE;};
00354     BOOL ForceCurvatureToGrey() {return FALSE;};
00355     BOOL ForceNumSidesToGrey() {return FALSE;};
00356     BOOL DoesPolygonExist() {return TRUE;};
00357     BOOL DoesEllipseExist() {return TRUE;};
00358     BOOL DoesStellationExist() {return TRUE;};
00359     BOOL DoesCurvatureExist() {return TRUE;};
00360     BOOL DoesReformSidesExist() {return TRUE;};
00361     BOOL DoesNumSidesExist() {return TRUE;};
00362     BOOL IsInterestingShape(NodeRegularShape* pShape);
00363     INT32 GetShapesToAffect() {return EditRegularShapeParam::AFFECT_ALL;};
00364     INT32 GetCursorID() {return _R(IDC_REGSHAPETOOLCURSOR);};
00365     INT32 GetShapeID() {return _R(IDS_REGSHAPE_SINGULAR);};
00366     INT32 GetShapesID() {return _R(IDS_REGSHAPE_PLURAL);};
00367     BOOL CanReformEdges() {return TRUE;};
00368 
00369     
00370 private:
00371     // Keep copies of the creation mode, etc... so when tool is deselected then reselected
00372     // the info bar is unaffected.
00373     static INT32 CreationMode;
00374     static INT32 NumSides;
00375     static BOOL CreatePolygons;
00376     static BOOL CreateStellated;
00377     static BOOL CreateCurved;
00378 
00379     // Standard tool static vars
00380     static  TCHAR* FamilyName;              
00381     static  TCHAR* ToolName;                    
00382     static  TCHAR* Purpose;                 
00383     static  TCHAR* Author;                  
00384 };
00385 
00386 
00387 
00388 #endif      // INC_REGSHAPETOOL
00389 
00390 
00391 
00392 

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