00001
00002
00003
00004
00005
00006
00007
00008
00009
00010 #ifndef INSTIGATE_TOOLKIT_QT_ITEM
00011 #define INSTIGATE_TOOLKIT_QT_ITEM
00012
00022
00023 #include "event_names.hpp"
00024 #include "item.hpp"
00025
00026
00027
00028
00029
00030
00031
00033 template <typename T>
00034 class instigate::toolkit::qt_item
00035 : public T
00036 , public item
00037 {
00038 public:
00039 void mousePressEvent(QGraphicsSceneMouseEvent* e) throw();
00040
00041 void mouseReleaseEvent(QGraphicsSceneMouseEvent* e) throw();
00042
00043 void mouseMoveEvent(QGraphicsSceneMouseEvent* e) throw();
00044
00045 void hoverMoveEvent(QGraphicsSceneHoverEvent* e) throw();
00046
00047 void mouseDoubleClickEvent(QGraphicsSceneMouseEvent* e) throw();
00048
00049 public:
00050 qt_item(const std::string& s, toolkit::window* w) throw();
00051 };
00052
00053 template <typename T>
00054 void instigate::toolkit::qt_item<T>::
00055 mousePressEvent(QGraphicsSceneMouseEvent* e) throw()
00056 {
00057 assert(0 != e);
00058 if (e->button() == Qt::LeftButton) {
00059 notify(mouse_left_button_press, e);
00060 } else if (e->button() == Qt::RightButton) {
00061 notify(mouse_right_button_press, e);
00062 } else if (e->button() == Qt::MidButton) {
00063 notify(mouse_middle_button_press, e);
00064 }
00065 }
00066
00067 template <typename T>
00068 void instigate::toolkit::qt_item<T>::
00069 mouseReleaseEvent(QGraphicsSceneMouseEvent* e) throw()
00070 {
00071 assert(0 != e);
00072 if (e->button() == Qt::LeftButton) {
00073 notify(mouse_left_button_release, e);
00074 } else if (e->button() == Qt::RightButton) {
00075 notify(mouse_right_button_release, e);
00076 } else if (e->button() == Qt::MidButton) {
00077 notify(mouse_middle_button_release, e);
00078 }
00079 }
00080
00081 template <typename T>
00082 void instigate::toolkit::qt_item<T>::
00083 mouseMoveEvent(QGraphicsSceneMouseEvent* e) throw()
00084 {
00085 assert(0 != e);
00086 notify(mouse_move, e);
00087 }
00088
00089 template <typename T>
00090 void instigate::toolkit::qt_item<T>::
00091 hoverMoveEvent(QGraphicsSceneHoverEvent* e) throw()
00092 {
00093 assert(0 != e);
00094 notify(mouse_move, e);
00095 }
00096
00097 template <typename T>
00098 void instigate::toolkit::qt_item<T>::
00099 mouseDoubleClickEvent(QGraphicsSceneMouseEvent* e) throw()
00100 {
00101 assert(0 != e);
00102 if (e->button() == Qt::LeftButton) {
00103 notify(mouse_left_double_click, e);
00104 } else if (e->button() == Qt::RightButton) {
00105 notify(mouse_right_double_click, e);
00106 } else if (e->button() == Qt::MidButton) {
00107 notify(mouse_middle_double_click, e);
00108 }
00109 }
00110
00111 template <typename T>
00112 instigate::toolkit::qt_item<T>::
00113 qt_item(const std::string& s, toolkit::window* w) throw()
00114 : item(s, w)
00115 {
00116 assert(!s.empty());
00117 assert(0 != w);
00118 }
00119
00120
00121
00122 #endif // INSTIGATE_TOOLKIT_QT_ITEM
00123