File indexing completed on 2025-02-09 06:59:31
0001 /*************************************************************************** 0002 * Copyright (C) 2005 by David Saxton * 0003 * david@bluehaze.org * 0004 * * 0005 * This program is free software; you can redistribute it and/or modify * 0006 * it under the terms of the GNU General Public License as published by * 0007 * the Free Software Foundation; either version 2 of the License, or * 0008 * (at your option) any later version. * 0009 ***************************************************************************/ 0010 0011 #ifndef EVENTINFO_H 0012 #define EVENTINFO_H 0013 0014 #include <QPoint> 0015 0016 class ItemView; 0017 0018 class KtlQCanvasItem; 0019 class QEvent; 0020 class QMouseEvent; 0021 class QWheelEvent; 0022 0023 /** 0024 Contains information from for a mouse event that occurred on a canvas. Like a 0025 QMouseEvent / QEvent / QWheelEvent, but abstracted to the canvas coordinate 0026 system, as well as holding lots of useful information. 0027 @author David Saxton 0028 */ 0029 class EventInfo 0030 { 0031 public: 0032 EventInfo(); 0033 EventInfo(ItemView *itemView, QMouseEvent *e); 0034 EventInfo(ItemView *itemView, QWheelEvent *e); 0035 EventInfo(ItemView *itemView, QEvent *e); 0036 0037 QMouseEvent *mousePressEvent(int dx, int dy) const; 0038 QMouseEvent *mouseReleaseEvent(int dx, int dy) const; 0039 QMouseEvent *mouseDoubleClickEvent(int dx, int dy) const; 0040 QMouseEvent *mouseMoveEvent(int dx, int dy) const; 0041 QWheelEvent *wheelEvent(int dx, int dy) const; 0042 0043 QPoint pos; 0044 QPoint globalPos; 0045 KtlQCanvasItem *qcanvasItemClickedOn; 0046 QPoint pixelDelta; 0047 QPoint angleDelta; 0048 Qt::ScrollPhase phase; 0049 bool inverted; 0050 bool isRightClick; 0051 bool isMiddleClick; 0052 bool ctrlPressed; 0053 bool shiftPressed; 0054 bool altPressed; 0055 0056 protected: 0057 void extractPos(ItemView *itemView, const QPoint &contentsMouseClick); 0058 void reset(); 0059 }; 0060 0061 #endif