qgraphicssceneevent.h 9.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327
  1. /****************************************************************************
  2. **
  3. ** Copyright (C) 2016 The Qt Company Ltd.
  4. ** Contact: https://www.qt.io/licensing/
  5. **
  6. ** This file is part of the QtWidgets module of the Qt Toolkit.
  7. **
  8. ** $QT_BEGIN_LICENSE:LGPL$
  9. ** Commercial License Usage
  10. ** Licensees holding valid commercial Qt licenses may use this file in
  11. ** accordance with the commercial license agreement provided with the
  12. ** Software or, alternatively, in accordance with the terms contained in
  13. ** a written agreement between you and The Qt Company. For licensing terms
  14. ** and conditions see https://www.qt.io/terms-conditions. For further
  15. ** information use the contact form at https://www.qt.io/contact-us.
  16. **
  17. ** GNU Lesser General Public License Usage
  18. ** Alternatively, this file may be used under the terms of the GNU Lesser
  19. ** General Public License version 3 as published by the Free Software
  20. ** Foundation and appearing in the file LICENSE.LGPL3 included in the
  21. ** packaging of this file. Please review the following information to
  22. ** ensure the GNU Lesser General Public License version 3 requirements
  23. ** will be met: https://www.gnu.org/licenses/lgpl-3.0.html.
  24. **
  25. ** GNU General Public License Usage
  26. ** Alternatively, this file may be used under the terms of the GNU
  27. ** General Public License version 2.0 or (at your option) the GNU General
  28. ** Public license version 3 or any later version approved by the KDE Free
  29. ** Qt Foundation. The licenses are as published by the Free Software
  30. ** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3
  31. ** included in the packaging of this file. Please review the following
  32. ** information to ensure the GNU General Public License requirements will
  33. ** be met: https://www.gnu.org/licenses/gpl-2.0.html and
  34. ** https://www.gnu.org/licenses/gpl-3.0.html.
  35. **
  36. ** $QT_END_LICENSE$
  37. **
  38. ****************************************************************************/
  39. #ifndef QGRAPHICSSCENEEVENT_H
  40. #define QGRAPHICSSCENEEVENT_H
  41. #include <QtCore/qcoreevent.h>
  42. #include <QtCore/qpoint.h>
  43. #include <QtCore/qscopedpointer.h>
  44. #include <QtCore/qrect.h>
  45. #include <QtGui/qpolygon.h>
  46. #include <QtCore/qset.h>
  47. #if QT_DEPRECATED_SINCE(5, 5)
  48. #include <QtCore/qhash.h>
  49. #endif
  50. QT_BEGIN_NAMESPACE
  51. #if !defined(QT_NO_GRAPHICSVIEW)
  52. class QMimeData;
  53. class QPointF;
  54. class QSizeF;
  55. class QWidget;
  56. class QGraphicsSceneEventPrivate;
  57. class Q_WIDGETS_EXPORT QGraphicsSceneEvent : public QEvent
  58. {
  59. public:
  60. explicit QGraphicsSceneEvent(Type type);
  61. ~QGraphicsSceneEvent();
  62. QWidget *widget() const;
  63. void setWidget(QWidget *widget);
  64. protected:
  65. QGraphicsSceneEvent(QGraphicsSceneEventPrivate &dd, Type type = None);
  66. QScopedPointer<QGraphicsSceneEventPrivate> d_ptr;
  67. Q_DECLARE_PRIVATE(QGraphicsSceneEvent)
  68. private:
  69. Q_DISABLE_COPY(QGraphicsSceneEvent)
  70. };
  71. class QGraphicsSceneMouseEventPrivate;
  72. class Q_WIDGETS_EXPORT QGraphicsSceneMouseEvent : public QGraphicsSceneEvent
  73. {
  74. public:
  75. explicit QGraphicsSceneMouseEvent(Type type = None);
  76. ~QGraphicsSceneMouseEvent();
  77. QPointF pos() const;
  78. void setPos(const QPointF &pos);
  79. QPointF scenePos() const;
  80. void setScenePos(const QPointF &pos);
  81. QPoint screenPos() const;
  82. void setScreenPos(const QPoint &pos);
  83. QPointF buttonDownPos(Qt::MouseButton button) const;
  84. void setButtonDownPos(Qt::MouseButton button, const QPointF &pos);
  85. QPointF buttonDownScenePos(Qt::MouseButton button) const;
  86. void setButtonDownScenePos(Qt::MouseButton button, const QPointF &pos);
  87. QPoint buttonDownScreenPos(Qt::MouseButton button) const;
  88. void setButtonDownScreenPos(Qt::MouseButton button, const QPoint &pos);
  89. QPointF lastPos() const;
  90. void setLastPos(const QPointF &pos);
  91. QPointF lastScenePos() const;
  92. void setLastScenePos(const QPointF &pos);
  93. QPoint lastScreenPos() const;
  94. void setLastScreenPos(const QPoint &pos);
  95. Qt::MouseButtons buttons() const;
  96. void setButtons(Qt::MouseButtons buttons);
  97. Qt::MouseButton button() const;
  98. void setButton(Qt::MouseButton button);
  99. Qt::KeyboardModifiers modifiers() const;
  100. void setModifiers(Qt::KeyboardModifiers modifiers);
  101. Qt::MouseEventSource source() const;
  102. void setSource(Qt::MouseEventSource source);
  103. Qt::MouseEventFlags flags() const;
  104. void setFlags(Qt::MouseEventFlags);
  105. private:
  106. Q_DECLARE_PRIVATE(QGraphicsSceneMouseEvent)
  107. Q_DISABLE_COPY(QGraphicsSceneMouseEvent)
  108. };
  109. class QGraphicsSceneWheelEventPrivate;
  110. class Q_WIDGETS_EXPORT QGraphicsSceneWheelEvent : public QGraphicsSceneEvent
  111. {
  112. public:
  113. explicit QGraphicsSceneWheelEvent(Type type = None);
  114. ~QGraphicsSceneWheelEvent();
  115. QPointF pos() const;
  116. void setPos(const QPointF &pos);
  117. QPointF scenePos() const;
  118. void setScenePos(const QPointF &pos);
  119. QPoint screenPos() const;
  120. void setScreenPos(const QPoint &pos);
  121. Qt::MouseButtons buttons() const;
  122. void setButtons(Qt::MouseButtons buttons);
  123. Qt::KeyboardModifiers modifiers() const;
  124. void setModifiers(Qt::KeyboardModifiers modifiers);
  125. int delta() const;
  126. void setDelta(int delta);
  127. Qt::Orientation orientation() const;
  128. void setOrientation(Qt::Orientation orientation);
  129. private:
  130. Q_DECLARE_PRIVATE(QGraphicsSceneWheelEvent)
  131. Q_DISABLE_COPY(QGraphicsSceneWheelEvent)
  132. };
  133. class QGraphicsSceneContextMenuEventPrivate;
  134. class Q_WIDGETS_EXPORT QGraphicsSceneContextMenuEvent : public QGraphicsSceneEvent
  135. {
  136. public:
  137. enum Reason { Mouse, Keyboard, Other };
  138. explicit QGraphicsSceneContextMenuEvent(Type type = None);
  139. ~QGraphicsSceneContextMenuEvent();
  140. QPointF pos() const;
  141. void setPos(const QPointF &pos);
  142. QPointF scenePos() const;
  143. void setScenePos(const QPointF &pos);
  144. QPoint screenPos() const;
  145. void setScreenPos(const QPoint &pos);
  146. Qt::KeyboardModifiers modifiers() const;
  147. void setModifiers(Qt::KeyboardModifiers modifiers);
  148. Reason reason() const;
  149. void setReason(Reason reason);
  150. private:
  151. Q_DECLARE_PRIVATE(QGraphicsSceneContextMenuEvent)
  152. Q_DISABLE_COPY(QGraphicsSceneContextMenuEvent)
  153. };
  154. class QGraphicsSceneHoverEventPrivate;
  155. class Q_WIDGETS_EXPORT QGraphicsSceneHoverEvent : public QGraphicsSceneEvent
  156. {
  157. public:
  158. explicit QGraphicsSceneHoverEvent(Type type = None);
  159. ~QGraphicsSceneHoverEvent();
  160. QPointF pos() const;
  161. void setPos(const QPointF &pos);
  162. QPointF scenePos() const;
  163. void setScenePos(const QPointF &pos);
  164. QPoint screenPos() const;
  165. void setScreenPos(const QPoint &pos);
  166. QPointF lastPos() const;
  167. void setLastPos(const QPointF &pos);
  168. QPointF lastScenePos() const;
  169. void setLastScenePos(const QPointF &pos);
  170. QPoint lastScreenPos() const;
  171. void setLastScreenPos(const QPoint &pos);
  172. Qt::KeyboardModifiers modifiers() const;
  173. void setModifiers(Qt::KeyboardModifiers modifiers);
  174. private:
  175. Q_DECLARE_PRIVATE(QGraphicsSceneHoverEvent)
  176. Q_DISABLE_COPY(QGraphicsSceneHoverEvent)
  177. };
  178. class QGraphicsSceneHelpEventPrivate;
  179. class Q_WIDGETS_EXPORT QGraphicsSceneHelpEvent : public QGraphicsSceneEvent
  180. {
  181. public:
  182. explicit QGraphicsSceneHelpEvent(Type type = None);
  183. ~QGraphicsSceneHelpEvent();
  184. QPointF scenePos() const;
  185. void setScenePos(const QPointF &pos);
  186. QPoint screenPos() const;
  187. void setScreenPos(const QPoint &pos);
  188. private:
  189. Q_DECLARE_PRIVATE(QGraphicsSceneHelpEvent)
  190. Q_DISABLE_COPY(QGraphicsSceneHelpEvent)
  191. };
  192. class QGraphicsSceneDragDropEventPrivate;
  193. class Q_WIDGETS_EXPORT QGraphicsSceneDragDropEvent : public QGraphicsSceneEvent
  194. {
  195. public:
  196. explicit QGraphicsSceneDragDropEvent(Type type = None);
  197. ~QGraphicsSceneDragDropEvent();
  198. QPointF pos() const;
  199. void setPos(const QPointF &pos);
  200. QPointF scenePos() const;
  201. void setScenePos(const QPointF &pos);
  202. QPoint screenPos() const;
  203. void setScreenPos(const QPoint &pos);
  204. Qt::MouseButtons buttons() const;
  205. void setButtons(Qt::MouseButtons buttons);
  206. Qt::KeyboardModifiers modifiers() const;
  207. void setModifiers(Qt::KeyboardModifiers modifiers);
  208. Qt::DropActions possibleActions() const;
  209. void setPossibleActions(Qt::DropActions actions);
  210. Qt::DropAction proposedAction() const;
  211. void setProposedAction(Qt::DropAction action);
  212. void acceptProposedAction();
  213. Qt::DropAction dropAction() const;
  214. void setDropAction(Qt::DropAction action);
  215. QWidget *source() const;
  216. void setSource(QWidget *source);
  217. const QMimeData *mimeData() const;
  218. void setMimeData(const QMimeData *data);
  219. private:
  220. Q_DECLARE_PRIVATE(QGraphicsSceneDragDropEvent)
  221. Q_DISABLE_COPY(QGraphicsSceneDragDropEvent)
  222. };
  223. class QGraphicsSceneResizeEventPrivate;
  224. class Q_WIDGETS_EXPORT QGraphicsSceneResizeEvent : public QGraphicsSceneEvent
  225. {
  226. Q_DECLARE_PRIVATE(QGraphicsSceneResizeEvent)
  227. Q_DISABLE_COPY(QGraphicsSceneResizeEvent)
  228. public:
  229. QGraphicsSceneResizeEvent();
  230. ~QGraphicsSceneResizeEvent();
  231. QSizeF oldSize() const;
  232. void setOldSize(const QSizeF &size);
  233. QSizeF newSize() const;
  234. void setNewSize(const QSizeF &size);
  235. };
  236. class QGraphicsSceneMoveEventPrivate;
  237. class Q_WIDGETS_EXPORT QGraphicsSceneMoveEvent : public QGraphicsSceneEvent
  238. {
  239. Q_DECLARE_PRIVATE(QGraphicsSceneMoveEvent)
  240. Q_DISABLE_COPY(QGraphicsSceneMoveEvent)
  241. public:
  242. QGraphicsSceneMoveEvent();
  243. ~QGraphicsSceneMoveEvent();
  244. QPointF oldPos() const;
  245. void setOldPos(const QPointF &pos);
  246. QPointF newPos() const;
  247. void setNewPos(const QPointF &pos);
  248. };
  249. #endif // QT_NO_GRAPHICSVIEW
  250. QT_END_NAMESPACE
  251. #endif