1 /* This file is part of the KDE project 2 Copyright (C) 2000 Simon Hausmann <hausmann@kde.org> 3 4 This library is free software; you can redistribute it and/or 5 modify it under the terms of the GNU Library General Public 6 License as published by the Free Software Foundation; either 7 version 2 of the License, or (at your option) any later version. 8 9 This library 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 GNU 12 Library General Public License for more details. 13 14 You should have received a copy of the GNU Library General Public License 15 along with this library; see the file COPYING.LIB. If not, write to 16 the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, 17 Boston, MA 02110-1301, USA. 18 */ 19 #ifndef __khtml_events_h__ 20 #define __khtml_events_h__ 21 22 #include <kparts/event.h> 23 24 #include "dom/dom_node.h" 25 #include "dom/dom_string.h" 26 27 class QMouseEvent; 28 class QPainter; 29 30 namespace khtml 31 { 32 33 class KHTML_EXPORT MouseEvent : public KParts::Event 34 { 35 public: 36 MouseEvent(const char *name, QMouseEvent *qmouseEvent, int x, int y, 37 const DOM::DOMString &url, const DOM::DOMString &target, 38 const DOM::Node &innerNode); 39 virtual ~MouseEvent(); 40 qmouseEvent()41 QMouseEvent *qmouseEvent() const 42 { 43 return m_qmouseEvent; 44 } x()45 int x() const 46 { 47 return m_x; 48 } y()49 int y() const 50 { 51 return m_y; 52 } absX()53 int absX() const 54 { 55 return m_nodeAbsX; 56 } absY()57 int absY() const 58 { 59 return m_nodeAbsY; 60 } 61 url()62 DOM::DOMString url() const 63 { 64 return m_url; 65 } target()66 DOM::DOMString target() const 67 { 68 return m_target; 69 } innerNode()70 DOM::Node innerNode() const 71 { 72 return m_innerNode; 73 } 74 75 // return the offset of innerNode 76 long offset() const; 77 78 private: 79 QMouseEvent *m_qmouseEvent; 80 int m_x; 81 int m_y; 82 int m_nodeAbsX, m_nodeAbsY; 83 DOM::DOMString m_url; 84 DOM::DOMString m_target; 85 DOM::Node m_innerNode; 86 class MouseEventPrivate; 87 MouseEventPrivate *d; 88 }; 89 90 class KHTML_EXPORT MousePressEvent : public MouseEvent 91 { 92 public: MousePressEvent(QMouseEvent * mouseEvent,int x,int y,const DOM::DOMString & url,const DOM::DOMString & target,const DOM::Node & innerNode)93 MousePressEvent(QMouseEvent *mouseEvent, int x, int y, 94 const DOM::DOMString &url, const DOM::DOMString &target, 95 const DOM::Node &innerNode) 96 : MouseEvent(s_strMousePressEvent, mouseEvent, x, y, url, target, innerNode) 97 {} 98 test(const QEvent * event)99 static bool test(const QEvent *event) 100 { 101 return KParts::Event::test(event, s_strMousePressEvent); 102 } 103 104 private: 105 static const char *s_strMousePressEvent; 106 }; 107 108 class KHTML_EXPORT MouseDoubleClickEvent : public MouseEvent 109 { 110 public: 111 // clickCount is 3 for a triple-click event 112 MouseDoubleClickEvent(QMouseEvent *mouseEvent, int x, int y, 113 const DOM::DOMString &url, const DOM::DOMString &target, 114 const DOM::Node &innerNode, int clickCount = 2) MouseEvent(s_strMouseDoubleClickEvent,mouseEvent,x,y,url,target,innerNode)115 : MouseEvent(s_strMouseDoubleClickEvent, mouseEvent, x, y, url, target, innerNode), 116 m_clickCount(clickCount) 117 {} 118 test(const QEvent * event)119 static bool test(const QEvent *event) 120 { 121 return KParts::Event::test(event, s_strMouseDoubleClickEvent); 122 } 123 clickCount()124 int clickCount() const 125 { 126 return m_clickCount; 127 } 128 129 private: 130 int m_clickCount; 131 static const char *s_strMouseDoubleClickEvent; 132 }; 133 134 class KHTML_EXPORT MouseMoveEvent : public MouseEvent 135 { 136 public: MouseMoveEvent(QMouseEvent * mouseEvent,int x,int y,const DOM::DOMString & url,const DOM::DOMString & target,const DOM::Node & innerNode)137 MouseMoveEvent(QMouseEvent *mouseEvent, int x, int y, 138 const DOM::DOMString &url, const DOM::DOMString &target, 139 const DOM::Node &innerNode) 140 : MouseEvent(s_strMouseMoveEvent, mouseEvent, x, y, url, target, innerNode) 141 {} 142 test(const QEvent * event)143 static bool test(const QEvent *event) 144 { 145 return KParts::Event::test(event, s_strMouseMoveEvent); 146 } 147 148 private: 149 static const char *s_strMouseMoveEvent; 150 }; 151 152 class KHTML_EXPORT MouseReleaseEvent : public MouseEvent 153 { 154 public: 155 MouseReleaseEvent(QMouseEvent *mouseEvent, int x, int y, 156 const DOM::DOMString &url, const DOM::DOMString &target, 157 const DOM::Node &innerNode, long = 0) MouseEvent(s_strMouseReleaseEvent,mouseEvent,x,y,url,target,innerNode)158 : MouseEvent(s_strMouseReleaseEvent, mouseEvent, x, y, url, target, innerNode) 159 {} 160 test(const QEvent * event)161 static bool test(const QEvent *event) 162 { 163 return KParts::Event::test(event, s_strMouseReleaseEvent); 164 } 165 166 private: 167 static const char *s_strMouseReleaseEvent; 168 }; 169 170 class KHTML_EXPORT DrawContentsEvent : public KParts::Event 171 { 172 public: 173 DrawContentsEvent(QPainter *painter, int clipx, int clipy, int clipw, int cliph); 174 virtual ~DrawContentsEvent(); 175 painter()176 QPainter *painter() const 177 { 178 return m_painter; 179 } clipx()180 int clipx() const 181 { 182 return m_clipx; 183 } clipy()184 int clipy() const 185 { 186 return m_clipy; 187 } clipw()188 int clipw() const 189 { 190 return m_clipw; 191 } cliph()192 int cliph() const 193 { 194 return m_cliph; 195 } 196 test(const QEvent * event)197 static bool test(const QEvent *event) 198 { 199 return KParts::Event::test(event, s_strDrawContentsEvent); 200 } 201 202 private: 203 QPainter *m_painter; 204 int m_clipx; 205 int m_clipy; 206 int m_clipw; 207 int m_cliph; 208 class DrawContentsEventPrivate; 209 DrawContentsEventPrivate *d; 210 static const char *s_strDrawContentsEvent; 211 }; 212 213 } 214 215 #endif 216