00001 // $Id: dragmgr.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 // dragmgr.h - Definitions for global dragging system manager 00100 00101 #ifndef INC_DRAGMGR 00102 #define INC_DRAGMGR 00103 00104 00105 #include "draginfo.h" 00106 #include "dragmsg.h" 00107 //#include "dragtrgt.h" - in camtypes.h [AUTOMATICALLY REMOVED] 00108 //#include "list.h" - in camtypes.h [AUTOMATICALLY REMOVED] 00109 00110 class Cursor; 00111 enum ObjectDragTarget; 00112 00113 /******************************************************************************************** 00114 00115 > class CaptureHandler : public CWnd 00116 00117 Author: Gerry_Iles (Xara Group Ltd) <camelotdev@xara.com> 00118 Created: 13/01/95 00119 Purpose: An event handler to centralise the mouse handling during a drag 00120 SeeAlso: 00121 00122 ********************************************************************************************/ 00123 00124 class CaptureHandler : public wxEvtHandler 00125 { 00126 DECLARE_DYNAMIC_CLASS(CaptureHandler) 00127 00128 friend class DragManagerOp; 00129 friend class DragInformation; 00130 00131 public: 00132 CaptureHandler(wxWindow* pWindow = NULL); 00133 ~CaptureHandler(); 00134 00135 void OnMouseMove(wxMouseEvent& event); 00136 void OnLButtonUp(wxMouseEvent& event); 00137 void OnRButtonUp(wxMouseEvent& event); 00138 00139 public: 00140 BOOL StartCapture(); 00141 00142 BOOL SetUpSolidDrag(wxPoint StartPos); 00143 BOOL CleanUpSolidDrag(); 00144 00145 BOOL CleanUpSolidDragInScreenArea(const wxRect& Area); 00146 // Called to remove any on-scren solid drag stuff if it overlaps the given area 00147 // This minimises flicker when unrelated areas of the screen are redrawn while we're dragging 00148 00149 BOOL DrawSolidDrag(wxPoint point); 00150 BOOL DrawTransparentDrag(wxPoint point, INT32 Transparency); 00151 00152 protected: 00153 wxWindow* m_pWindow; 00154 BOOL m_bHasCapture; 00155 wxScreenDC* m_pDisplayDC; 00156 00157 wxBitmap* m_pBackBitmap; 00158 wxRect m_DragRect; 00159 00160 // Some things for semi-transparent drags 00161 wxBitmap* m_pMaskBitmap; 00162 00163 DECLARE_EVENT_TABLE() 00164 }; 00165 00166 00167 00168 /********************************************************************************************* 00169 00170 > class DragManagerOp : public Operation 00171 00172 Author: Jason_Williams (Xara Group Ltd) <camelotdev@xara.com> 00173 Created: 2/1/95 00174 Purpose: An instantiation of this class (created by a call to its static StartDrag 00175 method) is used to describe a current global drag. When the drag completes, 00176 this object will self destruct. While alive, this object controls the drag, 00177 passing relevant events on to registered drag targets, etc. 00178 See the documentation for a fuller description of the global drag system. 00179 00180 SeeAlso: DragManagerOp::StartDrag; DragTarget; DragInformation 00181 00182 Documentation: Docs\Specs\DragMan.doc 00183 00184 *********************************************************************************************/ 00185 00186 class CCAPI DragManagerOp : public Operation 00187 { 00188 friend class DragTarget; 00189 friend class KernelDragTarget; 00190 friend class OilDragTarget; 00191 friend class CaptureHandler; 00192 friend class DragInformation; 00193 00194 CC_DECLARE_DYNCREATE(DragManagerOp) 00195 00196 00197 protected: // Protected constructors/Destructor 00198 DragManagerOp(); // use StartDrag to create a new DragManagerOp 00199 DragManagerOp(DragInformation *Descriptor); 00200 00201 ~DragManagerOp(); // use AbortDrag to destruct a DragManagerOp 00202 00203 00204 public: // External drag management methods 00205 static void StartDrag(DragInformation *Descriptor, CWindowID DragWindow); 00206 // To start a drag going 00207 00208 static void EndDrag(INT32 Flags); 00209 // To end a drag - called from the capture window on mouse ups 00210 00211 static void AbortDrag(void); 00212 // To abort the current drag (if any) 00213 00214 static DragManagerOp *GetCurrentManager(void); 00215 // Returns NULL, or a pointer to the current drag manager 00216 static BOOL GetStatusText(String_256 * StatusText); 00217 00218 static CaptureHandler * GetDragCaptureHandler(); 00219 00220 static DragInformation * GetCurrentDragInfo(); 00221 00222 static wxPoint GetDragMousePos(); 00223 00224 static BOOL IsDragActive(){return DragActive;} 00225 00226 static void SetDragActive(BOOL State){DragActive = State;} 00227 00228 static void RedrawStarting(void); 00229 static void RedrawStarting(CWindowID TheWindow, CGadgetID TheGadget, DocRect *TheArea = NULL); 00230 static void RedrawFinished(void); 00231 // Call to tell the drag manager that a redraw is occurring, during a drag. 00232 // This allows the drag manager to ensure all drag blobs are removed from screen during the redraw 00233 00234 public: // Operation class overrides 00235 virtual BOOL OnIdleEvent(void); 00236 // Handles idle events 00237 00238 protected: // Methods for use only by friend classes 00239 void RegisterTarget(DragTarget *NewTarget, BOOL HighPriority = FALSE); 00240 // Registers a target with the current drag manager 00241 00242 void DeregisterTarget(DragTarget *OldTarget); 00243 // De-registers a registered target. Is quiet if the target is already deregistered 00244 00245 static void SetCursor(); 00246 // Sets the cursor shape. If nobody tries to set the shape during an event processing 00247 // pass, then it will be set back to the default. Repeated calls with the same shape 00248 // have no effect (except to stop the pointer reverting) 00249 00250 static void SetStatusLineText(); 00251 // writes status line text 00252 00253 private: // Internal methods 00254 BOOL ProcessEvent(DragEventType Event); 00255 // Passes a Drag Event to all (or until event claimed) registered DragTargets 00256 00257 void CleanUpAfterDrag(void); 00258 // Deletes all of our memory claims 00259 00260 private: // private data 00261 static DragManagerOp *CurrentManager; // ptr to the currently active Drag Manager 00262 00263 static DragInformation *CurrentDragInfo;// Points to descriptor of current drag 00264 00265 static DragTarget * CurrentDragTarget; // Points to the current drag target 00266 00267 static UINT32 StatusLineStringID; // ID of Current StatusLine Text string 00268 00269 UINT32 CurrentID; 00270 Cursor* CurrentCursor; 00271 00272 List Targets; // List of DragTargets for this current drag 00273 00274 KeyPress *CurrentKeypress; // NULL, or last keypress info 00275 00276 wxPoint InitialMousePos; // Contains first winoily screen mouse position 00277 wxPoint CurrentMousePos; // Contains last winoily screen mouse position 00278 wxPoint LastMousePos; // Last position the mouse was at 00279 00280 DragEventType LastEvent; // Type of the last Drag Event processed 00281 00282 static CaptureHandler * TheCaptureHandler; // The event handler we use to centralised mouse handling 00283 00284 static BOOL DragPending; // Drag pending flag ie. this may be a click ! 00285 00286 static BOOL DragEnded; 00287 00288 static MonotonicTime DragStartTimer; 00289 00290 static UINT32 DragMinDist; // drag start distance 00291 00292 static UINT32 DragDelay; // millisecond delay before drag starts 00293 00294 static wxRect DragStartRect; 00295 00296 static wxRect StillClickRect; // initial area for drag start - if pointer 00297 // leaves this area we start a drag. 00298 00299 static BOOL DragActive; 00300 00301 static BOOL RedrawInProgress; // An external redraw is occurring 00302 }; 00303 00304 00305 #endif 00306