1 /* AbiWord 2 * Copyright (c) 2005 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_VISUALINLINEIMAGE_H 21 #define FV_VISUALINLINEIMAGE_H 22 23 #include "pt_Types.h" 24 #include "fl_FrameLayout.h" 25 #include "ut_string_class.h" 26 #include "fv_FrameEdit.h" // for FV_Base 27 28 29 typedef enum _FV_InlineDragMode 30 { 31 FV_InlineDrag_NOT_ACTIVE, 32 FV_InlineDrag_WAIT_FOR_MOUSE_CLICK, 33 FV_InlineDrag_WAIT_FOR_MOUSE_DRAG, 34 FV_InlineDrag_DRAGGING, 35 FV_InlineDrag_RESIZE, 36 FV_InlineDrag_START_DRAGGING 37 } FV_InlineDragMode; 38 39 class GR_Graphics; 40 class GR_Image; 41 class FV_View; 42 class PP_AttrProp; 43 class UT_ByteBuf; 44 45 class ABI_EXPORT FV_VisualInlineImage : public FV_Base 46 { 47 friend class fv_View; 48 49 public: 50 51 FV_VisualInlineImage (FV_View * pView); 52 ~FV_VisualInlineImage(); 53 bool isActive(void) const; 54 void setMode(FV_InlineDragMode iInlineDragMode); getInlineDragMode(void)55 FV_InlineDragMode getInlineDragMode(void) const 56 { return m_iInlineDragMode;} 57 void setDragType(UT_sint32 x,UT_sint32 y, bool bDrawImage); 58 FV_DragWhat mouseMotion(UT_sint32 x, UT_sint32 y); 59 void mouseLeftPress(UT_sint32 x, UT_sint32 y); 60 void mouseCut(UT_sint32 x, UT_sint32 y); 61 void mouseCopy(UT_sint32 x, UT_sint32 y); 62 void mouseRelease(UT_sint32 x, UT_sint32 y); 63 bool drawImage(void); 64 void getImageFromSelection(UT_sint32 x, UT_sint32 y,PP_AttrProp ** pAP = NULL ); 65 PP_AttrProp * getImageAPFromXY(UT_sint32 x, UT_sint32 y); 66 PT_DocPosition getPosFromXY(UT_sint32 x, UT_sint32 y) const; 67 void drawCursor(PT_DocPosition newPos); 68 static void _actuallyScroll(UT_Worker * pTimer); 69 static void _autoScroll(UT_Worker * pTimer); 70 void clearCursor(void); 71 void cleanUP(void); 72 void abortDrag(void); 73 const char * getPNGImage(const UT_ByteBuf ** pBuf) const; 74 UT_sint32 getImageSelBoxSize() const; // in device units! 75 void setSelectionDrawn(bool bSelectionDrawn); 76 protected: 77 virtual void _mouseDrag(UT_sint32 x, UT_sint32 y); 78 private: 79 FV_InlineDragMode m_iInlineDragMode; 80 GR_Image * m_pDragImage; 81 UT_sint32 m_iLastX; 82 UT_sint32 m_iLastY; 83 UT_sint32 m_iInitialOffX; 84 UT_sint32 m_iInitialOffY; 85 bool m_bTextCut; 86 GR_Image * m_pDocUnderCursor; 87 bool m_bCursorDrawn; 88 UT_Rect m_recCursor; 89 90 // autoscroll stuff 91 UT_Timer * m_pAutoScrollTimer; 92 93 bool m_bDoingCopy; 94 PP_AttrProp * m_pImageAP; 95 GR_Image * m_screenCache; 96 UT_UTF8String m_sCopyName; 97 bool m_bIsEmbedded; 98 bool m_bEmbedCanResize; 99 UT_UTF8String m_sDataId; 100 bool m_bSelectionDrawn; 101 }; 102 103 #endif /* FV_VISUALINLINEIMAGE_H */ 104