opdragbx.h

Go to the documentation of this file.
00001 // $Id: opdragbx.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 /*
00099 
00100     opdragbx.h
00101 
00102     Base-class for easy drag box operations.
00103 */
00104 
00105 #ifndef OPDRAGBX_H
00106 #define OPDRAGBX_H
00107 
00108 //#include "ops.h" - in camtypes.h [AUTOMATICALLY REMOVED]
00109 
00110 enum  DragType;
00111 enum  StockColour;
00112 class Spread;
00113 class DocCoord;
00114 class DocRect;
00115 class RenderRegion;
00116 class ClickModifiers;
00117 
00118 
00119 /********************************************************************************************
00120 
00121 >   class OpDragBox : public Operation
00122 
00123     Author:     Justin_Flude (Xara Group Ltd) <camelotdev@xara.com>
00124     Created:    22/4/95
00125     Purpose:    This is a base class for operations that use a drag box to select an area
00126                 within a view, such as the selector and the zoom tools.  This class looks
00127                 after the chore of correctly drawing and updating the xored drag box.
00128 
00129                 To use this class derive a new operation from it and override the
00130                 OnDragEnded function to do something useful with the drag box it is passed.
00131                 You can optionally also override the OnDragStarted, OnPointerMoved, or
00132                 OnPointerIdle functions, eg. to set status text or perform intermediate
00133                 calculations, and the SetBoxColours and CalcDragRect functions to customise
00134                 the "look and feel" of the drag box.
00135 
00136                 To run a drag, create an instance of your derived class and call its
00137                 DoDrag() function, passing the mouse position etc that should be available
00138                 in a tool.
00139     SeeAlso:    class OpCentredDragBox
00140 
00141 ********************************************************************************************/
00142 
00143 class OpDragBox : public Operation
00144 {
00145 public:
00146     // This function is called on startup, and reads preferences etc.
00147     static BOOL Init();
00148 
00149     // This function initiates a drag, returning TRUE if it is successful.
00150     BOOL DoDrag(DragType dt,
00151                 Spread* pStartSpread,
00152                 const DocCoord& dcStartPos,
00153                 ClickModifiers cmods);
00154 
00155 protected:
00156     // Creation & destruction.  The constructor is only available to derived classes (it
00157     // makes no sense to create objects of this type, only derivatives).
00158     OpDragBox();
00159 
00160     // You can override these On... functions to do something useful (by default they do
00161     // nothing).  They can all return FALSE to cancel the drag.  This function is called when
00162     // the drag is started.
00163     virtual BOOL OnDragStarted(Spread* pStartSpread,
00164                                const DocCoord& dcStartPos,
00165                                ClickModifiers cmods);
00166 
00167     // This function is called when the pointer moves.
00168     virtual BOOL OnPointerMoved(Spread* pBoxSpread,
00169                                 const DocRect& drDragBox,
00170                                 ClickModifiers cmods);
00171 
00172     // This function is called when the pointer hasn't moved for a little while.
00173     virtual BOOL OnPointerIdle(Spread* pBoxSpread,
00174                                const DocRect& drDragBox,
00175                                ClickModifiers cmods);
00176 
00177     // This function is called when the drag finishes, and is passed the final drag box the
00178     // user has drawn and a drag success code.
00179     virtual BOOL OnDragEnded(Spread* pBoxSpread,
00180                              const DocRect& drDragBox,
00181                              ClickModifiers cmods,
00182                              BOOL fDragOK);
00183 
00184     // This function can be overridden to calculate the drag box in a different way, eg. for
00185     // a drag box that grows from a centre point to a corner, instead of the default behaviour
00186     // which calculates a drag box from one corner to its opposite.
00187     virtual DocRect CalcDragBox(const DocCoord& dcStartPos, const DocCoord& dcMousePos) const;
00188 
00189     // This function can be overriden to set the line colour for the drag box.  By default it
00190     // returns COLOUR_XORSELECT, as per user-interface guidelines for selection xor-ing.
00191     virtual StockColour GetBoxColour() const;
00192 
00193     // If you override the above CalcDragBox function so that the start position is no longer a
00194     // corner of the drag box, when you get the final drag box in OnDragEnded it may be
00195     // difficult to work out from it where the drag started, so call this which always knows.
00196     BOOL GetDragStartPos(Spread** ppStartSpread, DocCoord* pdcStartPos) const;
00197 
00198     // Miscellaneous helpers.  These may well be useful in a derived class.
00199     static MILLIPOINT Min(MILLIPOINT a, MILLIPOINT b);
00200     static MILLIPOINT Max(MILLIPOINT a, MILLIPOINT b);
00201 
00202 private:
00203     // Implementation of a drag operation as defined by Operation.
00204     void DragPointerMove(DocCoord dcMousePos, ClickModifiers cmods, Spread* pSpread, BOOL bSolidDrag);
00205     void DragPointerIdle(DocCoord dcMousePos, ClickModifiers cmods, Spread* pSpread, BOOL bSolidDrag);
00206     void DragFinished(DocCoord dcMousePos, ClickModifiers cmods, Spread* pSpread, BOOL fOK, BOOL bSolidDrag);
00207     void RenderDragBlobs(DocRect drClipRect, Spread* pRenderSpread, BOOL bSolidDrag);
00208 
00209     // These functions erase the old drag box and draw the new one.
00210     void UpdateSolidDragBox(const DocRect& drNewDragBox);
00211     void UpdateUnfilledDragBox(const DocRect& drNewDragBox);
00212     
00213     // This function draws a render-on-top xored rectangle at the given spread coordinates.
00214     void DrawXorRect(const DocRect& drClip, Spread* pspdXor, const DocRect& drXor) const;
00215 
00216     // Data members.
00217     Spread*  m_pStartSpread;                // the spread where the drag started
00218     DocCoord m_dcStartPos;                  // the point where the drag started
00219     DocRect  m_drLastDragBox;               // the last extent of the drag box
00220 
00221     // Preferences.
00222     static BOOL m_fDoSolidDragBoxes;        // whether to do solid xored drag boxes or just
00223                                             // unfilled rectangles.
00224     
00225     CC_DECLARE_DYNCREATE(OpDragBox);
00226 };
00227 
00228 
00229 
00230 /********************************************************************************************
00231 
00232 >   class OpCentredDragBox : public OpDragBox
00233 
00234     Author:     Justin_Flude (Xara Group Ltd) <camelotdev@xara.com>
00235     Created:    23/4/95
00236     Purpose:    This is a base class for drag operations that would like a drag box to be
00237                 centred on the initial click point, such as (optionally) the zoom tool.
00238                 Apart from providing a new default CalcDragBox function, it is used the
00239                 same way as OpDragBox.
00240     SeeAlso:    class OpDragBox
00241 
00242 ********************************************************************************************/
00243 
00244 class OpCentredDragBox : public OpDragBox
00245 {
00246 protected:
00247     // Creation & destruction.
00248     OpCentredDragBox();
00249 
00250     // Overridables.
00251     virtual DocRect CalcDragBox(const DocCoord& dcStartPos, const DocCoord& dcMousePos) const;
00252 
00253 private:    
00254     CC_DECLARE_DYNCREATE(OpCentredDragBox);
00255 };
00256 
00257 #endif  // !OPDRAGBX_H

Generated on Sat Nov 10 03:46:13 2007 for Camelot by  doxygen 1.4.4