1 /* AbiWord
2  * Copyright (c) 2003 Martin Sevior <msevior@physics.unimelb.edu.au>
3  *
4  * This program is free software; you can redistribute it and/or
5  * modify it under the terms of the GNU General Public License
6  * as published by the Free Software Foundation; either version 2
7  * of the License, or (at your option) any later version.
8  *
9  * This program is distributed in the hope that it will be useful,
10  * but WITHOUT ANY WARRANTY; without even the implied warranty of
11  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
12  * GNU General Public License for more details.
13  *
14  * You should have received a copy of the GNU General Public License
15  * along with this program; if not, write to the Free Software
16  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
17  * 02110-1301 USA.
18  */
19 
20 #ifndef FV_VISUALDRAGTEXT_H
21 #define FV_VISUALDRAGTEXT_H
22 
23 #include "pt_Types.h"
24 #include "fl_FrameLayout.h"
25 
26 typedef enum _FV_VisualDragMode
27 {
28 	FV_VisualDrag_NOT_ACTIVE,
29 	FV_VisualDrag_WAIT_FOR_MOUSE_CLICK,
30 	FV_VisualDrag_WAIT_FOR_MOUSE_DRAG,
31 	FV_VisualDrag_DRAGGING,
32 	FV_VisualDrag_START_DRAGGING
33 } FV_VisualDragMode;
34 
35 class GR_Graphics;
36 class GR_Image;
37 class FV_View;
38 
39 class ABI_EXPORT FV_VisualDragText
40 {
41 	friend class fv_View;
42 
43 public:
44 
45 	FV_VisualDragText (FV_View * pView);
46 	virtual ~FV_VisualDragText();
47 	GR_Graphics *         getGraphics(void) const ;
48 	bool                  isActive(void) const;
49     void                  setMode(FV_VisualDragMode iVisualDragMode);
getVisualDragMode(void)50 	FV_VisualDragMode      getVisualDragMode(void) const
51 		{ return m_iVisualDragMode;}
52 	virtual void          mouseDrag(UT_sint32 x, UT_sint32 y);
53 	void                  mouseCut(UT_sint32 x, UT_sint32 y);
54 	void                  mouseCopy(UT_sint32 x, UT_sint32 y);
55 	void                  mouseRelease(UT_sint32 x, UT_sint32 y);
56 	void                  drawImage(void);
57 	void                  getImageFromSelection(UT_sint32 x, UT_sint32 y);
58 	bool                  reposOffsets(UT_sint32 x, UT_sint32 y);
59 	PT_DocPosition        getPosFromXY(UT_sint32 x, UT_sint32 y);
60 	void                  drawCursor(PT_DocPosition newPos);
61 	static void 		  _actuallyScroll(UT_Worker * pTimer);
62 	static void 		  _autoScroll(UT_Worker * pTimer);
63 	void                  clearCursor(void);
64 	void                  abortDrag(void);
isNotdraggingImage(void)65 	bool                  isNotdraggingImage(void)
66 	  { return m_bNotDraggingImage;}
isDoingCopy(void)67 	bool                  isDoingCopy(void)
68 	  { return m_bDoingCopy;}
getCurFrame(void)69 	UT_Rect *             getCurFrame(void)
70 	  { return &m_recCurFrame;}
71  protected:
72 	void                  _mouseDrag(UT_sint32 x, UT_sint32 y);
73 	FV_View *             m_pView;
74 private:
75 	FV_VisualDragMode     m_iVisualDragMode;
76 	GR_Image *            m_pDragImage;
77 	UT_sint32             m_iLastX;
78 	UT_sint32             m_iLastY;
79 	UT_Rect               m_recCurFrame;
80 	UT_sint32             m_iInitialOffX;
81 	UT_sint32             m_iInitialOffY;
82 	UT_Rect               m_recOrigLeft;
83 	UT_Rect               m_recOrigRight;
84 	bool                  m_bTextCut;
85 	GR_Image *            m_pDocUnderCursor;
86 	bool                  m_bCursorDrawn;
87 	UT_Rect               m_recCursor;
88 	UT_Rect               m_recDoc;
89 
90 	// autoscroll stuff
91 	UT_Timer *			  m_pAutoScrollTimer;
92 	UT_sint32			  m_xLastMouse;
93 	UT_sint32			  m_yLastMouse;
94 
95 	bool                  m_bDoingCopy;
96 	bool                  m_bNotDraggingImage;
97 	bool                  m_bSelectedRow;
98 };
99 
100 #endif /* FV_VISUALDRAGTEXT_H */
101