Warning, file /office/calligra/libs/flake/KoPointerEvent.h was not indexed or was modified since last indexation (in which case cross-reference links may be missing, inaccurate or erroneous).
0001 /* This file is part of the KDE project 0002 0003 Copyright (C) 2006 Thorsten Zachmann <zachmann@kde.org> 0004 Copyright (C) 2006 C. Boemann Rasmussen <cbo@boemann.dk> 0005 Copyright (C) 2006-2007 Thomas Zander <zander@kde.org> 0006 Copyright (C) 2012 Boudewijn Rempt <boud@kogmbh.com> 0007 0008 This library is free software; you can redistribute it and/or 0009 modify it under the terms of the GNU Library General Public 0010 License as published by the Free Software Foundation; either 0011 version 2 of the License, or (at your option) any later version. 0012 0013 This library is distributed in the hope that it will be useful, 0014 but WITHOUT ANY WARRANTY; without even the implied warranty of 0015 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 0016 Library General Public License for more details. 0017 0018 You should have received a copy of the GNU Library General Public License 0019 along with this library; see the file COPYING.LIB. If not, write to 0020 the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, 0021 * Boston, MA 02110-1301, USA. 0022 */ 0023 0024 #ifndef KOPOINTEREVENT_H 0025 #define KOPOINTEREVENT_H 0026 0027 #include <QTouchEvent> 0028 0029 class QTabletEvent; 0030 class QMouseEvent; 0031 class QWheelEvent; 0032 class KoInputDeviceHandlerEvent; 0033 class QGraphicsSceneMouseEvent; 0034 class QGraphicsSceneWheelEvent; 0035 0036 #include "flake_export.h" 0037 0038 struct KoTouchPoint 0039 { 0040 QTouchEvent::TouchPoint touchPoint; 0041 // the point in document coordinates 0042 QPointF lastPoint; 0043 QPointF point; 0044 0045 }; 0046 0047 Q_DECLARE_TYPEINFO(KoTouchPoint, Q_MOVABLE_TYPE); 0048 0049 /** 0050 * KoPointerEvent is a synthetic event that can be built from a mouse, 0051 * touch or tablet event. In addition to always providing tools with tablet 0052 * pressure characteristics, KoPointerEvent has both the original 0053 * (canvas based) position as well as the normalized position, that is, 0054 * the position of the event _in_ the document coordinates. 0055 */ 0056 class FLAKE_EXPORT KoPointerEvent 0057 { 0058 public: 0059 /** 0060 * Constructor. 0061 * 0062 * @param event the mouse event that is the base of this event. 0063 * @param point the zoomed point in the normal coordinate system. 0064 */ 0065 KoPointerEvent(QMouseEvent *event, const QPointF &point); 0066 0067 /** 0068 * Constructor. 0069 * 0070 * @param event the mouse event that is the base of this event. 0071 * @param point the zoomed point in the normal coordinate system. 0072 */ 0073 KoPointerEvent(QGraphicsSceneMouseEvent *event, const QPointF &point); 0074 0075 /** 0076 * Constructor. 0077 * 0078 * @param event the mouse event that is the base of this event. 0079 * @param point the zoomed point in the normal coordinate system. 0080 */ 0081 KoPointerEvent(QGraphicsSceneWheelEvent *event, const QPointF &point); 0082 0083 /** 0084 * Constructor. 0085 * 0086 * @param event the tablet event that is the base of this event. 0087 * @param point the zoomed point in the normal coordinate system. 0088 */ 0089 KoPointerEvent(QTabletEvent *event, const QPointF &point); 0090 0091 /** 0092 * Constructor. 0093 * 0094 * @param event the touch event that is the base of this event. 0095 * @param point the zoomed point of the primary touch event in the normal coordinate system. 0096 * @param touchpoints the zoomed points of the touch event in the normal coordinate system. 0097 */ 0098 KoPointerEvent(QTouchEvent *event, const QPointF &point, const QVector<KoTouchPoint> &_touchPoints); 0099 0100 /** 0101 * Constructor. 0102 * 0103 * @param event the tablet event that is the base of this event. 0104 * @param point the zoomed point in the normal coordinate system. 0105 */ 0106 KoPointerEvent(QWheelEvent *event, const QPointF &point); 0107 0108 KoPointerEvent(KoInputDeviceHandlerEvent *event, int x, int y, int z = 0, int rx = 0, int ry = 0, int rz = 0); 0109 0110 KoPointerEvent(KoPointerEvent *event, const QPointF& point); 0111 0112 KoPointerEvent(const KoPointerEvent &rhs); 0113 0114 0115 ~KoPointerEvent(); 0116 0117 /** 0118 * For classes that are handed this event, you can choose to accept (default) this event. 0119 * Acceptance signifies that you have handled this event and found it useful, the effect 0120 * of that will be that the event will not be handled to other event handlers. 0121 */ 0122 inline void accept() { 0123 m_event->accept(); 0124 } 0125 0126 /** 0127 * For classes that are handed this event, you can choose to ignore this event. 0128 * Ignoring this event means you have not handled it and want to allow other event 0129 * handlers to try to handle it. 0130 */ 0131 inline void ignore() { 0132 m_event->ignore(); 0133 } 0134 0135 /** 0136 * Returns the keyboard modifier flags that existed immediately before the event occurred. 0137 * See also QApplication::keyboardModifiers(). 0138 */ 0139 Qt::KeyboardModifiers modifiers() const; 0140 0141 /// return if the event has been accepted. 0142 inline bool isAccepted() const { 0143 return m_event->isAccepted(); 0144 } 0145 0146 /// return if this event was spontaneous (see QMouseEvent::spontaneous()) 0147 inline bool spontaneous() const { 0148 return m_event->spontaneous(); 0149 } 0150 0151 /// return button pressed (see QMouseEvent::button()); 0152 Qt::MouseButton button() const; 0153 0154 /// return buttons pressed (see QMouseEvent::buttons()); 0155 Qt::MouseButtons buttons() const; 0156 0157 /// Return the position screen coordinates 0158 QPoint globalPos() const; 0159 0160 /// return the position in widget coordinates 0161 QPoint pos() const; 0162 0163 /** 0164 * return the pressure (or a default value). The range is 0.0 - 1.0 0165 * and the default pressure (this is the pressure that will be given 0166 * when you use something like the mouse) is 1.0 0167 */ 0168 qreal pressure() const; 0169 0170 /// return the rotation (or a default value) 0171 qreal rotation() const; 0172 0173 /** 0174 * return the tangential pressure (or a default value) 0175 * This is typically given by a finger wheel on an airbrush tool. The range 0176 * is from -1.0 to 1.0. 0.0 indicates a neutral position. Current airbrushes can 0177 * only move in the positive direction from the neutral position. If the device 0178 * does not support tangential pressure, this value is always 0.0. 0179 */ 0180 qreal tangentialPressure() const; 0181 0182 /** 0183 * Return the x position in widget coordinates. 0184 * @see point 0185 */ 0186 int x() const; 0187 0188 /** 0189 * Returns the angle between the device (a pen, for example) and the 0190 * perpendicular in the direction of the x axis. Positive values are 0191 * towards the tablet's physical right. The angle is in the range -60 0192 * to +60 degrees. The default value is 0. 0193 */ 0194 int xTilt() const; 0195 0196 /** 0197 * Return the y position in widget coordinates. 0198 * @see point 0199 */ 0200 int y() const; 0201 0202 /** 0203 * Returns the angle between the device (a pen, for example) and the 0204 * perpendicular in the direction of the x axis. Positive values are 0205 * towards the tablet's physical right. The angle is in the range -60 0206 * to +60 degrees. The default value is 0. 0207 */ 0208 int yTilt() const; 0209 0210 /** 0211 * Returns the z position of the device. Typically this is represented 0212 * by a wheel on a 4D Mouse. If the device does not support a Z-axis, 0213 * this value is always zero. This is <em>not</em> the same as pressure. 0214 */ 0215 int z() const; 0216 0217 /** 0218 * Returns the distance that the wheel is rotated, in eights of a degree, or 0 otherwise. 0219 * @return the distance of rotation. 0220 * @see orientation() 0221 */ 0222 int delta() const; 0223 0224 /** 0225 * Returns the rotation around the X-axis. If the device does not support 0226 * this, the value is always zero. 0227 */ 0228 int rotationX() const; 0229 0230 /** 0231 * Returns the rotation around the X-axis. If the device does not support 0232 * this, the value is always zero. 0233 */ 0234 int rotationY() const; 0235 0236 /** 0237 * Returns the rotation around the Z-axis. If the device does not support 0238 * this, the value is always zero. 0239 */ 0240 int rotationZ() const; 0241 0242 /** 0243 * Returns the orientation of the delta. 0244 */ 0245 Qt::Orientation orientation() const; 0246 0247 /// The point in document coordinates. 0248 const QPointF point; 0249 0250 const QVector<KoTouchPoint> touchPoints; 0251 /** 0252 * Returns if the event comes from a tablet 0253 */ 0254 bool isTabletEvent(); 0255 0256 protected: 0257 friend class KoToolProxy; 0258 friend class KisToolProxy; 0259 friend class KisScratchPadEventFilter; 0260 /// called by KoToolProxy to set which button was pressed. 0261 void setTabletButton(Qt::MouseButton button); 0262 private: 0263 KoPointerEvent& operator=(const KoPointerEvent &rhs); 0264 0265 // for the d-pointer police; we want to make accessors to the event inline, so this one stays here. 0266 QEvent *m_event; 0267 0268 class Private; 0269 Private * const d; 0270 }; 0271 0272 #endif 0273