shadtool.h

Go to the documentation of this file.
00001 // $Id: shadtool.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 Shadow Tool implementation
00099 
00100 #ifndef INC_SOFTSHADOWTOOL
00101 #define INC_SOFTSHADOWTOOL
00102 
00103 #include "nodecont.h"
00104 
00105 #ifdef BUILDSHADOWS
00106 
00107 //#include "tool.h" - in camtypes.h [AUTOMATICALLY REMOVED]
00108 //#include "doccoord.h" - in camtypes.h [AUTOMATICALLY REMOVED]
00109 //#include "bars.h" - in camtypes.h [AUTOMATICALLY REMOVED]
00110 #include "shadinfo.h"
00111 #include "dragtool.h"
00112 //#include "selop.h" - in camtypes.h [AUTOMATICALLY REMOVED]
00113 #include "opliveeffects.h"
00114 
00115 class Cursor;
00116 class Spread;
00117 class SoftShadowInfoBarOp;
00118 class SoftShadowTool;
00119 class PPStackLevel;
00120 
00121 #define OPTOKEN_DRAGCREATESHADOW _T("DragCreateShadow")
00122 
00123 
00124 /********************************************************************************************
00125 
00126 >   class SoftShadowTool : public Tool_v1
00127 
00128     Author:     Olivier_Gascoin (Xara Group Ltd) <camelotdev@xara.com>
00129     Created:    29/10/96
00130     Purpose:    A template tool class
00131 
00132 ********************************************************************************************/
00133 class CCAPI SoftShadowTool : public DragTool
00134 {
00135 // Give tool name in memory dumps
00136 CC_DECLARE_MEMDUMP(SoftShadowTool);
00137 
00138 public:
00139     SoftShadowTool();
00140     ~SoftShadowTool();
00141 
00142     // Standard calls your tool must provide
00143     BOOL Init();
00144     void Describe(void* InfoPtr);
00145     UINT32 GetID() { return TOOLID_SOFTSHADOW; };   
00146     
00147     // Some very common event handlers
00148     void SelectChange(BOOL isSelected);
00149 
00150     void OnClick( DocCoord, ClickType, ClickModifiers, Spread* );
00151     void OnMouseMove(DocCoord PointerPos,Spread* pSpread, ClickModifiers ClickMods);
00152     virtual BOOL OnKeyPress(KeyPress* pKey);
00153 
00154     virtual BOOL GetStatusLineText(String_256* ptext, Spread* pSpread, DocCoord DocPos, ClickModifiers ClickMods);
00155 // Don't do anything m_pEditRange copes with changes automatically
00156 //  BOOL SelectionHasChanged() { m_iEditStackPos = STACKPOS_TOP; return TRUE; }
00157     
00158     // Some useful static functions
00159     static SoftShadowInfoBarOp*     GetSoftShadowInfoBarOp()    { return pSoftShadowInfoBarOp; }
00160     static BOOL                     IsCurrentTool()             { return CurrentTool; }
00161 
00162     void SetBlobRendering(BOOL b) { m_bBlobRendering = b; }
00163 
00164     void SetAmDragging(BOOL bDrag);
00165 
00166     BOOL AreToolBlobsRenderedOnSelection() { return TRUE; }
00167 
00168     Spread * GetSpread() 
00169     { 
00170         if (pLastBlobSpread) 
00171             return pLastBlobSpread; 
00172         else
00173             return Document::GetSelectedSpread();
00174     }
00175 
00176     ListRange*              GetShadowEditRange(NodeShadowController** ppMasterShadow = NULL);
00177     INT32                       GetShadowEditRangeStackPos() const {return m_iEditStackPos;}
00178     void                    SetShadowEditRange(ListRange* pNewRange, INT32 iNewPos, BOOL bConsistent = FALSE);
00179     NodeShadowController*   GetShadowEditField(ShadowMaskBits flags, String_256* pStrInfo = NULL);
00180     NodeShadowController*   GetShadowEditField(ShadowMaskBits flags, BOOL* pbNone, BOOL* pbConsistent, BOOL* pbMany);
00181     BOOL                    SetShadowEditRangeFromSelection(BOOL bBroadcast = FALSE);
00182     void                    SelectShadowRange(ListRange* pNewRange);
00183 
00184 protected:
00185     BOOL FigureUserFeedback(String_256* pText,      Spread* pSpread,
00186                             const DocCoord& dcPos,  ClickModifiers cMods);
00187 
00188     BOOL CreateCursors();                       // Create  your tool's cursors in this func
00189     void DestroyCursors();                      // Destroy your tool's cursors in this func
00190 
00191     static BOOL             CurrentTool;        // Can be useful to keep a "is my tool current?" flag
00192     static SoftShadowInfoBarOp* pSoftShadowInfoBarOp;   // Ptr to your tool's infobar
00193 
00194     Cursor* pcNormalSoftShadowCursor;           // the standard cursor to use when your tool becomes active
00195     Cursor* pcBlobSoftShadowCursor;             // cursor that will appear when the mouse is over one of the tool blobs
00196     Cursor* pcCurrentCursor;                    // The cursor your tool is currently displaying
00197     INT32 CurrentCursorID;                      // ID of the current cursor you're displaying
00198 
00199     // Status line text ID
00200     static UINT32   StatusID;
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     BOOL m_bBlobRendering;
00209 
00210     Spread* pLastBlobSpread;
00211 
00212     INT32           m_iEditStackPos;
00213     ListRange*  m_pEditRange;
00214 };
00215 
00216 
00217 
00218 /********************************************************************************************
00219 
00220 >   class DragCreateShadowParam : public OpParam
00221 
00222     Author:     David_McClarnon (Xara Group Ltd) <camelotdev@xara.com>
00223     Created:    25/1/2000
00224     Purpose:    The parameter for the dragging operation
00225 
00226 ********************************************************************************************/
00227 class DragCreateShadowParam : public OpParam
00228 {
00229 public:
00230     DragCreateShadowParam(SoftShadowTool * pTool, SoftShadowInfoBarOp * pInfoBar, DocCoord PointerPos,
00231         ClickModifiers ClickMods, BOOL bClickedOnBlob = FALSE)
00232     {
00233         m_pInfoBar = pInfoBar;
00234         m_PointerPos = PointerPos;
00235         m_pTool = pTool;
00236         m_ClickMods = ClickMods;
00237         m_bClickedOnBlob = bClickedOnBlob;
00238     }
00239 
00240     SoftShadowInfoBarOp * m_pInfoBar;
00241     SoftShadowTool * m_pTool;
00242     DocCoord m_PointerPos;
00243     ClickModifiers m_ClickMods;
00244     BOOL m_bClickedOnBlob;
00245 } ;
00246 
00247 
00248 
00249 /********************************************************************************************
00250 
00251 >   class OpDragCreateShadow2 : public SelOperation
00252 
00253     Author:     Karim_MacDonald (Xara Group Ltd) <camelotdev@xara.com>
00254     Created:    14/06/2000
00255     Purpose:    The Op which deals with drag-creation of shadows.
00256 
00257 ********************************************************************************************/
00258 class OpDragCreateShadow2 : public SelOperation
00259 {
00260 CC_DECLARE_DYNCREATE(OpDragCreateShadow2)
00261 
00262 friend class SoftShadowTool;
00263 
00264 public:
00265     // Construction/Destruction
00266     OpDragCreateShadow2();
00267     ~OpDragCreateShadow2();
00268 
00269     // start the drag - must have a DragCreateShadowParam passed in.
00270     virtual void DoWithParam(OpDescriptor* pOpDesc, OpParam* pOpParam);
00271     virtual void Do(OpDescriptor *pOpDesc) {};
00272 
00273     // should probably be implemented, but I'll leave this for the time being.
00274     virtual BOOL SnappingDrag() { return FALSE; }
00275 
00276     // virtual dragging functions.
00277     virtual void DragPointerMove(DocCoord PointerPos, ClickModifiers ClickMods, Spread* pSpread, BOOL bSolidDrag);
00278     virtual void DragFinished(DocCoord PointerPos, ClickModifiers ClickMods, Spread* pSpread, BOOL bSuccess, BOOL bSolidDrag);
00279 
00280     // the declaration function, which tells Camelot that we exist.
00281     static BOOL Declare();
00282 
00283     // the state function - allows us to enable or disable ourself.
00284     static OpState GetState(String_256* Description, OpDescriptor*);
00285 
00286     // helper methods for ourself.
00287 private:
00288     static NodeRenderableInk*   GetSelectedShadowFromNode(NodeRenderableInk* pClickedNode);
00289 
00290     void ChangeAllShadows(  DocCoord* pdcWallOffset, DocCoord* pdcFloorVector,
00291                             MILLIPOINT GlowWidth, ShadowType ChangeType );
00292     BOOL SaveSettings(NodeShadowController* pShadow);
00293     BOOL SaveSettings(Range* pShadowRange);
00294     void RestoreSavedSettings();
00295 
00296     // ptrs to our info-bar and tool.
00297     SoftShadowInfoBarOp *   m_pInfoBar;
00298     SoftShadowTool      *   m_pTool;
00299 
00300     // records of past mouse positions.
00301     DocCoord m_InitialPointerPos;
00302 
00303     // the node on which the drag originated.
00304     NodeRenderableInk * m_pClickNode;
00305 
00306     // pointer to a 'master shadow', which defines behaviour
00307     // for all other selected shadows of the same type.
00308     NodeShadowController* m_pMasterShadow;
00309 
00310     // information on initial shadow settings before the drag.
00311     MILLIPOINT  m_InitialGlowWidth;
00312     DocCoord    m_dcInitialWallOffset;
00313     DocCoord    m_dcInitialFloorShadowVector;
00314     MILLIPOINT  m_InitialFeatherWidth;
00315 
00316     // the region of screen currently covered by the dragged shadows.
00317     DocRect     m_drCurrentShadowBounds;
00318 
00319     // the region of screen initially covered by the dragged shadows.
00320     DocRect     m_drInitialShadowBounds;
00321 
00322     // a list to store shadow settings before the drag.
00323     List*       m_plInitialShadowSettings;
00324 
00325     // A range we do own and must delete when we're finished
00326     ListRange*  m_pOwnedRange;
00327 
00328 };
00329 
00330 
00331 
00332 //-------------------------------------------------------------------------------------------
00333 //-------------------------------------------------------------------------------------------
00334 //-------------------------------------------------------------------------------------------
00335 //-------------------------------------------------------------------------------------------
00336 
00337 
00338 
00339 /********************************************************************************************
00340 
00341 >   class SaveShadowSettingsAction : public Action
00342 
00343     Author:     Karim_MacDonald (Xara Group Ltd) <camelotdev@xara.com>
00344     Created:    19 June 2000
00345     Purpose:    Save/restore the shadow settings for a given list of shadows.
00346                 Used to undo/redo the results of OpDragCreateShadow2.
00347 
00348     Notes:      (usage notes here)
00349 
00350 ********************************************************************************************/
00351 class SaveShadowSettingsAction : public Action
00352 {
00353 // dynamic class creation.
00354 CC_DECLARE_DYNCREATE(SaveShadowSettingsAction)
00355 
00356 public:
00357     // required Action methods.
00358     SaveShadowSettingsAction();
00359     ~SaveShadowSettingsAction();
00360     static ActionCode Init( UndoableOperation * pUndoOp,
00361                             ActionList *        pActionList,
00362                             List *              plShadowSettings );
00363     virtual ActionCode Execute();
00364 
00365 private:
00366     // initialise our own information.
00367     void SetShadowList(List* plShadowSettings) { m_plShadowSettings = plShadowSettings; }
00368 
00369     // member variables.
00370     List*   m_plShadowSettings;
00371 };
00372 
00373 
00374 
00375 //-------------------------------------------------------------------------------------------
00376 //-------------------------------------------------------------------------------------------
00377 //-------------------------------------------------------------------------------------------
00378 //-------------------------------------------------------------------------------------------
00379 
00380 
00381 
00382 /********************************************************************************************
00383 
00384 >   class ShadowSettingsItem : public ListItem
00385 
00386     Author:     Karim_MacDonald (Xara Group Ltd) <camelotdev@xara.com>
00387     Created:    19/06/2000
00388     Purpose:    A container class for objects to go in our shadow settings list.
00389 
00390     SeeAlso:    OpDragCreateShadow2, SaveShadowSettingsAction.
00391 
00392 ********************************************************************************************/
00393 class ShadowSettingsItem : public ListItem
00394 {
00395 public:
00396     ShadowSettingsItem(NodeShadowController* pShadow) { this->pShadow = pShadow; }
00397     ShadowSettingsItem() { ERROR3("Do not use this constructor!"); }
00398     ~ShadowSettingsItem() { /* empty. */ };
00399 
00400     // the shadow which these settings apply to.
00401     NodeShadowController* pShadow;
00402 
00403     // the old settings for the shadow.
00404     DocCoord    dcWallOffset;
00405     DocCoord    dcFloorVector;
00406     MILLIPOINT  GlowWidth;
00407     MILLIPOINT  FeatherWidth;
00408 };
00409 
00410 
00411 
00412 #endif      // BUILDSHADOWS
00413 #endif      // INC_SOFTSHADOWTOOL

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